23
23
24
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
28
u64 idle ;
29
29
30
- idle = kcpustat_cpu ( cpu ). cpustat [CPUTIME_IDLE ];
30
+ idle = kcs -> cpustat [CPUTIME_IDLE ];
31
31
if (cpu_online (cpu ) && !nr_iowait_cpu (cpu ))
32
32
idle += arch_idle_time (cpu );
33
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
38
u64 iowait ;
39
39
40
- iowait = kcpustat_cpu ( cpu ). cpustat [CPUTIME_IOWAIT ];
40
+ iowait = kcs -> cpustat [CPUTIME_IOWAIT ];
41
41
if (cpu_online (cpu ) && nr_iowait_cpu (cpu ))
42
42
iowait += arch_idle_time (cpu );
43
43
return iowait ;
44
44
}
45
45
46
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
50
u64 idle , idle_usecs = -1ULL ;
51
51
@@ -54,14 +54,14 @@ static u64 get_idle_time(int cpu)
54
54
55
55
if (idle_usecs == -1ULL )
56
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
58
else
59
59
idle = idle_usecs * NSEC_PER_USEC ;
60
60
61
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
66
u64 iowait , iowait_usecs = -1ULL ;
67
67
@@ -70,7 +70,7 @@ static u64 get_iowait_time(int cpu)
70
70
71
71
if (iowait_usecs == -1ULL )
72
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
74
else
75
75
iowait = iowait_usecs * NSEC_PER_USEC ;
76
76
@@ -95,16 +95,18 @@ static int show_stat(struct seq_file *p, void *v)
95
95
getboottime64 (& boottime );
96
96
97
97
for_each_possible_cpu (i ) {
98
- user += kcpustat_cpu (i ).cpustat [CPUTIME_USER ];
99
- nice += kcpustat_cpu (i ).cpustat [CPUTIME_NICE ];
100
- system += kcpustat_cpu (i ).cpustat [CPUTIME_SYSTEM ];
101
- idle += get_idle_time (i );
102
- iowait += get_iowait_time (i );
103
- irq += kcpustat_cpu (i ).cpustat [CPUTIME_IRQ ];
104
- softirq += kcpustat_cpu (i ).cpustat [CPUTIME_SOFTIRQ ];
105
- steal += kcpustat_cpu (i ).cpustat [CPUTIME_STEAL ];
106
- guest += kcpustat_cpu (i ).cpustat [CPUTIME_GUEST ];
107
- guest_nice += kcpustat_cpu (i ).cpustat [CPUTIME_GUEST_NICE ];
98
+ struct kernel_cpustat * kcs = & kcpustat_cpu (i );
99
+
100
+ user += kcs -> cpustat [CPUTIME_USER ];
101
+ nice += kcs -> cpustat [CPUTIME_NICE ];
102
+ system += kcs -> cpustat [CPUTIME_SYSTEM ];
103
+ idle += get_idle_time (kcs , i );
104
+ iowait += get_iowait_time (kcs , i );
105
+ irq += kcs -> cpustat [CPUTIME_IRQ ];
106
+ softirq += kcs -> cpustat [CPUTIME_SOFTIRQ ];
107
+ steal += kcs -> cpustat [CPUTIME_STEAL ];
108
+ guest += kcs -> cpustat [CPUTIME_GUEST ];
109
+ guest_nice += kcs -> cpustat [CPUTIME_GUEST_NICE ];
108
110
sum += kstat_cpu_irqs_sum (i );
109
111
sum += arch_irq_stat_cpu (i );
110
112
@@ -130,17 +132,19 @@ static int show_stat(struct seq_file *p, void *v)
130
132
seq_putc (p , '\n' );
131
133
132
134
for_each_online_cpu (i ) {
135
+ struct kernel_cpustat * kcs = & kcpustat_cpu (i );
136
+
133
137
/* Copy values here to work around gcc-2.95.3, gcc-2.96 */
134
- user = kcpustat_cpu ( i ). cpustat [CPUTIME_USER ];
135
- nice = kcpustat_cpu ( i ). cpustat [CPUTIME_NICE ];
136
- system = kcpustat_cpu ( i ). cpustat [CPUTIME_SYSTEM ];
137
- idle = get_idle_time (i );
138
- iowait = get_iowait_time (i );
139
- irq = kcpustat_cpu ( i ). cpustat [CPUTIME_IRQ ];
140
- softirq = kcpustat_cpu ( i ). cpustat [CPUTIME_SOFTIRQ ];
141
- steal = kcpustat_cpu ( i ). cpustat [CPUTIME_STEAL ];
142
- guest = kcpustat_cpu ( i ). cpustat [CPUTIME_GUEST ];
143
- guest_nice = kcpustat_cpu ( i ). cpustat [CPUTIME_GUEST_NICE ];
138
+ user = kcs -> cpustat [CPUTIME_USER ];
139
+ nice = kcs -> cpustat [CPUTIME_NICE ];
140
+ system = kcs -> cpustat [CPUTIME_SYSTEM ];
141
+ idle = get_idle_time (kcs , i );
142
+ iowait = get_iowait_time (kcs , i );
143
+ irq = kcs -> cpustat [CPUTIME_IRQ ];
144
+ softirq = kcs -> cpustat [CPUTIME_SOFTIRQ ];
145
+ steal = kcs -> cpustat [CPUTIME_STEAL ];
146
+ guest = kcs -> cpustat [CPUTIME_GUEST ];
147
+ guest_nice = kcs -> cpustat [CPUTIME_GUEST_NICE ];
144
148
seq_printf (p , "cpu%d" , i );
145
149
seq_put_decimal_ull (p , " " , nsec_to_clock_t (user ));
146
150
seq_put_decimal_ull (p , " " , nsec_to_clock_t (nice ));
0 commit comments