Various cosmetic fixes.
authorSebastien Godard <sysstat@orange.fr>
Sat, 6 Nov 2010 14:19:02 +0000 (15:19 +0100)
committerSebastien Godard <sysstat@orange.fr>
Sat, 6 Nov 2010 14:19:02 +0000 (15:19 +0100)
.gitignore file has been updated.
This patch also includes a small fix for sar CPU frequency activity
(sar -m CPU). It now takes into account a specific case of machines
where /sys isn't mounted and which don't have an SMP kernel running.
In this case, the number of CPU is counted using /proc/stat file, and
this file only has a line with global CPU statistics. The number of
items for CPU frequency activity is then equal to 1, which was
badly handled by read_cpuinfo() function in rd_stats.c. This patch
fixes that.

.gitignore
rd_stats.c

index 84232ba49e73a7d9644d52cf9c36be6320fcab92..e4dbf15b562207bbc48c73c5a545c57eef336c05 100644 (file)
@@ -1,9 +1,7 @@
 # Lines starting with '#' are considered comments.
-# Ignore Makefile
+# List of files to ignore:
 Makefile
-# Ignore objects and archives.
 *.[oa]
-# Ignore files created by sysstat
 sa1
 sa2
 sysstat
index 59f90aa8d23a63fc12e14c0b35718ed3c56190e9..a4ffa7eb2c53da9f935e567f8f3f9941177f33de 100644 (file)
@@ -1605,7 +1605,7 @@ void read_cpuinfo(struct stats_pwr_cpufreq *st_pwr_cpufreq, int nbr)
                else if (!strncmp(line, "cpu MHz\t", 8)) {
                        sscanf(strchr(line, ':') + 1, "%u.%u", &ifreq, &dfreq);
                        
-                       if (proc_nb < (nbr - 1)) {                      /* FIXME: quelle reaction pour un kernel non SMP 1 proc? */
+                       if (proc_nb < (nbr - 1)) {
                                /* Save current CPU frequency */
                                st_pwr_cpufreq_i = st_pwr_cpufreq + proc_nb + 1;
                                st_pwr_cpufreq_i->cpufreq = ifreq * 100 + dfreq / 10;
@@ -1614,6 +1614,16 @@ void read_cpuinfo(struct stats_pwr_cpufreq *st_pwr_cpufreq, int nbr)
                                st_pwr_cpufreq->cpufreq += st_pwr_cpufreq_i->cpufreq;
                                nr++;
                        }
+                       else if (!proc_nb && (nbr == 1)) {
+                               /*
+                                * We are reading freq for "Processor 0" and we have a machine
+                                * with only one processor and not an SMP kernel, with /sys not mounted
+                                * (the nr of proc has been counted using /proc/stat and there was
+                                * only one line with global CPU stats here).
+                                * This is a very specific case, I must admit...
+                                */
+                               st_pwr_cpufreq->cpufreq = ifreq * 100 + dfreq / 10;
+                       }
                }
        }
        
@@ -2089,7 +2099,7 @@ int get_disk_nr(unsigned int f)
  * RETURNS:
  * Number of processors (online and offline).
  * A value of 0 means that /sys was not mounted.
- * A value of N (!=0) means N processor(s) (0 .. N-1).
+ * A value of N (!=0) means N processor(s) (cpu0 .. cpu(N-1)).
  ***************************************************************************
  */
 int get_sys_cpu_nr(void)