From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754846Ab1HOPxY (ORCPT ); Mon, 15 Aug 2011 11:53:24 -0400 Received: from mail-vx0-f174.google.com ([209.85.220.174]:51689 "EHLO mail-vx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754797Ab1HOPxU (ORCPT ); Mon, 15 Aug 2011 11:53:20 -0400 From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Andrew Morton , Anton Blanchard , Avi Kivity , Ingo Molnar , Lai Jiangshan , "Paul E . McKenney" , Paul Menage , Peter Zijlstra , Stephen Hemminger , Thomas Gleixner , Tim Pepper Subject: [PATCH 12/32] nohz: Try not to give the timekeeping duty to a cpuset nohz cpu Date: Mon, 15 Aug 2011 17:52:09 +0200 Message-Id: <1313423549-27093-13-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1313423549-27093-1-git-send-email-fweisbec@gmail.com> References: <1313423549-27093-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. Signed-off-by: Frederic Weisbecker Cc: Andrew Morton Cc: Anton Blanchard Cc: Avi Kivity Cc: Ingo Molnar Cc: Lai Jiangshan Cc: Paul E . McKenney Cc: Paul Menage Cc: Peter Zijlstra Cc: Stephen Hemminger Cc: Thomas Gleixner Cc: Tim Pepper --- 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 f5e12da..5f41ef7 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -729,6 +730,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 */ @@ -745,17 +785,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