From patchwork Thu Sep 27 10:31:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11752 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id AAEEC23EFF for ; Thu, 27 Sep 2012 10:31:18 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3C099A18642 for ; Thu, 27 Sep 2012 10:31:18 +0000 (UTC) Received: by ieje10 with SMTP id e10so3764168iej.11 for ; Thu, 27 Sep 2012 03:31:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=kNGjjp8BHLNiQnhNnP6ku2t/LZxBT4po8N6kCDzmnkk=; b=drE8SwprEaIbC7DJPG4YLwj6RMvzsINLRGdDmMwT149VwAKII9S21x6nnhEzj3J+BY 11/uHjFN8lznZFy4/tPBYE94t5NBX5dD4/hKgv59EH94w7UA2a4UJGxN3vsUjwTyC192 DCTaxfCm7lyvQFjDav9ia9upH1Ur3D5qZAFFFCw2QdTdyzRbKKg8P3+ls5y38VX20J32 mx0KDpW9CfvUwEB6RpulFMWuwSgLZXM4BDEtqxClGT+aNkumGVv5oEwoNZzhugc1AIDw 9gTF2lHyjM/mYt9DXU5RnD7Lw1BH8GSf8obaoDx7hkdyb8GGXmT7ci/EsoTGa2wBHMkZ PWkw== Received: by 10.50.217.227 with SMTP id pb3mr13809450igc.28.1348741877561; Thu, 27 Sep 2012 03:31:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp407940igc; Thu, 27 Sep 2012 03:31:17 -0700 (PDT) Received: by 10.50.53.170 with SMTP id c10mr3175571igp.45.1348741877086; Thu, 27 Sep 2012 03:31:17 -0700 (PDT) Received: from mail-ie0-f178.google.com (mail-ie0-f178.google.com [209.85.223.178]) by mx.google.com with ESMTPS id mj1si18362783igc.15.2012.09.27.03.31.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 03:31:17 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.223.178 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.223.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.223.178 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) smtp.mail=viresh.kumar@linaro.org Received: by ieje11 with SMTP id e11so4657642iej.37 for ; Thu, 27 Sep 2012 03:31:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.190.137 with SMTP id gq9mr3192359igc.27.1348741876689; Thu, 27 Sep 2012 03:31:16 -0700 (PDT) Received: by 10.64.166.38 with HTTP; Thu, 27 Sep 2012 03:31:16 -0700 (PDT) In-Reply-To: <169feed8cddec1edecb311d2471df0a553d6e865.1348736069.git.viresh.kumar@linaro.org> References: <169feed8cddec1edecb311d2471df0a553d6e865.1348736069.git.viresh.kumar@linaro.org> Date: Thu, 27 Sep 2012 16:01:16 +0530 Message-ID: Subject: Re: [PATCH V2 2/3] timer: hrtimer: Don't check idle_cpu() before calling get_nohz_timer_target() From: Viresh Kumar To: linux-kernel@vger.kernel.org Cc: pjt@google.com, paul.mckenney@linaro.org, tglx@linutronix.de, tj@kernel.org, suresh.b.siddha@intel.com, venki@google.com, mingo@redhat.com, peterz@infradead.org, robin.randhawa@arm.com, Steve.Bannister@arm.com, Arvind.Chauhan@arm.com, amit.kucheria@linaro.org, vincent.guittot@linaro.org, linaro-dev@lists.linaro.org, patches@linaro.org, Viresh Kumar X-Gm-Message-State: ALoCoQnrTXEL+a0D4Pb4qtmwISMDRc4GGfZNJcavRQnmYR663O+PvEo0QINDWSCPnZXNr+U9sksj On 27 September 2012 14:34, Viresh Kumar wrote: > #if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP) > - if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) > + if (!pinned && get_sysctl_timer_migration()) > cpu = get_nohz_timer_target(); > #endif > + if (!cpu) > + cpu = smp_processor_id(); Ahh... Bad change... cpu can be returned as zero by get_nohz_timer_target(). Please consider below patch here: ------------8<------------- Subject: [PATCH] timer: hrtimer: Don't check idle_cpu() before calling get_nohz_timer_target() Check for current cpu's idleness already done in implementation of sched_select_cpu() which is called by get_nohz_timer_target(). So, no need to call idle_cpu() twice, once from sched_select_cpu() and once from timer and hrtimer before calling get_nohz_timer_target(). This patch removes calls to idle_cpu() from timer and hrtimer. This also reduces an extra call to smp_processor_id() when get_nohz_timer_target() is called. Signed-off-by: Viresh Kumar --- kernel/hrtimer.c | 2 +- kernel/timer.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 6db7a5e..74bdaf6 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -159,7 +159,7 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer, static int hrtimer_get_target(int this_cpu, int pinned) { #ifdef CONFIG_NO_HZ - if (!pinned && get_sysctl_timer_migration() && idle_cpu(this_cpu)) + if (!pinned && get_sysctl_timer_migration()) return get_nohz_timer_target(); #endif return this_cpu; diff --git a/kernel/timer.c b/kernel/timer.c index d5de1b2..db57606 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -733,11 +733,13 @@ __mod_timer(struct timer_list *timer, unsigned long expires, debug_activate(timer, expires); - cpu = smp_processor_id(); - #if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP) - if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) + if (!pinned && get_sysctl_timer_migration()) cpu = get_nohz_timer_target(); + else + cpu = smp_processor_id(); +#else + cpu = smp_processor_id(); #endif new_base = per_cpu(tvec_bases, cpu);