[PATCH] Fix idle time field in /proc/uptime
authorMichael Abbott <michael.abbott@diamond.ac.uk>
Thu, 24 Sep 2009 08:15:19 +0000 (10:15 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 24 Sep 2009 08:16:24 +0000 (10:16 +0200)
Git commit 79741dd changes idle cputime accounting, but unfortunately
the /proc/uptime file hasn't caught up.  Here the idle time calculation
from /proc/stat is copied over.

Signed-off-by: Michael Abbott <michael.abbott@diamond.ac.uk>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
fs/proc/uptime.c

index 0c10a0b3f1460c5ff8d533de1c6304a657c097fd..766b1d456050ff98d2603f3af027b7d61b98174d 100644 (file)
@@ -4,13 +4,18 @@
 #include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <linux/time.h>
+#include <linux/kernel_stat.h>
 #include <asm/cputime.h>
 
 static int uptime_proc_show(struct seq_file *m, void *v)
 {
        struct timespec uptime;
        struct timespec idle;
-       cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
+       int i;
+       cputime_t idletime = cputime_zero;
+
+       for_each_possible_cpu(i)
+               idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
 
        do_posix_clock_monotonic_gettime(&uptime);
        monotonic_to_bootbased(&uptime);