]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Use 64-bit counters for scheduler stats
authorAndrew Morton <akpm@osdl.org>
Sat, 13 Mar 2004 11:25:38 +0000 (03:25 -0800)
committerLen Brown <len.brown@intel.com>
Sat, 13 Mar 2004 11:25:38 +0000 (03:25 -0800)
From: Kingsley Cheung <kingsley@aurema.com>

A number of scheduler counters wrap around after 47 days.  The context-switch
counter can wrap around after considerably less time.

Convert them to 64-bit values.

fs/proc/proc_misc.c
include/linux/kernel_stat.h
kernel/sched.c

index 328bcd3405cc4546cb5b95d06a7241481bba7dd8..beeb7e99e28a3916d9140ead273bd42e9e1f02fc 100644 (file)
@@ -361,7 +361,8 @@ int show_stat(struct seq_file *p, void *v)
        int i;
        extern unsigned long total_forks;
        unsigned long jif;
-       unsigned int sum = 0, user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0;
+       u64     sum = 0, user = 0, nice = 0, system = 0,
+               idle = 0, iowait = 0, irq = 0, softirq = 0;
 
        jif = - wall_to_monotonic.tv_sec;
        if (wall_to_monotonic.tv_nsec)
@@ -381,26 +382,35 @@ int show_stat(struct seq_file *p, void *v)
                        sum += kstat_cpu(i).irqs[j];
        }
 
-       seq_printf(p, "cpu  %u %u %u %u %u %u %u\n",
-               jiffies_to_clock_t(user),
-               jiffies_to_clock_t(nice),
-               jiffies_to_clock_t(system),
-               jiffies_to_clock_t(idle),
-               jiffies_to_clock_t(iowait),
-               jiffies_to_clock_t(irq),
-               jiffies_to_clock_t(softirq));
+       seq_printf(p, "cpu  %llu %llu %llu %llu %llu %llu %llu\n",
+               (unsigned long long)jiffies_64_to_clock_t(user),
+               (unsigned long long)jiffies_64_to_clock_t(nice),
+               (unsigned long long)jiffies_64_to_clock_t(system),
+               (unsigned long long)jiffies_64_to_clock_t(idle),
+               (unsigned long long)jiffies_64_to_clock_t(iowait),
+               (unsigned long long)jiffies_64_to_clock_t(irq),
+               (unsigned long long)jiffies_64_to_clock_t(softirq));
        for_each_cpu(i) {
-               seq_printf(p, "cpu%d %u %u %u %u %u %u %u\n",
+               /* two separate calls here to work around gcc-2.95.3 ICE */
+               seq_printf(p, "cpu%d %llu %llu %llu ",
                        i,
-                       jiffies_to_clock_t(kstat_cpu(i).cpustat.user),
-                       jiffies_to_clock_t(kstat_cpu(i).cpustat.nice),
-                       jiffies_to_clock_t(kstat_cpu(i).cpustat.system),
-                       jiffies_to_clock_t(kstat_cpu(i).cpustat.idle),
-                       jiffies_to_clock_t(kstat_cpu(i).cpustat.iowait),
-                       jiffies_to_clock_t(kstat_cpu(i).cpustat.irq),
-                       jiffies_to_clock_t(kstat_cpu(i).cpustat.softirq));
+                       (unsigned long long)
+                         jiffies_64_to_clock_t(kstat_cpu(i).cpustat.user),
+                       (unsigned long long)
+                         jiffies_64_to_clock_t(kstat_cpu(i).cpustat.nice),
+                       (unsigned long long)
+                         jiffies_64_to_clock_t(kstat_cpu(i).cpustat.system));
+               seq_printf(p, "%llu %llu %llu %llu\n",
+                       (unsigned long long)
+                         jiffies_64_to_clock_t(kstat_cpu(i).cpustat.idle),
+                       (unsigned long long)
+                         jiffies_64_to_clock_t(kstat_cpu(i).cpustat.iowait),
+                       (unsigned long long)
+                         jiffies_64_to_clock_t(kstat_cpu(i).cpustat.irq),
+                       (unsigned long long)
+                         jiffies_64_to_clock_t(kstat_cpu(i).cpustat.softirq));
        }
-       seq_printf(p, "intr %u", sum);
+       seq_printf(p, "intr %llu", (unsigned long long)sum);
 
 #if !defined(CONFIG_PPC64) && !defined(CONFIG_ALPHA)
        for (i = 0; i < NR_IRQS; i++)
@@ -408,7 +418,7 @@ int show_stat(struct seq_file *p, void *v)
 #endif
 
        seq_printf(p,
-               "\nctxt %lu\n"
+               "\nctxt %llu\n"
                "btime %lu\n"
                "processes %lu\n"
                "procs_running %lu\n"
index 17a9656a31fb86d8a08326b7f6157560bb2afa91..4594ccc4a7c1f73b414aeaca89e201f9b11c306c 100644 (file)
  */
 
 struct cpu_usage_stat {
-       unsigned int user;
-       unsigned int nice;
-       unsigned int system;
-       unsigned int softirq;
-       unsigned int irq;
-       unsigned int idle;
-       unsigned int iowait;
+       u64 user;
+       u64 nice;
+       u64 system;
+       u64 softirq;
+       u64 irq;
+       u64 idle;
+       u64 iowait;
 };
 
 struct kernel_stat {
@@ -34,7 +34,7 @@ DECLARE_PER_CPU(struct kernel_stat, kstat);
 /* Must have preemption disabled for this to be meaningful. */
 #define kstat_this_cpu __get_cpu_var(kstat)
 
-extern unsigned long nr_context_switches(void);
+extern unsigned long long nr_context_switches(void);
 
 /*
  * Number of interrupts per specific IRQ source, since bootup
index 28cd05aba0ec72f763c5c0af43d4e77eb5751a8b..894cb9a406639cdd722255ca29e8d9dd15bcd982 100644 (file)
@@ -201,8 +201,9 @@ struct prio_array {
  */
 struct runqueue {
        spinlock_t lock;
-       unsigned long nr_running, nr_switches, expired_timestamp,
-                     nr_uninterruptible, timestamp_last_tick;
+       unsigned long long nr_switches;
+       unsigned long nr_running, expired_timestamp, nr_uninterruptible,
+               timestamp_last_tick;
        task_t *curr, *idle;
        struct mm_struct *prev_mm;
        prio_array_t *active, *expired, arrays[2];
@@ -950,9 +951,9 @@ unsigned long nr_uninterruptible(void)
        return sum;
 }
 
-unsigned long nr_context_switches(void)
+unsigned long long nr_context_switches(void)
 {
-       unsigned long i, sum = 0;
+       unsigned long long i, sum = 0;
 
        for_each_cpu(i)
                sum += cpu_rq(i)->nr_switches;