mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
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 <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: Tony Luck <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Stanislaw Gruszka <[email protected]> Cc: Wanpeng Li <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
ba03ce822d
commit
7fb1327ee9
9 changed files with 61 additions and 65 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -5,23 +5,20 @@
|
|||
#include <linux/seq_file.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/kernel_stat.h>
|
||||
#include <linux/cputime.h>
|
||||
|
||||
static int uptime_proc_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct timespec uptime;
|
||||
struct timespec idle;
|
||||
u64 idletime;
|
||||
u64 nsec;
|
||||
u32 rem;
|
||||
int i;
|
||||
|
||||
idletime = 0;
|
||||
nsec = 0;
|
||||
for_each_possible_cpu(i)
|
||||
idletime += (__force u64) kcpustat_cpu(i).cpustat[CPUTIME_IDLE];
|
||||
nsec += (__force u64) kcpustat_cpu(i).cpustat[CPUTIME_IDLE];
|
||||
|
||||
get_monotonic_boottime(&uptime);
|
||||
nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
|
||||
idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
|
||||
idle.tv_nsec = rem;
|
||||
seq_printf(m, "%lu.%02lu %lu.%02lu\n",
|
||||
|
|
|
|||
Loading…
Reference in a new issue