]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
[S390] /proc/stat idle field for idle cpus
authorMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 23 Apr 2009 11:58:08 +0000 (13:58 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 23 Apr 2009 11:58:17 +0000 (13:58 +0200)
The cpu idle field in the output of /proc/stat is too small for cpus
that have been idle for more than a tick. Add the architecture hook
arch_idle_time that allows to add the not accounted idle time of a
sleeping cpu without waking the cpu.

The s390 implementation of arch_idle_time uses the already existing
s390_idle_data per_cpu variable to find the sleep time of a neighboring
idle cpu.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/cputime.h
arch/s390/kernel/vtime.c
fs/proc/stat.c

index 95b0f7db3c69dcb076c7969ceacba1f5ab2f82b0..941384fbd39c503b79bd9ebdebe3ef35772a6e7e 100644 (file)
@@ -174,4 +174,8 @@ cputime64_to_clock_t(cputime64_t cputime)
        return __div(cputime, 4096000000ULL / USER_HZ);
 }
 
+cputime64_t s390_get_idle_time(int cpu);
+
+#define arch_idle_time(cpu) s390_get_idle_time(cpu)
+
 #endif /* _S390_CPUTIME_H */
index 38ea92ff04f9ad9dd2fdbefbcf50de95f8474c50..c87f59bd8246a9ecdbe9d9417a58b19975df72f9 100644 (file)
@@ -240,6 +240,22 @@ void vtime_stop_cpu(void)
        }
 }
 
+cputime64_t s390_get_idle_time(int cpu)
+{
+       struct s390_idle_data *idle;
+       unsigned long long now, idle_time, idle_enter;
+
+       idle = &per_cpu(s390_idle, cpu);
+       spin_lock(&idle->lock);
+       now = get_clock();
+       idle_time = 0;
+       idle_enter = idle->idle_enter;
+       if (idle_enter != 0ULL && idle_enter < now)
+               idle_time = now - idle_enter;
+       spin_unlock(&idle->lock);
+       return idle_time;
+}
+
 /*
  * Sorted add to a list. List is linear searched until first bigger
  * element is found.
index f75efa22df5ee39eba1e23f4998ed01567e35b8f..81e4eb60972e8ba04234e48305448ef40e88afe5 100644 (file)
@@ -18,6 +18,9 @@
 #ifndef arch_irq_stat
 #define arch_irq_stat() 0
 #endif
+#ifndef arch_idle_time
+#define arch_idle_time(cpu) 0
+#endif
 
 static int show_stat(struct seq_file *p, void *v)
 {
@@ -40,6 +43,7 @@ static int show_stat(struct seq_file *p, void *v)
                nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
                system = cputime64_add(system, kstat_cpu(i).cpustat.system);
                idle = cputime64_add(idle, kstat_cpu(i).cpustat.idle);
+               idle = cputime64_add(idle, arch_idle_time(i));
                iowait = cputime64_add(iowait, kstat_cpu(i).cpustat.iowait);
                irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq);
                softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
@@ -69,6 +73,7 @@ static int show_stat(struct seq_file *p, void *v)
                nice = kstat_cpu(i).cpustat.nice;
                system = kstat_cpu(i).cpustat.system;
                idle = kstat_cpu(i).cpustat.idle;
+               idle = cputime64_add(idle, arch_idle_time(i));
                iowait = kstat_cpu(i).cpustat.iowait;
                irq = kstat_cpu(i).cpustat.irq;
                softirq = kstat_cpu(i).cpustat.softirq;