]> granicus.if.org Git - sysstat/commitdiff
Merge branch 'workaround-mpstat-overflow' of https://github.com/kosaki/sysstat
authorSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 30 Jun 2014 19:18:38 +0000 (21:18 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 30 Jun 2014 19:18:38 +0000 (21:18 +0200)
Added comments for ll_sp_value() function.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
1  2 
common.c

diff --cc common.c
index 353b9557ccb4d527d491b9ebc32285c51b71d5af,e96c8810d2ae4c559637d443d690bc40da43cfca..037e193b9e41e16501a3a33bddd6c3db90e25962
+++ b/common.c
@@@ -501,26 -501,13 +501,17 @@@ void get_HZ(void
        hz = (unsigned int) ticks;
  }
  
-  * Handle overflow conditions properly for counters which are read as
-  * unsigned long long, but which can be unsigned long long or
-  * unsigned long only depending on the kernel version used.
-  * @value1 and @value2 being two values successively read for this
-  * counter, if @value2 < @value1 and @value1 <= 0xffffffff, then we can
-  * assume that the counter's type was unsigned long and has overflown, and
-  * so the difference @value2 - @value1 must be casted to this type.
-  * NOTE: These functions should no longer be necessary to handle a particular
-  * stat counter when we can assume that everybody is using a recent kernel
-  * (defining this counter as unsigned long long).
 +/*
 + ***************************************************************************
++ * Workaround for CPU counters read from /proc/stat: Dyn-tick kernels
++ * have a race issue that can make those counters go backward.
 + ***************************************************************************
 + */
  double ll_sp_value(unsigned long long value1, unsigned long long value2,
                   unsigned long long itv)
  {
-       if ((value2 < value1) && (value1 <= 0xffffffff))
-               /* Counter's type was unsigned long and has overflown */
-               return ((double) ((value2 - value1) & 0xffffffff)) / itv * 100;
 -      /* Workaround: dyn-tick kernel has a race issue and /proc/stat values
 -         could be backward. */
+       if (value2 < value1)
 -              return 0;
++              return (double) 0;
        else
                return SP_VALUE(value1, value2, itv);
  }