In get_cpu_{idle,iowait}_time_us, we were fetching
per_cpu(tick_cpu_sched, cpu) upfront. But them we do
        if (!tick_nohz_active)
                return -1;
which may make that fetch pointless.
Moving it further down, closer to the usage point.

Signed-off-by: Denys Vlasenko <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Hidetoshi Seto <[email protected]>
Cc: Fernando Luis Vazquez Cao <[email protected]>
Cc: Tetsuo Handa <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Cc: Oleg Nesterov <[email protected]>
---
 kernel/time/tick-sched.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index d78c942..4ffccd0 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -476,7 +476,7 @@ void tick_nohz_iowait_to_idle(int cpu)
  */
 u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
 {
-       struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
+       struct tick_sched *ts;
        ktime_t now, idle;
        unsigned int seq;
 
@@ -487,6 +487,8 @@ u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
        if (last_update_time)
                *last_update_time = ktime_to_us(now);
 
+       ts = &per_cpu(tick_cpu_sched, cpu);
+
        do {
                ktime_t start, delta, iowait_exit;
 
@@ -531,7 +533,7 @@ EXPORT_SYMBOL_GPL(get_cpu_idle_time_us);
  */
 u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
 {
-       struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
+       struct tick_sched *ts;
        ktime_t now, iowait;
        unsigned int seq;
 
@@ -542,6 +544,8 @@ u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
        if (last_update_time)
                *last_update_time = ktime_to_us(now);
 
+       ts = &per_cpu(tick_cpu_sched, cpu);
+
        do {
                ktime_t delta, end;
 
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to