]> 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>
Makefile.in
common.c
count.c
rd_stats.c

index 94c7b303b8aac419175097a7add6eac973be5284..7880270fd9bf647d41ba0d7995a89635d168ff1b 100644 (file)
@@ -548,16 +548,16 @@ maintainer-clean: distclean
        rm -f configure
 
 dist: almost-distclean
-       cd .. && (tar --exclude=Makefile --exclude=.git -cvf - sysstat-$(VERSION) | gzip -v9 > sysstat-$(VERSION).tar.gz)
+       cd .. && (tar --exclude=Makefile --exclude=.git --dereference -cvf - sysstat-$(VERSION) | gzip -v9 > sysstat-$(VERSION).tar.gz)
 
 bdist: almost-distclean
-       cd .. && (tar --exclude=Makefile --exclude=.git -cvf - sysstat-$(VERSION) | bzip2 > sysstat-$(VERSION).tar.bz2)
+       cd .. && (tar --exclude=Makefile --exclude=.git --dereference -cvf - sysstat-$(VERSION) | bzip2 > sysstat-$(VERSION).tar.bz2)
 
 xdist: almost-distclean
-       cd .. && (tar --exclude=Makefile --exclude=.git -cvf - sysstat-$(VERSION) | xz > sysstat-$(VERSION).tar.xz)
+       cd .. && (tar --exclude=Makefile --exclude=.git --dereference -cvf - sysstat-$(VERSION) | xz > sysstat-$(VERSION).tar.xz)
 
 gitdist: almost-distclean
-       cd .. && (tar --exclude=Makefile -cvf - sysstat-$(VERSION) | bzip2 > sysstat-$(VERSION)-git.tar.bz2)
+       cd .. && (tar --exclude=Makefile --dereference -cvf - sysstat-$(VERSION) | bzip2 > sysstat-$(VERSION)-git.tar.bz2)
 
 tags:
        etags ./*.[hc]
index e96c8810d2ae4c559637d443d690bc40da43cfca..037e193b9e41e16501a3a33bddd6c3db90e25962 100644 (file)
--- a/common.c
+++ b/common.c
@@ -501,13 +501,17 @@ void get_HZ(void)
        hz = (unsigned int) ticks;
 }
 
+/*
+ ***************************************************************************
+ * 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)
 {
-       /* 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);
 }
diff --git a/count.c b/count.c
index 426af31aa1f13e5a67ed132ed4b17b6e7358b241..ceca3f5a1336430ecd418f9e66002ff133d03db9 100644 (file)
--- a/count.c
+++ b/count.c
@@ -27,7 +27,7 @@
 #include <ctype.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/vfs.h>
+#include <sys/statvfs.h>
 #include <unistd.h>
 
 #include "common.h"
@@ -463,7 +463,7 @@ int get_filesystem_nr(void)
        FILE *fp;
        char line[256], fs_name[MAX_FS_LEN], mountp[128];
        int fs = 0;
-       struct statfs buf;
+       struct statvfs buf;
 
        if ((fp = fopen(MTAB, "r")) == NULL)
                /* File non-existent */
@@ -480,7 +480,7 @@ int get_filesystem_nr(void)
                        oct2chr(mountp);
 
                        /* Check that total size is not null */
-                       if (statfs(mountp, &buf) < 0)
+                       if (statvfs(mountp, &buf) < 0)
                                continue;
 
                        if (buf.f_blocks) {
index 6ea549c2f5b802d6688e03376d8ad4b38f93dc65..899671d0f0a77142f5c5be2d98c22756a637b811 100644 (file)
@@ -27,7 +27,7 @@
 #include <ctype.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/vfs.h>
+#include <sys/statvfs.h>
 #include <unistd.h>
 
 #include "common.h"
@@ -2015,7 +2015,7 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
        char line[256], fs_name[MAX_FS_LEN], mountp[128];
        int fs = 0;
        struct stats_filesystem *st_filesystem_i;
-       struct statfs buf;
+       struct statvfs buf;
 
        if ((fp = fopen(MTAB, "r")) == NULL)
                return;
@@ -2029,13 +2029,13 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
                        /* Replace octal codes */
                        oct2chr(mountp);
 
-                       if ((statfs(mountp, &buf) < 0) || (!buf.f_blocks))
+                       if ((statvfs(mountp, &buf) < 0) || (!buf.f_blocks))
                                continue;
 
                        st_filesystem_i = st_filesystem + fs++;
-                       st_filesystem_i->f_blocks = buf.f_blocks * buf.f_bsize;
-                       st_filesystem_i->f_bfree  = buf.f_bfree * buf.f_bsize;
-                       st_filesystem_i->f_bavail = buf.f_bavail * buf.f_bsize;
+                       st_filesystem_i->f_blocks = buf.f_blocks * buf.f_frsize;
+                       st_filesystem_i->f_bfree  = buf.f_bfree * buf.f_frsize;
+                       st_filesystem_i->f_bavail = buf.f_bavail * buf.f_frsize;
                        st_filesystem_i->f_files  = buf.f_files;
                        st_filesystem_i->f_ffree  = buf.f_ffree;
                        strcpy(st_filesystem_i->fs_name, fs_name);