diff options
author | Glauber Costa <glommer@parallels.com> | 2011-11-28 11:45:17 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-12-06 03:06:38 -0500 |
commit | 3292beb340c76884427faa1f5d6085719477d889 (patch) | |
tree | cb7e431b2a15fa66ef5278d485131bac7a125fbd /fs | |
parent | 786d6dc7aeb2bfbfe417507b7beb83919f319db3 (diff) |
sched/accounting: Change cpustat fields to an array
This patch changes fields in cpustat from a structure, to an
u64 array. Math gets easier, and the code is more flexible.
Signed-off-by: Glauber Costa <glommer@parallels.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul Tuner <pjt@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1322498719-2255-2-git-send-email-glommer@parallels.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/proc/stat.c | 63 | ||||
-rw-r--r-- | fs/proc/uptime.c | 4 |
2 files changed, 31 insertions, 36 deletions
diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 42b274da92c3..8a6ab666e9f8 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c | |||
@@ -22,29 +22,27 @@ | |||
22 | #define arch_idle_time(cpu) 0 | 22 | #define arch_idle_time(cpu) 0 |
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | static cputime64_t get_idle_time(int cpu) | 25 | static u64 get_idle_time(int cpu) |
26 | { | 26 | { |
27 | u64 idle_time = get_cpu_idle_time_us(cpu, NULL); | 27 | u64 idle, idle_time = get_cpu_idle_time_us(cpu, NULL); |
28 | cputime64_t idle; | ||
29 | 28 | ||
30 | if (idle_time == -1ULL) { | 29 | if (idle_time == -1ULL) { |
31 | /* !NO_HZ so we can rely on cpustat.idle */ | 30 | /* !NO_HZ so we can rely on cpustat.idle */ |
32 | idle = kstat_cpu(cpu).cpustat.idle; | 31 | idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE]; |
33 | idle = cputime64_add(idle, arch_idle_time(cpu)); | 32 | idle += arch_idle_time(cpu); |
34 | } else | 33 | } else |
35 | idle = usecs_to_cputime(idle_time); | 34 | idle = usecs_to_cputime(idle_time); |
36 | 35 | ||
37 | return idle; | 36 | return idle; |
38 | } | 37 | } |
39 | 38 | ||
40 | static cputime64_t get_iowait_time(int cpu) | 39 | static u64 get_iowait_time(int cpu) |
41 | { | 40 | { |
42 | u64 iowait_time = get_cpu_iowait_time_us(cpu, NULL); | 41 | u64 iowait, iowait_time = get_cpu_iowait_time_us(cpu, NULL); |
43 | cputime64_t iowait; | ||
44 | 42 | ||
45 | if (iowait_time == -1ULL) | 43 | if (iowait_time == -1ULL) |
46 | /* !NO_HZ so we can rely on cpustat.iowait */ | 44 | /* !NO_HZ so we can rely on cpustat.iowait */ |
47 | iowait = kstat_cpu(cpu).cpustat.iowait; | 45 | iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT]; |
48 | else | 46 | else |
49 | iowait = usecs_to_cputime(iowait_time); | 47 | iowait = usecs_to_cputime(iowait_time); |
50 | 48 | ||
@@ -55,33 +53,30 @@ static int show_stat(struct seq_file *p, void *v) | |||
55 | { | 53 | { |
56 | int i, j; | 54 | int i, j; |
57 | unsigned long jif; | 55 | unsigned long jif; |
58 | cputime64_t user, nice, system, idle, iowait, irq, softirq, steal; | 56 | u64 user, nice, system, idle, iowait, irq, softirq, steal; |
59 | cputime64_t guest, guest_nice; | 57 | u64 guest, guest_nice; |
60 | u64 sum = 0; | 58 | u64 sum = 0; |
61 | u64 sum_softirq = 0; | 59 | u64 sum_softirq = 0; |
62 | unsigned int per_softirq_sums[NR_SOFTIRQS] = {0}; | 60 | unsigned int per_softirq_sums[NR_SOFTIRQS] = {0}; |
63 | struct timespec boottime; | 61 | struct timespec boottime; |
64 | 62 | ||
65 | user = nice = system = idle = iowait = | 63 | user = nice = system = idle = iowait = |
66 | irq = softirq = steal = cputime64_zero; | 64 | irq = softirq = steal = 0; |
67 | guest = guest_nice = cputime64_zero; | 65 | guest = guest_nice = 0; |
68 | getboottime(&boottime); | 66 | getboottime(&boottime); |
69 | jif = boottime.tv_sec; | 67 | jif = boottime.tv_sec; |
70 | 68 | ||
71 | for_each_possible_cpu(i) { | 69 | for_each_possible_cpu(i) { |
72 | user = cputime64_add(user, kstat_cpu(i).cpustat.user); | 70 | user += kcpustat_cpu(i).cpustat[CPUTIME_USER]; |
73 | nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice); | 71 | nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE]; |
74 | system = cputime64_add(system, kstat_cpu(i).cpustat.system); | 72 | system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM]; |
75 | idle = cputime64_add(idle, get_idle_time(i)); | 73 | idle += get_idle_time(i); |
76 | iowait = cputime64_add(iowait, get_iowait_time(i)); | 74 | iowait += get_iowait_time(i); |
77 | irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq); | 75 | irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ]; |
78 | softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq); | 76 | softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ]; |
79 | steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal); | 77 | steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL]; |
80 | guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest); | 78 | guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST]; |
81 | guest_nice = cputime64_add(guest_nice, | 79 | guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE]; |
82 | kstat_cpu(i).cpustat.guest_nice); | ||
83 | sum += kstat_cpu_irqs_sum(i); | ||
84 | sum += arch_irq_stat_cpu(i); | ||
85 | 80 | ||
86 | for (j = 0; j < NR_SOFTIRQS; j++) { | 81 | for (j = 0; j < NR_SOFTIRQS; j++) { |
87 | unsigned int softirq_stat = kstat_softirqs_cpu(j, i); | 82 | unsigned int softirq_stat = kstat_softirqs_cpu(j, i); |
@@ -106,16 +101,16 @@ static int show_stat(struct seq_file *p, void *v) | |||
106 | (unsigned long long)cputime64_to_clock_t(guest_nice)); | 101 | (unsigned long long)cputime64_to_clock_t(guest_nice)); |
107 | for_each_online_cpu(i) { | 102 | for_each_online_cpu(i) { |
108 | /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ | 103 | /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ |
109 | user = kstat_cpu(i).cpustat.user; | 104 | user = kcpustat_cpu(i).cpustat[CPUTIME_USER]; |
110 | nice = kstat_cpu(i).cpustat.nice; | 105 | nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE]; |
111 | system = kstat_cpu(i).cpustat.system; | 106 | system = kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM]; |
112 | idle = get_idle_time(i); | 107 | idle = get_idle_time(i); |
113 | iowait = get_iowait_time(i); | 108 | iowait = get_iowait_time(i); |
114 | irq = kstat_cpu(i).cpustat.irq; | 109 | irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ]; |
115 | softirq = kstat_cpu(i).cpustat.softirq; | 110 | softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ]; |
116 | steal = kstat_cpu(i).cpustat.steal; | 111 | steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL]; |
117 | guest = kstat_cpu(i).cpustat.guest; | 112 | guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST]; |
118 | guest_nice = kstat_cpu(i).cpustat.guest_nice; | 113 | guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE]; |
119 | seq_printf(p, | 114 | seq_printf(p, |
120 | "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu " | 115 | "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu " |
121 | "%llu\n", | 116 | "%llu\n", |
diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c index 766b1d456050..0fb22e464e72 100644 --- a/fs/proc/uptime.c +++ b/fs/proc/uptime.c | |||
@@ -12,10 +12,10 @@ static int uptime_proc_show(struct seq_file *m, void *v) | |||
12 | struct timespec uptime; | 12 | struct timespec uptime; |
13 | struct timespec idle; | 13 | struct timespec idle; |
14 | int i; | 14 | int i; |
15 | cputime_t idletime = cputime_zero; | 15 | u64 idletime = 0; |
16 | 16 | ||
17 | for_each_possible_cpu(i) | 17 | for_each_possible_cpu(i) |
18 | idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle); | 18 | idletime += kcpustat_cpu(i).cpustat[CPUTIME_IDLE]; |
19 | 19 | ||
20 | do_posix_clock_monotonic_gettime(&uptime); | 20 | do_posix_clock_monotonic_gettime(&uptime); |
21 | monotonic_to_bootbased(&uptime); | 21 | monotonic_to_bootbased(&uptime); |