From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030996Ab2CUOFv (ORCPT ); Wed, 21 Mar 2012 10:05:51 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:47416 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030583Ab2CUN7S (ORCPT ); Wed, 21 Mar 2012 09:59:18 -0400 From: Frederic Weisbecker To: LKML , linaro-sched-sig@lists.linaro.org Cc: Frederic Weisbecker , Alessio Igor Bogani , Andrew Morton , Avi Kivity , Chris Metcalf , Christoph Lameter , Daniel Lezcano , Geoff Levand , Gilad Ben Yossef , Ingo Molnar , Max Krasnyansky , "Paul E. McKenney" , Peter Zijlstra , Stephen Hemminger , Steven Rostedt , Sven-Thorsten Dietrich , Thomas Gleixner , Zen Lin Subject: [PATCH 08/32] nohz: Try not to give the timekeeping duty to an adaptive tickless cpu Date: Wed, 21 Mar 2012 14:58:14 +0100 Message-Id: <1332338318-5958-10-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1332338318-5958-1-git-send-email-fweisbec@gmail.com> References: <1332338318-5958-1-git-send-email-fweisbec@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Try to give the timekeeing duty to a CPU that doesn't belong to any nohz cpuset when possible, so that we increase the chance for these nohz cpusets to run their CPUs out of periodic tick mode. [TODO: We need to find a way to ensure there is always one non-nohz running CPU maintaining the timekeeping duty if every non-idle CPUs are adaptive tickless] Signed-off-by: Frederic Weisbecker Cc: Alessio Igor Bogani Cc: Andrew Morton Cc: Avi Kivity Cc: Chris Metcalf Cc: Christoph Lameter Cc: Daniel Lezcano Cc: Geoff Levand Cc: Gilad Ben Yossef Cc: Ingo Molnar Cc: Max Krasnyansky Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Stephen Hemminger Cc: Steven Rostedt Cc: Sven-Thorsten Dietrich Cc: Thomas Gleixner Cc: Zen Lin --- kernel/time/tick-sched.c | 52 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 41 insertions(+), 11 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 0695e9d..f1142d5 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -782,6 +783,45 @@ void tick_check_idle(int cpu) tick_check_nohz(cpu); } +#ifdef CONFIG_CPUSETS_NO_HZ + +/* + * Take the timer duty if nobody is taking care of it. + * If a CPU already does and and it's in a nohz cpuset, + * then take the charge so that it can switch to nohz mode. + */ +static void tick_do_timer_check_handler(int cpu) +{ + int handler = tick_do_timer_cpu; + + if (unlikely(handler == TICK_DO_TIMER_NONE)) { + tick_do_timer_cpu = cpu; + } else { + if (!cpuset_adaptive_nohz() && + cpuset_cpu_adaptive_nohz(handler)) + tick_do_timer_cpu = cpu; + } +} + +#else + +static void tick_do_timer_check_handler(int cpu) +{ +#ifdef CONFIG_NO_HZ + /* + * Check if the do_timer duty was dropped. We don't care about + * concurrency: This happens only when the cpu in charge went + * into a long sleep. If two cpus happen to assign themself to + * this duty, then the jiffies update is still serialized by + * xtime_lock. + */ + if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE)) + tick_do_timer_cpu = cpu; +#endif +} + +#endif /* CONFIG_CPUSETS_NO_HZ */ + /* * High resolution timer specific code */ @@ -798,17 +838,7 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer) ktime_t now = ktime_get(); int cpu = smp_processor_id(); -#ifdef CONFIG_NO_HZ - /* - * Check if the do_timer duty was dropped. We don't care about - * concurrency: This happens only when the cpu in charge went - * into a long sleep. If two cpus happen to assign themself to - * this duty, then the jiffies update is still serialized by - * xtime_lock. - */ - if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE)) - tick_do_timer_cpu = cpu; -#endif + tick_do_timer_check_handler(cpu); /* Check, if the jiffies need an update */ if (tick_do_timer_cpu == cpu) -- 1.7.5.4