]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/vtime: Remove duplicate get_lowcore() calls
authorSven Schnelle <svens@linux.ibm.com>
Mon, 10 Jun 2024 11:45:30 +0000 (13:45 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 18 Jun 2024 15:01:33 +0000 (17:01 +0200)
Assign the output from get_lowcore() to a local variable,
so the code is easier to read.

Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/vtime.h
arch/s390/kernel/vtime.c

index ef4dd7d057a29c37a20f1e5af2e64b9ee3e12dd0..9d25fb35a042703b8d67dfe179f8ac495fcde8ae 100644 (file)
@@ -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 */
index 7d8991c3cd3a0e4779061ff0e313d61991388481..234a0ba3051082b60986929864f5475a959b0f67 100644 (file)
@@ -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);
 }