Commit 0281d847 authored by Andrew Morton's avatar Andrew Morton Committed by Len Brown

[PATCH] Use 64-bit counters for scheduler stats

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.
parent baf129a1
...@@ -361,7 +361,8 @@ int show_stat(struct seq_file *p, void *v) ...@@ -361,7 +361,8 @@ int show_stat(struct seq_file *p, void *v)
int i; int i;
extern unsigned long total_forks; extern unsigned long total_forks;
unsigned long jif; 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; jif = - wall_to_monotonic.tv_sec;
if (wall_to_monotonic.tv_nsec) if (wall_to_monotonic.tv_nsec)
...@@ -381,26 +382,35 @@ int show_stat(struct seq_file *p, void *v) ...@@ -381,26 +382,35 @@ int show_stat(struct seq_file *p, void *v)
sum += kstat_cpu(i).irqs[j]; sum += kstat_cpu(i).irqs[j];
} }
seq_printf(p, "cpu %u %u %u %u %u %u %u\n", seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu\n",
jiffies_to_clock_t(user), (unsigned long long)jiffies_64_to_clock_t(user),
jiffies_to_clock_t(nice), (unsigned long long)jiffies_64_to_clock_t(nice),
jiffies_to_clock_t(system), (unsigned long long)jiffies_64_to_clock_t(system),
jiffies_to_clock_t(idle), (unsigned long long)jiffies_64_to_clock_t(idle),
jiffies_to_clock_t(iowait), (unsigned long long)jiffies_64_to_clock_t(iowait),
jiffies_to_clock_t(irq), (unsigned long long)jiffies_64_to_clock_t(irq),
jiffies_to_clock_t(softirq)); (unsigned long long)jiffies_64_to_clock_t(softirq));
for_each_cpu(i) { 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, i,
jiffies_to_clock_t(kstat_cpu(i).cpustat.user), (unsigned long long)
jiffies_to_clock_t(kstat_cpu(i).cpustat.nice), jiffies_64_to_clock_t(kstat_cpu(i).cpustat.user),
jiffies_to_clock_t(kstat_cpu(i).cpustat.system), (unsigned long long)
jiffies_to_clock_t(kstat_cpu(i).cpustat.idle), jiffies_64_to_clock_t(kstat_cpu(i).cpustat.nice),
jiffies_to_clock_t(kstat_cpu(i).cpustat.iowait), (unsigned long long)
jiffies_to_clock_t(kstat_cpu(i).cpustat.irq), jiffies_64_to_clock_t(kstat_cpu(i).cpustat.system));
jiffies_to_clock_t(kstat_cpu(i).cpustat.softirq)); 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) #if !defined(CONFIG_PPC64) && !defined(CONFIG_ALPHA)
for (i = 0; i < NR_IRQS; i++) for (i = 0; i < NR_IRQS; i++)
...@@ -408,7 +418,7 @@ int show_stat(struct seq_file *p, void *v) ...@@ -408,7 +418,7 @@ int show_stat(struct seq_file *p, void *v)
#endif #endif
seq_printf(p, seq_printf(p,
"\nctxt %lu\n" "\nctxt %llu\n"
"btime %lu\n" "btime %lu\n"
"processes %lu\n" "processes %lu\n"
"procs_running %lu\n" "procs_running %lu\n"
......
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
*/ */
struct cpu_usage_stat { struct cpu_usage_stat {
unsigned int user; u64 user;
unsigned int nice; u64 nice;
unsigned int system; u64 system;
unsigned int softirq; u64 softirq;
unsigned int irq; u64 irq;
unsigned int idle; u64 idle;
unsigned int iowait; u64 iowait;
}; };
struct kernel_stat { struct kernel_stat {
...@@ -34,7 +34,7 @@ DECLARE_PER_CPU(struct kernel_stat, kstat); ...@@ -34,7 +34,7 @@ DECLARE_PER_CPU(struct kernel_stat, kstat);
/* Must have preemption disabled for this to be meaningful. */ /* Must have preemption disabled for this to be meaningful. */
#define kstat_this_cpu __get_cpu_var(kstat) #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 * Number of interrupts per specific IRQ source, since bootup
......
...@@ -201,8 +201,9 @@ struct prio_array { ...@@ -201,8 +201,9 @@ struct prio_array {
*/ */
struct runqueue { struct runqueue {
spinlock_t lock; spinlock_t lock;
unsigned long nr_running, nr_switches, expired_timestamp, unsigned long long nr_switches;
nr_uninterruptible, timestamp_last_tick; unsigned long nr_running, expired_timestamp, nr_uninterruptible,
timestamp_last_tick;
task_t *curr, *idle; task_t *curr, *idle;
struct mm_struct *prev_mm; struct mm_struct *prev_mm;
prio_array_t *active, *expired, arrays[2]; prio_array_t *active, *expired, arrays[2];
...@@ -950,9 +951,9 @@ unsigned long nr_uninterruptible(void) ...@@ -950,9 +951,9 @@ unsigned long nr_uninterruptible(void)
return sum; 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) for_each_cpu(i)
sum += cpu_rq(i)->nr_switches; sum += cpu_rq(i)->nr_switches;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment