Commit 26dae145 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Ingo Molnar

procfs: Use all-in-one vtime aware kcpustat accessor

Now that we can read also user and guest time safely under vtime, use
the relevant accessor to fix frozen kcpustat values on nohz_full CPUs.
Reported-by: default avatarYauheni Kaliuta <yauheni.kaliuta@redhat.com>
Signed-off-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wanpeng Li <wanpengli@tencent.com>
Link: https://lkml.kernel.org/r/20191121024430.19938-4-frederic@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 74722bb2
...@@ -120,20 +120,23 @@ static int show_stat(struct seq_file *p, void *v) ...@@ -120,20 +120,23 @@ static int show_stat(struct seq_file *p, void *v)
getboottime64(&boottime); getboottime64(&boottime);
for_each_possible_cpu(i) { for_each_possible_cpu(i) {
struct kernel_cpustat *kcs = &kcpustat_cpu(i); struct kernel_cpustat kcpustat;
u64 *cpustat = kcpustat.cpustat;
user += kcs->cpustat[CPUTIME_USER];
nice += kcs->cpustat[CPUTIME_NICE]; kcpustat_cpu_fetch(&kcpustat, i);
system += kcpustat_field(kcs, CPUTIME_SYSTEM, i);
idle += get_idle_time(kcs, i); user += cpustat[CPUTIME_USER];
iowait += get_iowait_time(kcs, i); nice += cpustat[CPUTIME_NICE];
irq += kcs->cpustat[CPUTIME_IRQ]; system += cpustat[CPUTIME_SYSTEM];
softirq += kcs->cpustat[CPUTIME_SOFTIRQ]; idle += get_idle_time(&kcpustat, i);
steal += kcs->cpustat[CPUTIME_STEAL]; iowait += get_iowait_time(&kcpustat, i);
guest += kcs->cpustat[CPUTIME_GUEST]; irq += cpustat[CPUTIME_IRQ];
guest_nice += kcs->cpustat[CPUTIME_GUEST_NICE]; softirq += cpustat[CPUTIME_SOFTIRQ];
sum += kstat_cpu_irqs_sum(i); steal += cpustat[CPUTIME_STEAL];
sum += arch_irq_stat_cpu(i); guest += cpustat[CPUTIME_GUEST];
guest_nice += cpustat[CPUTIME_USER];
sum += kstat_cpu_irqs_sum(i);
sum += arch_irq_stat_cpu(i);
for (j = 0; j < NR_SOFTIRQS; j++) { for (j = 0; j < NR_SOFTIRQS; j++) {
unsigned int softirq_stat = kstat_softirqs_cpu(j, i); unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
...@@ -157,19 +160,22 @@ static int show_stat(struct seq_file *p, void *v) ...@@ -157,19 +160,22 @@ static int show_stat(struct seq_file *p, void *v)
seq_putc(p, '\n'); seq_putc(p, '\n');
for_each_online_cpu(i) { for_each_online_cpu(i) {
struct kernel_cpustat *kcs = &kcpustat_cpu(i); struct kernel_cpustat kcpustat;
u64 *cpustat = kcpustat.cpustat;
kcpustat_cpu_fetch(&kcpustat, i);
/* Copy values here to work around gcc-2.95.3, gcc-2.96 */ /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
user = kcs->cpustat[CPUTIME_USER]; user = cpustat[CPUTIME_USER];
nice = kcs->cpustat[CPUTIME_NICE]; nice = cpustat[CPUTIME_NICE];
system = kcpustat_field(kcs, CPUTIME_SYSTEM, i); system = cpustat[CPUTIME_SYSTEM];
idle = get_idle_time(kcs, i); idle = get_idle_time(&kcpustat, i);
iowait = get_iowait_time(kcs, i); iowait = get_iowait_time(&kcpustat, i);
irq = kcs->cpustat[CPUTIME_IRQ]; irq = cpustat[CPUTIME_IRQ];
softirq = kcs->cpustat[CPUTIME_SOFTIRQ]; softirq = cpustat[CPUTIME_SOFTIRQ];
steal = kcs->cpustat[CPUTIME_STEAL]; steal = cpustat[CPUTIME_STEAL];
guest = kcs->cpustat[CPUTIME_GUEST]; guest = cpustat[CPUTIME_GUEST];
guest_nice = kcs->cpustat[CPUTIME_GUEST_NICE]; guest_nice = cpustat[CPUTIME_USER];
seq_printf(p, "cpu%d", i); seq_printf(p, "cpu%d", i);
seq_put_decimal_ull(p, " ", nsec_to_clock_t(user)); seq_put_decimal_ull(p, " ", nsec_to_clock_t(user));
seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice)); seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice));
......
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