Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758036Ab0LTP1j (ORCPT ); Mon, 20 Dec 2010 10:27:39 -0500 Received: from mail-fx0-f43.google.com ([209.85.161.43]:42508 "EHLO mail-fx0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754427Ab0LTPYh (ORCPT ); Mon, 20 Dec 2010 10:24:37 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=iPyKPfwZPQdUb5CtgcHZM3Ny3OGt9FRo7TbWHxewxnU7FrvxDB9vXzvS1Zzvf3/OKD psfwULllT4T+ad/pQunOhftgkEu9qhn7Pn9UZJOSL6q/kzrdFkvIdDWOVhebB7ezRVeq fLChVp3LJDL9aoXTVgsNMIYCTxK05fcQ9BAFY= From: Frederic Weisbecker To: LKML Cc: LKML , Frederic Weisbecker , Thomas Gleixner , Peter Zijlstra , "Paul E. McKenney" , Ingo Molnar , Steven Rostedt , Lai Jiangshan , Andrew Morton , Anton Blanchard , Tim Pepper Subject: [RFC PATCH 02/15] nohz_task: Avoid nohz task cpu as non-idle timer target Date: Mon, 20 Dec 2010 16:24:09 +0100 Message-Id: <1292858662-5650-3-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1292858662-5650-1-git-send-email-fweisbec@gmail.com> References: <1292858662-5650-1-git-send-email-fweisbec@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1780 Lines: 63 Unbound timers are preferably targeted for non idle cpu. If possible though, prioritize idle cpus over nohz task cpus, because the main point of nohz task is to avoid unnecessary timer interrupts. Signed-off-by: Frederic Weisbecker Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Steven Rostedt Cc: Lai Jiangshan Cc: Andrew Morton Cc: Anton Blanchard Cc: Tim Pepper --- kernel/sched.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/sched.c b/kernel/sched.c index dc91a4d..2cd6823 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -1209,16 +1209,29 @@ static void resched_cpu(int cpu) int get_nohz_timer_target(void) { int cpu = smp_processor_id(); + int fallback = -1; int i; struct sched_domain *sd; for_each_domain(cpu, sd) { - for_each_cpu(i, sched_domain_span(sd)) + for_each_cpu(i, sched_domain_span(sd)) { + if (cpu_has_nohz_task(i)) + continue; + if (!idle_cpu(i)) return i; + + if (fallback == -1 || i == cpu) + fallback = i; + } } - return cpu; + + if (fallback == -1) + fallback = cpu; + + return fallback; } + /* * When add_timer_on() enqueues a timer into the timer wheel of an * idle CPU then this timer might expire before the next timer event -- 1.7.3.2 -- 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/