diff options
Diffstat (limited to 'fs/proc/stat.c')
-rw-r--r-- | fs/proc/stat.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 76175211b304..80c305f206bb 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c | |||
@@ -23,21 +23,21 @@ | |||
23 | 23 | ||
24 | #ifdef arch_idle_time | 24 | #ifdef arch_idle_time |
25 | 25 | ||
26 | static u64 get_idle_time(int cpu) | 26 | static u64 get_idle_time(struct kernel_cpustat *kcs, int cpu) |
27 | { | 27 | { |
28 | u64 idle; | 28 | u64 idle; |
29 | 29 | ||
30 | idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE]; | 30 | idle = kcs->cpustat[CPUTIME_IDLE]; |
31 | if (cpu_online(cpu) && !nr_iowait_cpu(cpu)) | 31 | if (cpu_online(cpu) && !nr_iowait_cpu(cpu)) |
32 | idle += arch_idle_time(cpu); | 32 | idle += arch_idle_time(cpu); |
33 | return idle; | 33 | return idle; |
34 | } | 34 | } |
35 | 35 | ||
36 | static u64 get_iowait_time(int cpu) | 36 | static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu) |
37 | { | 37 | { |
38 | u64 iowait; | 38 | u64 iowait; |
39 | 39 | ||
40 | iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT]; | 40 | iowait = kcs->cpustat[CPUTIME_IOWAIT]; |
41 | if (cpu_online(cpu) && nr_iowait_cpu(cpu)) | 41 | if (cpu_online(cpu) && nr_iowait_cpu(cpu)) |
42 | iowait += arch_idle_time(cpu); | 42 | iowait += arch_idle_time(cpu); |
43 | return iowait; | 43 | return iowait; |
@@ -45,7 +45,7 @@ static u64 get_iowait_time(int cpu) | |||
45 | 45 | ||
46 | #else | 46 | #else |
47 | 47 | ||
48 | static u64 get_idle_time(int cpu) | 48 | static u64 get_idle_time(struct kernel_cpustat *kcs, int cpu) |
49 | { | 49 | { |
50 | u64 idle, idle_usecs = -1ULL; | 50 | u64 idle, idle_usecs = -1ULL; |
51 | 51 | ||
@@ -54,14 +54,14 @@ static u64 get_idle_time(int cpu) | |||
54 | 54 | ||
55 | if (idle_usecs == -1ULL) | 55 | if (idle_usecs == -1ULL) |
56 | /* !NO_HZ or cpu offline so we can rely on cpustat.idle */ | 56 | /* !NO_HZ or cpu offline so we can rely on cpustat.idle */ |
57 | idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE]; | 57 | idle = kcs->cpustat[CPUTIME_IDLE]; |
58 | else | 58 | else |
59 | idle = idle_usecs * NSEC_PER_USEC; | 59 | idle = idle_usecs * NSEC_PER_USEC; |
60 | 60 | ||
61 | return idle; | 61 | return idle; |
62 | } | 62 | } |
63 | 63 | ||
64 | static u64 get_iowait_time(int cpu) | 64 | static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu) |
65 | { | 65 | { |
66 | u64 iowait, iowait_usecs = -1ULL; | 66 | u64 iowait, iowait_usecs = -1ULL; |
67 | 67 | ||
@@ -70,7 +70,7 @@ static u64 get_iowait_time(int cpu) | |||
70 | 70 | ||
71 | if (iowait_usecs == -1ULL) | 71 | if (iowait_usecs == -1ULL) |
72 | /* !NO_HZ or cpu offline so we can rely on cpustat.iowait */ | 72 | /* !NO_HZ or cpu offline so we can rely on cpustat.iowait */ |
73 | iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT]; | 73 | iowait = kcs->cpustat[CPUTIME_IOWAIT]; |
74 | else | 74 | else |
75 | iowait = iowait_usecs * NSEC_PER_USEC; | 75 | iowait = iowait_usecs * NSEC_PER_USEC; |
76 | 76 | ||
@@ -120,16 +120,18 @@ static int show_stat(struct seq_file *p, void *v) | |||
120 | getboottime64(&boottime); | 120 | getboottime64(&boottime); |
121 | 121 | ||
122 | for_each_possible_cpu(i) { | 122 | for_each_possible_cpu(i) { |
123 | user += kcpustat_cpu(i).cpustat[CPUTIME_USER]; | 123 | struct kernel_cpustat *kcs = &kcpustat_cpu(i); |
124 | nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE]; | 124 | |
125 | system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM]; | 125 | user += kcs->cpustat[CPUTIME_USER]; |
126 | idle += get_idle_time(i); | 126 | nice += kcs->cpustat[CPUTIME_NICE]; |
127 | iowait += get_iowait_time(i); | 127 | system += kcs->cpustat[CPUTIME_SYSTEM]; |
128 | irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ]; | 128 | idle += get_idle_time(kcs, i); |
129 | softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ]; | 129 | iowait += get_iowait_time(kcs, i); |
130 | steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL]; | 130 | irq += kcs->cpustat[CPUTIME_IRQ]; |
131 | guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST]; | 131 | softirq += kcs->cpustat[CPUTIME_SOFTIRQ]; |
132 | guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE]; | 132 | steal += kcs->cpustat[CPUTIME_STEAL]; |
133 | guest += kcs->cpustat[CPUTIME_GUEST]; | ||
134 | guest_nice += kcs->cpustat[CPUTIME_GUEST_NICE]; | ||
133 | sum += kstat_cpu_irqs_sum(i); | 135 | sum += kstat_cpu_irqs_sum(i); |
134 | sum += arch_irq_stat_cpu(i); | 136 | sum += arch_irq_stat_cpu(i); |
135 | 137 | ||
@@ -155,17 +157,19 @@ static int show_stat(struct seq_file *p, void *v) | |||
155 | seq_putc(p, '\n'); | 157 | seq_putc(p, '\n'); |
156 | 158 | ||
157 | for_each_online_cpu(i) { | 159 | for_each_online_cpu(i) { |
160 | struct kernel_cpustat *kcs = &kcpustat_cpu(i); | ||
161 | |||
158 | /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ | 162 | /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ |
159 | user = kcpustat_cpu(i).cpustat[CPUTIME_USER]; | 163 | user = kcs->cpustat[CPUTIME_USER]; |
160 | nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE]; | 164 | nice = kcs->cpustat[CPUTIME_NICE]; |
161 | system = kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM]; | 165 | system = kcs->cpustat[CPUTIME_SYSTEM]; |
162 | idle = get_idle_time(i); | 166 | idle = get_idle_time(kcs, i); |
163 | iowait = get_iowait_time(i); | 167 | iowait = get_iowait_time(kcs, i); |
164 | irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ]; | 168 | irq = kcs->cpustat[CPUTIME_IRQ]; |
165 | softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ]; | 169 | softirq = kcs->cpustat[CPUTIME_SOFTIRQ]; |
166 | steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL]; | 170 | steal = kcs->cpustat[CPUTIME_STEAL]; |
167 | guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST]; | 171 | guest = kcs->cpustat[CPUTIME_GUEST]; |
168 | guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE]; | 172 | guest_nice = kcs->cpustat[CPUTIME_GUEST_NICE]; |
169 | seq_printf(p, "cpu%d", i); | 173 | seq_printf(p, "cpu%d", i); |
170 | seq_put_decimal_ull(p, " ", nsec_to_clock_t(user)); | 174 | seq_put_decimal_ull(p, " ", nsec_to_clock_t(user)); |
171 | seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice)); | 175 | seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice)); |