Skip to content

Commit e1c8053

Browse files
author
Martin Schwidefsky
committed
[S390] /proc/stat idle field for idle cpus
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>
1 parent b1ad171 commit e1c8053

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎arch/s390/include/asm/cputime.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,8 @@ cputime64_to_clock_t(cputime64_t cputime)
174174
return __div(cputime, 4096000000ULL / USER_HZ);
175175
}
176176

177+
cputime64_t s390_get_idle_time(int cpu);
178+
179+
#define arch_idle_time(cpu) s390_get_idle_time(cpu)
180+
177181
#endif /* _S390_CPUTIME_H */

‎arch/s390/kernel/vtime.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,22 @@ void vtime_stop_cpu(void)
240240
}
241241
}
242242

243+
cputime64_t s390_get_idle_time(int cpu)
244+
{
245+
struct s390_idle_data *idle;
246+
unsigned long long now, idle_time, idle_enter;
247+
248+
idle = &per_cpu(s390_idle, cpu);
249+
spin_lock(&idle->lock);
250+
now = get_clock();
251+
idle_time = 0;
252+
idle_enter = idle->idle_enter;
253+
if (idle_enter != 0ULL && idle_enter < now)
254+
idle_time = now - idle_enter;
255+
spin_unlock(&idle->lock);
256+
return idle_time;
257+
}
258+
243259
/*
244260
* Sorted add to a list. List is linear searched until first bigger
245261
* element is found.

‎fs/proc/stat.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#ifndef arch_irq_stat
1919
#define arch_irq_stat() 0
2020
#endif
21+
#ifndef arch_idle_time
22+
#define arch_idle_time(cpu) 0
23+
#endif
2124

2225
static int show_stat(struct seq_file *p, void *v)
2326
{
@@ -40,6 +43,7 @@ static int show_stat(struct seq_file *p, void *v)
4043
nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
4144
system = cputime64_add(system, kstat_cpu(i).cpustat.system);
4245
idle = cputime64_add(idle, kstat_cpu(i).cpustat.idle);
46+
idle = cputime64_add(idle, arch_idle_time(i));
4347
iowait = cputime64_add(iowait, kstat_cpu(i).cpustat.iowait);
4448
irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq);
4549
softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
@@ -69,6 +73,7 @@ static int show_stat(struct seq_file *p, void *v)
6973
nice = kstat_cpu(i).cpustat.nice;
7074
system = kstat_cpu(i).cpustat.system;
7175
idle = kstat_cpu(i).cpustat.idle;
76+
idle = cputime64_add(idle, arch_idle_time(i));
7277
iowait = kstat_cpu(i).cpustat.iowait;
7378
irq = kstat_cpu(i).cpustat.irq;
7479
softirq = kstat_cpu(i).cpustat.softirq;

0 commit comments

Comments
 (0)