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 @@
static inline void update_timer_sys(void)
{
get_lowcore()->system_timer += get_lowcore()->last_update_timer - get_lowcore()->exit_timer;
get_lowcore()->user_timer += get_lowcore()->exit_timer - get_lowcore()->sys_enter_timer;
get_lowcore()->last_update_timer = get_lowcore()->sys_enter_timer;
struct lowcore *lc = get_lowcore();
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)
{
get_lowcore()->system_timer += get_lowcore()->last_update_timer - get_lowcore()->exit_timer;
get_lowcore()->user_timer += get_lowcore()->exit_timer - get_lowcore()->mcck_enter_timer;
get_lowcore()->last_update_timer = get_lowcore()->mcck_enter_timer;
struct lowcore *lc = get_lowcore();
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 */
......@@ -35,14 +35,15 @@ static DEFINE_PER_CPU(u64, mt_scaling_jiffies);
static inline void set_vtimer(u64 expires)
{
struct lowcore *lc = get_lowcore();
u64 timer;
asm volatile(
" stpt %0\n" /* Store current cpu timer value */
" spt %1" /* Set new value imm. afterwards */
: "=Q" (timer) : "Q" (expires));
get_lowcore()->system_timer += get_lowcore()->last_update_timer - timer;
get_lowcore()->last_update_timer = expires;
lc->system_timer += lc->last_update_timer - timer;
lc->last_update_timer = expires;
}
static inline int virt_timer_forward(u64 elapsed)
......@@ -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)
{
u64 timer, clock, user, guest, system, hardirq, softirq;
struct lowcore *lc = get_lowcore();
timer = get_lowcore()->last_update_timer;
clock = get_lowcore()->last_update_clock;
timer = lc->last_update_timer;
clock = lc->last_update_clock;
asm volatile(
" stpt %0\n" /* Store current cpu timer value */
" stckf %1" /* Store current tod clock value */
: "=Q" (get_lowcore()->last_update_timer),
"=Q" (get_lowcore()->last_update_clock)
: "=Q" (lc->last_update_timer),
"=Q" (lc->last_update_clock)
: : "cc");
clock = get_lowcore()->last_update_clock - clock;
timer -= get_lowcore()->last_update_timer;
clock = lc->last_update_clock - clock;
timer -= lc->last_update_timer;
if (hardirq_count())
get_lowcore()->hardirq_timer += timer;
lc->hardirq_timer += timer;
else
get_lowcore()->system_timer += timer;
lc->system_timer += timer;
/* Update MT utilization calculation */
if (smp_cpu_mtid &&
......@@ -141,16 +143,16 @@ static int do_account_vtime(struct task_struct *tsk)
/* Calculate cputime delta */
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,
READ_ONCE(get_lowcore()->guest_timer));
READ_ONCE(lc->guest_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,
READ_ONCE(get_lowcore()->hardirq_timer));
READ_ONCE(lc->hardirq_timer));
softirq = update_tsk_timer(&tsk->thread.softirq_timer,
READ_ONCE(get_lowcore()->softirq_timer));
get_lowcore()->steal_timer +=
READ_ONCE(lc->softirq_timer));
lc->steal_timer +=
clock - user - guest - system - hardirq - softirq;
/* Push account value */
......@@ -176,17 +178,19 @@ static int do_account_vtime(struct task_struct *tsk)
void vtime_task_switch(struct task_struct *prev)
{
struct lowcore *lc = get_lowcore();
do_account_vtime(prev);
prev->thread.user_timer = get_lowcore()->user_timer;
prev->thread.guest_timer = get_lowcore()->guest_timer;
prev->thread.system_timer = get_lowcore()->system_timer;
prev->thread.hardirq_timer = get_lowcore()->hardirq_timer;
prev->thread.softirq_timer = get_lowcore()->softirq_timer;
get_lowcore()->user_timer = current->thread.user_timer;
get_lowcore()->guest_timer = current->thread.guest_timer;
get_lowcore()->system_timer = current->thread.system_timer;
get_lowcore()->hardirq_timer = current->thread.hardirq_timer;
get_lowcore()->softirq_timer = current->thread.softirq_timer;
prev->thread.user_timer = lc->user_timer;
prev->thread.guest_timer = lc->guest_timer;
prev->thread.system_timer = lc->system_timer;
prev->thread.hardirq_timer = lc->hardirq_timer;
prev->thread.softirq_timer = lc->softirq_timer;
lc->user_timer = current->thread.user_timer;
lc->guest_timer = current->thread.guest_timer;
lc->system_timer = current->thread.system_timer;
lc->hardirq_timer = current->thread.hardirq_timer;
lc->softirq_timer = current->thread.softirq_timer;
}
/*
......@@ -196,28 +200,29 @@ void vtime_task_switch(struct task_struct *prev)
*/
void vtime_flush(struct task_struct *tsk)
{
struct lowcore *lc = get_lowcore();
u64 steal, avg_steal;
if (do_account_vtime(tsk))
virt_timer_expire();
steal = get_lowcore()->steal_timer;
avg_steal = get_lowcore()->avg_steal_timer;
steal = lc->steal_timer;
avg_steal = lc->avg_steal_timer;
if ((s64) steal > 0) {
get_lowcore()->steal_timer = 0;
lc->steal_timer = 0;
account_steal_time(cputime_to_nsecs(steal));
avg_steal += steal;
}
get_lowcore()->avg_steal_timer = avg_steal / 2;
lc->avg_steal_timer = avg_steal / 2;
}
static u64 vtime_delta(void)
{
u64 timer = get_lowcore()->last_update_timer;
get_lowcore()->last_update_timer = get_cpu_timer();
struct lowcore *lc = get_lowcore();
u64 timer = lc->last_update_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)
*/
void vtime_account_kernel(struct task_struct *tsk)
{
struct lowcore *lc = get_lowcore();
u64 delta = vtime_delta();
if (tsk->flags & PF_VCPU)
get_lowcore()->guest_timer += delta;
lc->guest_timer += delta;
else
get_lowcore()->system_timer += delta;
lc->system_timer += 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