From patchwork Fri Sep 28 07:02:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11832 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 52B8323EFB for ; Fri, 28 Sep 2012 07:02:35 +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 EDE91A1808F for ; Fri, 28 Sep 2012 07:02:34 +0000 (UTC) Received: by ieje10 with SMTP id e10so6215061iej.11 for ; Fri, 28 Sep 2012 00:02:34 -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:from:to:cc :subject:date:message-id:x-mailer:x-originalarrivaltime:x-mc-unique :content-type:content-transfer-encoding:x-gm-message-state; bh=NQfPUUHoB3fhkVn43oJiUZGJ3Pe9eYJgp1Eu4c6lgEg=; b=mZdqDHa6MZ+MfdLyOUhUaeaRHnpSD9lZKnQzPC601sEskMxLVMnAxU4MZ8lFeaY2Mn VgijSFBNkib4mMnvgOOn0Rztcy2VrGnM5W0WOSeelvqYfrGqRNY7GfhAGOgAcJGI77KB qXi5hvfLDkeoDeuDTkZgs8fkjxtR2vZY2w5iESNNebkDVU9mnFCghe7gqAoobMnqVRGC ZtGqoKlmu3uoU2T6UThYeePcp1eiqP4GsturKYcayLWtvpxEicb5ZrPnk6WWV4ordc4x CSQONl91OcpjHP5qbLEA5E/ERsu1SbGHmSVzDGVSP13PcWpfMl1EYGWGsI3IUWF/fpq/ KPkQ== Received: by 10.50.150.198 with SMTP id uk6mr754740igb.43.1348815754422; Fri, 28 Sep 2012 00:02:34 -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 ex8csp455618igc; Fri, 28 Sep 2012 00:02:33 -0700 (PDT) Received: by 10.216.211.158 with SMTP id w30mr2805724weo.55.1348815752984; Fri, 28 Sep 2012 00:02:32 -0700 (PDT) Received: from service87.mimecast.com (service87.mimecast.com. [91.220.42.44]) by mx.google.com with ESMTP id m2si9717437wea.145.2012.09.28.00.02.32; Fri, 28 Sep 2012 00:02:32 -0700 (PDT) Received-SPF: pass (google.com: domain of viresh.kumar2@arm.com designates 91.220.42.44 as permitted sender) client-ip=91.220.42.44; Authentication-Results: mx.google.com; spf=pass (google.com: domain of viresh.kumar2@arm.com designates 91.220.42.44 as permitted sender) smtp.mail=viresh.kumar2@arm.com Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 28 Sep 2012 08:02:31 +0100 Received: from localhost ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Fri, 28 Sep 2012 08:02:29 +0100 From: Viresh Kumar To: tglx@linutronix.de, linux-kernel@vger.kernel.org Cc: paul.mckenney@linaro.org, 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 Subject: [PATCH] timers: Avoid finding cpu for migration of running timers in __mod_timer() Date: Fri, 28 Sep 2012 12:32:19 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e X-OriginalArrivalTime: 28 Sep 2012 07:02:30.0049 (UTC) FILETIME=[39BC4110:01CD9D47] X-MC-Unique: 112092808023105501 X-Gm-Message-State: ALoCoQk22Ed86gi8OzNOSFXCfRXQkOlLo/yxphoNMItZvEPvtb5Z8W9QR33ox7k/kevfOvWw8nmp Currently we don't support migration of currently running timers. Current code flow in __mod_timer() is: - Find a cpu where we should migrate the timer - Check if timer is currently running - If yes, don't migrate. In this process, the first step is a unnecessary activiy, if the timer is currently running. This patch tries to avoid it in such cases. Signed-off-by: Viresh Kumar --- kernel/timer.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/kernel/timer.c b/kernel/timer.c index 8c5e7b9..6e5bf98 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -755,23 +755,23 @@ __mod_timer(struct timer_list *timer, unsigned long expires, debug_activate(timer, expires); - cpu = smp_processor_id(); + /* + * Should we try to migrate timer? + * However we can't change timer's base while it is running, otherwise + * del_timer_sync() can't detect that the timer's handler yet has not + * finished. This also guarantees that the timer is serialized wrt + * itself. + */ + if (likely(base->running_timer != timer)) { + cpu = smp_processor_id(); #if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP) - if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) - cpu = get_nohz_timer_target(); + if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) + cpu = get_nohz_timer_target(); #endif - new_base = per_cpu(tvec_bases, cpu); + new_base = per_cpu(tvec_bases, cpu); - if (base != new_base) { - /* - * We are trying to schedule the timer on the local CPU. - * However we can't change timer's base while it is running, - * otherwise del_timer_sync() can't detect that the timer's - * handler yet has not finished. This also guarantees that - * the timer is serialized wrt itself. - */ - if (likely(base->running_timer != timer)) { + if (base != new_base) { /* See the comment in lock_timer_base() */ timer_set_base(timer, NULL); spin_unlock(&base->lock);