Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753730AbaDYT5s (ORCPT ); Fri, 25 Apr 2014 15:57:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25666 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751876AbaDYT5o (ORCPT ); Fri, 25 Apr 2014 15:57:44 -0400 From: Denys Vlasenko To: linux-kernel@vger.kernel.org Cc: Denys Vlasenko , Frederic Weisbecker , Hidetoshi Seto , Fernando Luis Vazquez Cao , Tetsuo Handa , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Andrew Morton , Arjan van de Ven , Oleg Nesterov Subject: [PATCH 2/2] nohz: don't fetch per_cpu variable before we need it Date: Fri, 25 Apr 2014 20:57:30 +0200 Message-Id: <1398452250-6047-2-git-send-email-dvlasenk@redhat.com> In-Reply-To: <1398452250-6047-1-git-send-email-dvlasenk@redhat.com> References: <1398452250-6047-1-git-send-email-dvlasenk@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Frederic Weisbecker Cc: Hidetoshi Seto Cc: Fernando Luis Vazquez Cao Cc: Tetsuo Handa Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Andrew Morton Cc: Arjan van de Ven Cc: Oleg Nesterov --- 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/