Messages in this thread Patch in this message | | | From | Denys Vlasenko <> | Subject | [PATCH 2/2] nohz: don't fetch per_cpu variable before we need it | Date | Fri, 25 Apr 2014 20:57:30 +0200 |
| |
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 <dvlasenk@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> Cc: Fernando Luis Vazquez Cao <fernando_b1@lab.ntt.co.jp> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Oleg Nesterov <oleg@redhat.com> --- 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
| |