Commit 46c30311 authored by Sven Schnelle's avatar Sven Schnelle Committed by Vasily Gorbik

s390/vtime: Remove duplicate get_lowcore() calls

Assign the output from get_lowcore() to a local variable,
so the code is easier to read.
Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent eb28ec2b
...@@ -4,16 +4,20 @@ ...@@ -4,16 +4,20 @@
static inline void update_timer_sys(void) static inline void update_timer_sys(void)
{ {
get_lowcore()->system_timer += get_lowcore()->last_update_timer - get_lowcore()->exit_timer; struct lowcore *lc = get_lowcore();
get_lowcore()->user_timer += get_lowcore()->exit_timer - get_lowcore()->sys_enter_timer;
get_lowcore()->last_update_timer = get_lowcore()->sys_enter_timer; lc->system_timer += lc->last_update_timer - lc->exit_timer;
lc->user_timer += lc->exit_timer - lc->sys_enter_timer;
lc->last_update_timer = lc->sys_enter_timer;
} }
static inline void update_timer_mcck(void) static inline void update_timer_mcck(void)
{ {
get_lowcore()->system_timer += get_lowcore()->last_update_timer - get_lowcore()->exit_timer; struct lowcore *lc = get_lowcore();
get_lowcore()->user_timer += get_lowcore()->exit_timer - get_lowcore()->mcck_enter_timer;
get_lowcore()->last_update_timer = get_lowcore()->mcck_enter_timer; lc->system_timer += lc->last_update_timer - lc->exit_timer;
lc->user_timer += lc->exit_timer - lc->mcck_enter_timer;
lc->last_update_timer = lc->mcck_enter_timer;
} }
#endif /* _S390_VTIME_H */ #endif /* _S390_VTIME_H */
...@@ -35,14 +35,15 @@ static DEFINE_PER_CPU(u64, mt_scaling_jiffies); ...@@ -35,14 +35,15 @@ static DEFINE_PER_CPU(u64, mt_scaling_jiffies);
static inline void set_vtimer(u64 expires) static inline void set_vtimer(u64 expires)
{ {
struct lowcore *lc = get_lowcore();
u64 timer; u64 timer;
asm volatile( asm volatile(
" stpt %0\n" /* Store current cpu timer value */ " stpt %0\n" /* Store current cpu timer value */
" spt %1" /* Set new value imm. afterwards */ " spt %1" /* Set new value imm. afterwards */
: "=Q" (timer) : "Q" (expires)); : "=Q" (timer) : "Q" (expires));
get_lowcore()->system_timer += get_lowcore()->last_update_timer - timer; lc->system_timer += lc->last_update_timer - timer;
get_lowcore()->last_update_timer = expires; lc->last_update_timer = expires;
} }
static inline int virt_timer_forward(u64 elapsed) 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,22 +118,23 @@ static void account_system_index_scaled(struct task_struct *p, u64 cputime,
static int do_account_vtime(struct task_struct *tsk) static int do_account_vtime(struct task_struct *tsk)
{ {
u64 timer, clock, user, guest, system, hardirq, softirq; u64 timer, clock, user, guest, system, hardirq, softirq;
struct lowcore *lc = get_lowcore();
timer = get_lowcore()->last_update_timer; timer = lc->last_update_timer;
clock = get_lowcore()->last_update_clock; clock = lc->last_update_clock;
asm volatile( asm volatile(
" stpt %0\n" /* Store current cpu timer value */ " stpt %0\n" /* Store current cpu timer value */
" stckf %1" /* Store current tod clock value */ " stckf %1" /* Store current tod clock value */
: "=Q" (get_lowcore()->last_update_timer), : "=Q" (lc->last_update_timer),
"=Q" (get_lowcore()->last_update_clock) "=Q" (lc->last_update_clock)
: : "cc"); : : "cc");
clock = get_lowcore()->last_update_clock - clock; clock = lc->last_update_clock - clock;
timer -= get_lowcore()->last_update_timer; timer -= lc->last_update_timer;
if (hardirq_count()) if (hardirq_count())
get_lowcore()->hardirq_timer += timer; lc->hardirq_timer += timer;
else else
get_lowcore()->system_timer += timer; lc->system_timer += timer;
/* Update MT utilization calculation */ /* Update MT utilization calculation */
if (smp_cpu_mtid && if (smp_cpu_mtid &&
...@@ -141,16 +143,16 @@ static int do_account_vtime(struct task_struct *tsk) ...@@ -141,16 +143,16 @@ static int do_account_vtime(struct task_struct *tsk)
/* Calculate cputime delta */ /* Calculate cputime delta */
user = update_tsk_timer(&tsk->thread.user_timer, user = update_tsk_timer(&tsk->thread.user_timer,
READ_ONCE(get_lowcore()->user_timer)); READ_ONCE(lc->user_timer));
guest = update_tsk_timer(&tsk->thread.guest_timer, guest = update_tsk_timer(&tsk->thread.guest_timer,
READ_ONCE(get_lowcore()->guest_timer)); READ_ONCE(lc->guest_timer));
system = update_tsk_timer(&tsk->thread.system_timer, system = update_tsk_timer(&tsk->thread.system_timer,
READ_ONCE(get_lowcore()->system_timer)); READ_ONCE(lc->system_timer));
hardirq = update_tsk_timer(&tsk->thread.hardirq_timer, hardirq = update_tsk_timer(&tsk->thread.hardirq_timer,
READ_ONCE(get_lowcore()->hardirq_timer)); READ_ONCE(lc->hardirq_timer));
softirq = update_tsk_timer(&tsk->thread.softirq_timer, softirq = update_tsk_timer(&tsk->thread.softirq_timer,
READ_ONCE(get_lowcore()->softirq_timer)); READ_ONCE(lc->softirq_timer));
get_lowcore()->steal_timer += lc->steal_timer +=
clock - user - guest - system - hardirq - softirq; clock - user - guest - system - hardirq - softirq;
/* Push account value */ /* Push account value */
...@@ -176,17 +178,19 @@ static int do_account_vtime(struct task_struct *tsk) ...@@ -176,17 +178,19 @@ static int do_account_vtime(struct task_struct *tsk)
void vtime_task_switch(struct task_struct *prev) void vtime_task_switch(struct task_struct *prev)
{ {
struct lowcore *lc = get_lowcore();
do_account_vtime(prev); do_account_vtime(prev);
prev->thread.user_timer = get_lowcore()->user_timer; prev->thread.user_timer = lc->user_timer;
prev->thread.guest_timer = get_lowcore()->guest_timer; prev->thread.guest_timer = lc->guest_timer;
prev->thread.system_timer = get_lowcore()->system_timer; prev->thread.system_timer = lc->system_timer;
prev->thread.hardirq_timer = get_lowcore()->hardirq_timer; prev->thread.hardirq_timer = lc->hardirq_timer;
prev->thread.softirq_timer = get_lowcore()->softirq_timer; prev->thread.softirq_timer = lc->softirq_timer;
get_lowcore()->user_timer = current->thread.user_timer; lc->user_timer = current->thread.user_timer;
get_lowcore()->guest_timer = current->thread.guest_timer; lc->guest_timer = current->thread.guest_timer;
get_lowcore()->system_timer = current->thread.system_timer; lc->system_timer = current->thread.system_timer;
get_lowcore()->hardirq_timer = current->thread.hardirq_timer; lc->hardirq_timer = current->thread.hardirq_timer;
get_lowcore()->softirq_timer = current->thread.softirq_timer; lc->softirq_timer = current->thread.softirq_timer;
} }
/* /*
...@@ -196,28 +200,29 @@ void vtime_task_switch(struct task_struct *prev) ...@@ -196,28 +200,29 @@ void vtime_task_switch(struct task_struct *prev)
*/ */
void vtime_flush(struct task_struct *tsk) void vtime_flush(struct task_struct *tsk)
{ {
struct lowcore *lc = get_lowcore();
u64 steal, avg_steal; u64 steal, avg_steal;
if (do_account_vtime(tsk)) if (do_account_vtime(tsk))
virt_timer_expire(); virt_timer_expire();
steal = get_lowcore()->steal_timer; steal = lc->steal_timer;
avg_steal = get_lowcore()->avg_steal_timer; avg_steal = lc->avg_steal_timer;
if ((s64) steal > 0) { if ((s64) steal > 0) {
get_lowcore()->steal_timer = 0; lc->steal_timer = 0;
account_steal_time(cputime_to_nsecs(steal)); account_steal_time(cputime_to_nsecs(steal));
avg_steal += steal; avg_steal += steal;
} }
get_lowcore()->avg_steal_timer = avg_steal / 2; lc->avg_steal_timer = avg_steal / 2;
} }
static u64 vtime_delta(void) static u64 vtime_delta(void)
{ {
u64 timer = get_lowcore()->last_update_timer; struct lowcore *lc = get_lowcore();
u64 timer = lc->last_update_timer;
get_lowcore()->last_update_timer = get_cpu_timer();
return timer - get_lowcore()->last_update_timer; lc->last_update_timer = get_cpu_timer();
return timer - lc->last_update_timer;
} }
/* /*
...@@ -226,12 +231,13 @@ static u64 vtime_delta(void) ...@@ -226,12 +231,13 @@ static u64 vtime_delta(void)
*/ */
void vtime_account_kernel(struct task_struct *tsk) void vtime_account_kernel(struct task_struct *tsk)
{ {
struct lowcore *lc = get_lowcore();
u64 delta = vtime_delta(); u64 delta = vtime_delta();
if (tsk->flags & PF_VCPU) if (tsk->flags & PF_VCPU)
get_lowcore()->guest_timer += delta; lc->guest_timer += delta;
else else
get_lowcore()->system_timer += delta; lc->system_timer += delta;
virt_timer_forward(delta); virt_timer_forward(delta);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment