sched/cputime: Convert kcpustat to nsecs
Kernel CPU stats are stored in cputime_t which is an architecture defined type, and hence a bit opaque and requiring accessors and mutators for any operation. Converting them to nsecs simplifies the code and is one step toward the removal of cputime_t in the core code. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Stanislaw Gruszka <sgruszka@redhat.com> Cc: Wanpeng Li <wanpeng.li@hotmail.com> Link: http://lkml.kernel.org/r/1485832191-26889-4-git-send-email-fweisbec@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
committed by
Ingo Molnar
parent
ba03ce822d
commit
7fb1327ee9
@@ -21,23 +21,23 @@
|
||||
|
||||
#ifdef arch_idle_time
|
||||
|
||||
static cputime64_t get_idle_time(int cpu)
|
||||
static u64 get_idle_time(int cpu)
|
||||
{
|
||||
cputime64_t idle;
|
||||
u64 idle;
|
||||
|
||||
idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];
|
||||
if (cpu_online(cpu) && !nr_iowait_cpu(cpu))
|
||||
idle += arch_idle_time(cpu);
|
||||
idle += cputime_to_nsecs(arch_idle_time(cpu));
|
||||
return idle;
|
||||
}
|
||||
|
||||
static cputime64_t get_iowait_time(int cpu)
|
||||
static u64 get_iowait_time(int cpu)
|
||||
{
|
||||
cputime64_t iowait;
|
||||
u64 iowait;
|
||||
|
||||
iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];
|
||||
if (cpu_online(cpu) && nr_iowait_cpu(cpu))
|
||||
iowait += arch_idle_time(cpu);
|
||||
iowait += cputime_to_nsecs(arch_idle_time(cpu));
|
||||
return iowait;
|
||||
}
|
||||
|
||||
@@ -45,32 +45,32 @@ static cputime64_t get_iowait_time(int cpu)
|
||||
|
||||
static u64 get_idle_time(int cpu)
|
||||
{
|
||||
u64 idle, idle_time = -1ULL;
|
||||
u64 idle, idle_usecs = -1ULL;
|
||||
|
||||
if (cpu_online(cpu))
|
||||
idle_time = get_cpu_idle_time_us(cpu, NULL);
|
||||
idle_usecs = get_cpu_idle_time_us(cpu, NULL);
|
||||
|
||||
if (idle_time == -1ULL)
|
||||
if (idle_usecs == -1ULL)
|
||||
/* !NO_HZ or cpu offline so we can rely on cpustat.idle */
|
||||
idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];
|
||||
else
|
||||
idle = usecs_to_cputime64(idle_time);
|
||||
idle = idle_usecs * NSEC_PER_USEC;
|
||||
|
||||
return idle;
|
||||
}
|
||||
|
||||
static u64 get_iowait_time(int cpu)
|
||||
{
|
||||
u64 iowait, iowait_time = -1ULL;
|
||||
u64 iowait, iowait_usecs = -1ULL;
|
||||
|
||||
if (cpu_online(cpu))
|
||||
iowait_time = get_cpu_iowait_time_us(cpu, NULL);
|
||||
iowait_usecs = get_cpu_iowait_time_us(cpu, NULL);
|
||||
|
||||
if (iowait_time == -1ULL)
|
||||
if (iowait_usecs == -1ULL)
|
||||
/* !NO_HZ or cpu offline so we can rely on cpustat.iowait */
|
||||
iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];
|
||||
else
|
||||
iowait = usecs_to_cputime64(iowait_time);
|
||||
iowait = iowait_usecs * NSEC_PER_USEC;
|
||||
|
||||
return iowait;
|
||||
}
|
||||
@@ -115,16 +115,16 @@ static int show_stat(struct seq_file *p, void *v)
|
||||
}
|
||||
sum += arch_irq_stat();
|
||||
|
||||
seq_put_decimal_ull(p, "cpu ", cputime64_to_clock_t(user));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(nice));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(system));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(idle));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(iowait));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(irq));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(softirq));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(steal));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(guest));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(guest_nice));
|
||||
seq_put_decimal_ull(p, "cpu ", nsec_to_clock_t(user));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(system));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(idle));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(iowait));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(irq));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(softirq));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(steal));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(guest));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(guest_nice));
|
||||
seq_putc(p, '\n');
|
||||
|
||||
for_each_online_cpu(i) {
|
||||
@@ -140,16 +140,16 @@ static int show_stat(struct seq_file *p, void *v)
|
||||
guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
|
||||
guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
|
||||
seq_printf(p, "cpu%d", i);
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(user));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(nice));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(system));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(idle));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(iowait));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(irq));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(softirq));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(steal));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(guest));
|
||||
seq_put_decimal_ull(p, " ", cputime64_to_clock_t(guest_nice));
|
||||
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(system));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(idle));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(iowait));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(irq));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(softirq));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(steal));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(guest));
|
||||
seq_put_decimal_ull(p, " ", nsec_to_clock_t(guest_nice));
|
||||
seq_putc(p, '\n');
|
||||
}
|
||||
seq_put_decimal_ull(p, "intr ", (unsigned long long)sum);
|
||||
|
||||
Reference in New Issue
Block a user