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)
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"
......
......@@ -14,13 +14,13 @@
*/
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
......
......@@ -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;
......
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