From patchwork Wed Feb 26 16:52:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 25365 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DD38D203C4 for ; Wed, 26 Feb 2014 16:52:56 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id uy5sf3811522obc.10 for ; Wed, 26 Feb 2014 08:52:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=rI2FH5s1Uur8SvSW5wV2lCZYzpWeGut1agKGrdRyFcQ=; b=dbmn5c9A0SoiruTol+7JWGWN0FpMdlQT85XHdY2hmLJTrKTaohfWieRFe/PI3mbuSf Iu0M75+9tgROlLYtJj6tuioe4+gw1EXkFWHFdBe4xIofHHfSqDS2pzwo8AlAczXN6KHe AYgRNwVXvGD6xbjiwOPOoyXP9zv0l7QGcAVmFfRavDn4FZW0fxhrst2mIkOXq/77kMX2 jGnq/nNpaJUK76lh2xbGMPDd9kvkUqHKo8O+0NsGvRp3+HlFifySPnqzPFBsHZ6eNAis n9P4xLo+TfUqBSKwLj3udgKZuWXNJCYXPGHX3g+pNPQewl7qfNkkzJ0X7mGlmntVYheQ 8JIg== X-Gm-Message-State: ALoCoQkRa+LNUFTq+UgV82BryVm/FCm3eEXY46hDmnBbXYtgDEzL/UnUtkxRdcRsiPcNAMMADqP/ X-Received: by 10.42.115.129 with SMTP id k1mr83183icq.25.1393433576400; Wed, 26 Feb 2014 08:52:56 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.231 with SMTP id q94ls307557qga.45.gmail; Wed, 26 Feb 2014 08:52:56 -0800 (PST) X-Received: by 10.53.9.107 with SMTP id dr11mr5536401vdd.1.1393433576235; Wed, 26 Feb 2014 08:52:56 -0800 (PST) Received: from mail-ve0-x22e.google.com (mail-ve0-x22e.google.com [2607:f8b0:400c:c01::22e]) by mx.google.com with ESMTPS id w14si375582vco.3.2014.02.26.08.52.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Feb 2014 08:52:56 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22e; Received: by mail-ve0-f174.google.com with SMTP id oy12so2468325veb.33 for ; Wed, 26 Feb 2014 08:52:56 -0800 (PST) X-Received: by 10.58.211.8 with SMTP id my8mr40317vec.80.1393433575991; Wed, 26 Feb 2014 08:52:55 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp39946vcz; Wed, 26 Feb 2014 08:52:55 -0800 (PST) X-Received: by 10.66.192.162 with SMTP id hh2mr9745396pac.150.1393433574904; Wed, 26 Feb 2014 08:52:54 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wh10si1573070pab.278.2014.02.26.08.52.54; Wed, 26 Feb 2014 08:52:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753393AbaBZQwr (ORCPT + 26 others); Wed, 26 Feb 2014 11:52:47 -0500 Received: from mail-wi0-f181.google.com ([209.85.212.181]:33953 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753139AbaBZQwN (ORCPT ); Wed, 26 Feb 2014 11:52:13 -0500 Received: by mail-wi0-f181.google.com with SMTP id hi5so2396597wib.2 for ; Wed, 26 Feb 2014 08:52:12 -0800 (PST) X-Received: by 10.180.12.43 with SMTP id v11mr5479253wib.33.1393433532512; Wed, 26 Feb 2014 08:52:12 -0800 (PST) Received: from localhost.localdomain.com (19.104.89.79.rev.sfr.net. [79.89.104.19]) by mx.google.com with ESMTPSA id pm2sm46300636wic.0.2014.02.26.08.52.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2014 08:52:12 -0800 (PST) From: Frederic Weisbecker To: Ingo Molnar Cc: LKML , Viresh Kumar , Paul Gortmaker , "Paul E. McKenney" , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Frederic Weisbecker Subject: [PATCH 1/2] timer: Spare IPI when deferrable timer is queued on idle remote targets Date: Wed, 26 Feb 2014 17:52:04 +0100 Message-Id: <1393433525-5765-2-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1393433525-5765-1-git-send-email-fweisbec@gmail.com> References: <1393433525-5765-1-git-send-email-fweisbec@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: fweisbec@gmail.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (bad format) header.i=@gmail.com; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Viresh Kumar When a timer is enqueued or modified on a remote target, the latter is expected to see and handle this timer on its next tick. However if the target is idle and CONFIG_NO_HZ_IDLE=y, the CPU may be sleeping tickless and the timer may be ignored. wake_up_nohz_cpu() takes care of that by setting TIF_NEED_RESCHED and sending an IPI to idle targets so that the tick is reevaluated on the idle loop through the tick_nohz_idle_*() APIs. Now this is all performed regardless of the power properties of the timer. If the timer is deferrable, idle targets don't need to be woken up. Only the next buzy tick needs to care about it, and no IPI kick is needed for that to happen. So lets spare the IPI on idle targets when the timer is deferrable. Meanwhile we keep the current behaviour on full dynticks targets. We can spare IPIs on idle full dynticks targets as well but some tricky races against idle_cpu() must be dealt all along to make sure that the timer is well handled after idle exit. We can deal with that later since NO_HZ_FULL already has more important powersaving issues. Reported-by: Thomas Gleixner Signed-off-by: Viresh Kumar Cc: Ingo Molnar Cc: Paul Gortmaker Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/CAKohpomMZ0TAN2e6N76_g4ZRzxd5vZ1XfuZfxrP7GMxfTNiLVw@mail.gmail.com Signed-off-by: Frederic Weisbecker --- kernel/timer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/timer.c b/kernel/timer.c index accfd24..b75e789 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -939,8 +939,15 @@ void add_timer_on(struct timer_list *timer, int cpu) * with the timer by holding the timer base lock. This also * makes sure that a CPU on the way to stop its tick can not * evaluate the timer wheel. + * + * Spare the IPI for deferrable timers on idle targets though. + * The next busy ticks will take care of it. Except full dynticks + * require special care against races with idle_cpu(), lets deal + * with that later. */ - wake_up_nohz_cpu(cpu); + if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(cpu)) + wake_up_nohz_cpu(cpu); + spin_unlock_irqrestore(&base->lock, flags); } EXPORT_SYMBOL_GPL(add_timer_on);