From patchwork Fri Feb 14 12:12:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 24645 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CFE4D202B2 for ; Fri, 14 Feb 2014 12:13:18 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id e16sf24195319qcx.8 for ; Fri, 14 Feb 2014 04:13:17 -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=bPZ0sKBEcOql8SqWcKVs+enNr9ka6PZOUjBVsRiPh1U=; b=MDUJX0ywJumPI6JFvAjuuji4bpSuCRbnP7La7OZ42Z+96AAlhtibCJQCGu1+5Oods+ EAhHD3qsGHUDRvlhO2p9inr+V9MfCqnmSlIiA7+ncyjfRVUoZiKDH5d3PkIsKrYc/Zae zfxkfNP5G0xfPg+MTPODgI9G1Phu2YmyRkXRIg1eZ4CaME+3/taGkRJWaJLiUG1SzDJM DkTw/IWcGzPkbcAzjU5AfUs5MEdhvPMgRT4PuFBVchnvbmHLwm0ITM/qcCfD7ZQUKdw7 eS37DuNMI7PW7xymY+BnXehWVPp/WIwlM1dVwLQEJfRYBkoQjNY8B8EOVeC3PQOXbEbg YI7g== X-Gm-Message-State: ALoCoQk9X+jrg3y4P5exDCp/55VS9jfLnwj0M5Sn+o0zy8nDjeNVYpDY6qUisPJ762aTyyduKG8/ X-Received: by 10.236.17.161 with SMTP id j21mr2397103yhj.55.1392379997743; Fri, 14 Feb 2014 04:13:17 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.34.235 with SMTP id l98ls49731qgl.90.gmail; Fri, 14 Feb 2014 04:13:17 -0800 (PST) X-Received: by 10.52.184.73 with SMTP id es9mr826347vdc.31.1392379997645; Fri, 14 Feb 2014 04:13:17 -0800 (PST) Received: from mail-ve0-x231.google.com (mail-ve0-x231.google.com [2607:f8b0:400c:c01::231]) by mx.google.com with ESMTPS id tj7si1839739vdc.59.2014.02.14.04.13.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Feb 2014 04:13:17 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::231 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::231; Received: by mail-ve0-f177.google.com with SMTP id jz11so9485307veb.22 for ; Fri, 14 Feb 2014 04:13:15 -0800 (PST) X-Received: by 10.52.65.207 with SMTP id z15mr27735vds.61.1392379995258; Fri, 14 Feb 2014 04:13:15 -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 u4csp103895vcz; Fri, 14 Feb 2014 04:13:14 -0800 (PST) X-Received: by 10.66.150.69 with SMTP id ug5mr8565509pab.55.1392379994166; Fri, 14 Feb 2014 04:13:14 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si5621319pbk.84.2014.02.14.04.13.13; Fri, 14 Feb 2014 04:13:13 -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 S1752052AbaBNMMu (ORCPT + 27 others); Fri, 14 Feb 2014 07:12:50 -0500 Received: from mail-we0-f181.google.com ([74.125.82.181]:46815 "EHLO mail-we0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbaBNMMs (ORCPT ); Fri, 14 Feb 2014 07:12:48 -0500 Received: by mail-we0-f181.google.com with SMTP id w61so8780309wes.12 for ; Fri, 14 Feb 2014 04:12:47 -0800 (PST) X-Received: by 10.180.107.1 with SMTP id gy1mr1914166wib.47.1392379967535; Fri, 14 Feb 2014 04:12:47 -0800 (PST) Received: from localhost.localdomain (19.104.89.79.rev.sfr.net. [79.89.104.19]) by mx.google.com with ESMTPSA id fb6sm3976631wib.2.2014.02.14.04.12.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Feb 2014 04:12:47 -0800 (PST) From: Frederic Weisbecker To: LKML Cc: Viresh Kumar , Ingo Molnar , 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: Fri, 14 Feb 2014 13:12:39 +0100 Message-Id: <1392379960-4758-2-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1392379960-4758-1-git-send-email-fweisbec@gmail.com> References: <1392379960-4758-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::231 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..881f883 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 buzy 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);