@@ -35,14 +35,15 @@ static DEFINE_PER_CPU(u64, mt_scaling_jiffies);
35
35
36
36
static inline void set_vtimer (u64 expires )
37
37
{
38
+ struct lowcore * lc = get_lowcore ();
38
39
u64 timer ;
39
40
40
41
asm volatile (
41
42
" stpt %0\n" /* Store current cpu timer value */
42
43
" spt %1" /* Set new value imm. afterwards */
43
44
: "=Q" (timer ) : "Q" (expires ));
44
- get_lowcore () -> system_timer += get_lowcore () -> last_update_timer - timer ;
45
- get_lowcore () -> last_update_timer = expires ;
45
+ lc -> system_timer += lc -> last_update_timer - timer ;
46
+ lc -> last_update_timer = expires ;
46
47
}
47
48
48
49
static inline int virt_timer_forward (u64 elapsed )
@@ -117,22 +118,23 @@ static void account_system_index_scaled(struct task_struct *p, u64 cputime,
117
118
static int do_account_vtime (struct task_struct * tsk )
118
119
{
119
120
u64 timer , clock , user , guest , system , hardirq , softirq ;
121
+ struct lowcore * lc = get_lowcore ();
120
122
121
- timer = get_lowcore () -> last_update_timer ;
122
- clock = get_lowcore () -> last_update_clock ;
123
+ timer = lc -> last_update_timer ;
124
+ clock = lc -> last_update_clock ;
123
125
asm volatile (
124
126
" stpt %0\n" /* Store current cpu timer value */
125
127
" stckf %1" /* Store current tod clock value */
126
- : "=Q" (get_lowcore () -> last_update_timer ),
127
- "=Q" (get_lowcore () -> last_update_clock )
128
+ : "=Q" (lc -> last_update_timer ),
129
+ "=Q" (lc -> last_update_clock )
128
130
: : "cc" );
129
- clock = get_lowcore () -> last_update_clock - clock ;
130
- timer -= get_lowcore () -> last_update_timer ;
131
+ clock = lc -> last_update_clock - clock ;
132
+ timer -= lc -> last_update_timer ;
131
133
132
134
if (hardirq_count ())
133
- get_lowcore () -> hardirq_timer += timer ;
135
+ lc -> hardirq_timer += timer ;
134
136
else
135
- get_lowcore () -> system_timer += timer ;
137
+ lc -> system_timer += timer ;
136
138
137
139
/* Update MT utilization calculation */
138
140
if (smp_cpu_mtid &&
@@ -141,16 +143,16 @@ static int do_account_vtime(struct task_struct *tsk)
141
143
142
144
/* Calculate cputime delta */
143
145
user = update_tsk_timer (& tsk -> thread .user_timer ,
144
- READ_ONCE (get_lowcore () -> user_timer ));
146
+ READ_ONCE (lc -> user_timer ));
145
147
guest = update_tsk_timer (& tsk -> thread .guest_timer ,
146
- READ_ONCE (get_lowcore () -> guest_timer ));
148
+ READ_ONCE (lc -> guest_timer ));
147
149
system = update_tsk_timer (& tsk -> thread .system_timer ,
148
- READ_ONCE (get_lowcore () -> system_timer ));
150
+ READ_ONCE (lc -> system_timer ));
149
151
hardirq = update_tsk_timer (& tsk -> thread .hardirq_timer ,
150
- READ_ONCE (get_lowcore () -> hardirq_timer ));
152
+ READ_ONCE (lc -> hardirq_timer ));
151
153
softirq = update_tsk_timer (& tsk -> thread .softirq_timer ,
152
- READ_ONCE (get_lowcore () -> softirq_timer ));
153
- get_lowcore () -> steal_timer +=
154
+ READ_ONCE (lc -> softirq_timer ));
155
+ lc -> steal_timer +=
154
156
clock - user - guest - system - hardirq - softirq ;
155
157
156
158
/* Push account value */
@@ -176,17 +178,19 @@ static int do_account_vtime(struct task_struct *tsk)
176
178
177
179
void vtime_task_switch (struct task_struct * prev )
178
180
{
181
+ struct lowcore * lc = get_lowcore ();
182
+
179
183
do_account_vtime (prev );
180
- prev -> thread .user_timer = get_lowcore () -> user_timer ;
181
- prev -> thread .guest_timer = get_lowcore () -> guest_timer ;
182
- prev -> thread .system_timer = get_lowcore () -> system_timer ;
183
- prev -> thread .hardirq_timer = get_lowcore () -> hardirq_timer ;
184
- prev -> thread .softirq_timer = get_lowcore () -> softirq_timer ;
185
- get_lowcore () -> user_timer = current -> thread .user_timer ;
186
- get_lowcore () -> guest_timer = current -> thread .guest_timer ;
187
- get_lowcore () -> system_timer = current -> thread .system_timer ;
188
- get_lowcore () -> hardirq_timer = current -> thread .hardirq_timer ;
189
- get_lowcore () -> softirq_timer = current -> thread .softirq_timer ;
184
+ prev -> thread .user_timer = lc -> user_timer ;
185
+ prev -> thread .guest_timer = lc -> guest_timer ;
186
+ prev -> thread .system_timer = lc -> system_timer ;
187
+ prev -> thread .hardirq_timer = lc -> hardirq_timer ;
188
+ prev -> thread .softirq_timer = lc -> softirq_timer ;
189
+ lc -> user_timer = current -> thread .user_timer ;
190
+ lc -> guest_timer = current -> thread .guest_timer ;
191
+ lc -> system_timer = current -> thread .system_timer ;
192
+ lc -> hardirq_timer = current -> thread .hardirq_timer ;
193
+ lc -> softirq_timer = current -> thread .softirq_timer ;
190
194
}
191
195
192
196
/*
@@ -196,28 +200,29 @@ void vtime_task_switch(struct task_struct *prev)
196
200
*/
197
201
void vtime_flush (struct task_struct * tsk )
198
202
{
203
+ struct lowcore * lc = get_lowcore ();
199
204
u64 steal , avg_steal ;
200
205
201
206
if (do_account_vtime (tsk ))
202
207
virt_timer_expire ();
203
208
204
- steal = get_lowcore () -> steal_timer ;
205
- avg_steal = get_lowcore () -> avg_steal_timer ;
209
+ steal = lc -> steal_timer ;
210
+ avg_steal = lc -> avg_steal_timer ;
206
211
if ((s64 ) steal > 0 ) {
207
- get_lowcore () -> steal_timer = 0 ;
212
+ lc -> steal_timer = 0 ;
208
213
account_steal_time (cputime_to_nsecs (steal ));
209
214
avg_steal += steal ;
210
215
}
211
- get_lowcore () -> avg_steal_timer = avg_steal / 2 ;
216
+ lc -> avg_steal_timer = avg_steal / 2 ;
212
217
}
213
218
214
219
static u64 vtime_delta (void )
215
220
{
216
- u64 timer = get_lowcore ()-> last_update_timer ;
217
-
218
- get_lowcore ()-> last_update_timer = get_cpu_timer ();
221
+ struct lowcore * lc = get_lowcore ();
222
+ u64 timer = lc -> last_update_timer ;
219
223
220
- return timer - get_lowcore ()-> last_update_timer ;
224
+ lc -> last_update_timer = get_cpu_timer ();
225
+ return timer - lc -> last_update_timer ;
221
226
}
222
227
223
228
/*
@@ -226,12 +231,13 @@ static u64 vtime_delta(void)
226
231
*/
227
232
void vtime_account_kernel (struct task_struct * tsk )
228
233
{
234
+ struct lowcore * lc = get_lowcore ();
229
235
u64 delta = vtime_delta ();
230
236
231
237
if (tsk -> flags & PF_VCPU )
232
- get_lowcore () -> guest_timer += delta ;
238
+ lc -> guest_timer += delta ;
233
239
else
234
- get_lowcore () -> system_timer += delta ;
240
+ lc -> system_timer += delta ;
235
241
236
242
virt_timer_forward (delta );
237
243
}
0 commit comments