From patchwork Fri Apr 11 09:54:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 28255 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C17220822 for ; Fri, 11 Apr 2014 09:54:26 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id w8sf13192599qac.4 for ; Fri, 11 Apr 2014 02:54:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=mn7NlSJxZWecWkaWwIqndwRwJKhcQpw7nFR2unT4oYw=; b=hnyA4xQVnCN7nGXAwR1iy6FA+q94uQVw4t15Vckc+rgsvxRbfovlzjRH92UqkumMXw uJ7hOrMkJglofYwtyx6Af1XS4OGE/9M1WSlvyN25j1stqlXQeDqTZHd8OKkrDJ7d3A/Y FmhUW0Xm0EU0KtKUHikEnj8m/gVxWWjX9+gDyuuQVXweUkg9CXYxPXg7P7cW1GVfZJLr cdlc4DUlDv57rmbapVk47P/sDvbZNvsv7OXUnVIq9ZrQwTbW3HDyMzG0tvaxpeooSVw0 +Og/eXdGFPmIb6Rs1MtZqqnrbTPiNl1ErB47HZSw81NPlPJbpO807QSHEOXK4ccnJj9A HLoA== X-Gm-Message-State: ALoCoQldioS1tBInziMY2jJMUmnl9czfaF72bCthtCkZedCBCLEUQRmxgm6FOm5G5ey93n5cnOX5 X-Received: by 10.236.32.236 with SMTP id o72mr9014140yha.42.1397210066367; Fri, 11 Apr 2014 02:54:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.72 with SMTP id s66ls1569696qgd.11.gmail; Fri, 11 Apr 2014 02:54:26 -0700 (PDT) X-Received: by 10.221.29.137 with SMTP id ry9mr19214869vcb.6.1397210066202; Fri, 11 Apr 2014 02:54:26 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id sr19si1208646vcb.71.2014.04.11.02.54.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Apr 2014 02:54:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id db12so4454677veb.24 for ; Fri, 11 Apr 2014 02:54:26 -0700 (PDT) X-Received: by 10.52.173.165 with SMTP id bl5mr15793251vdc.13.1397210066124; Fri, 11 Apr 2014 02:54:26 -0700 (PDT) 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.221.72 with SMTP id ib8csp43392vcb; Fri, 11 Apr 2014 02:54:25 -0700 (PDT) X-Received: by 10.66.142.42 with SMTP id rt10mr26370191pab.1.1397210065042; Fri, 11 Apr 2014 02:54:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si3868554pas.385.2014.04.11.02.54.24; Fri, 11 Apr 2014 02:54:24 -0700 (PDT) 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 S1756514AbaDKJyP (ORCPT + 26 others); Fri, 11 Apr 2014 05:54:15 -0400 Received: from mail-oa0-f43.google.com ([209.85.219.43]:64533 "EHLO mail-oa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754232AbaDKJyM (ORCPT ); Fri, 11 Apr 2014 05:54:12 -0400 Received: by mail-oa0-f43.google.com with SMTP id eb12so5910150oac.16 for ; Fri, 11 Apr 2014 02:54:12 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.236.162 with SMTP id uv2mr4526585obc.40.1397210052157; Fri, 11 Apr 2014 02:54:12 -0700 (PDT) Received: by 10.182.28.168 with HTTP; Fri, 11 Apr 2014 02:54:11 -0700 (PDT) In-Reply-To: <20140410145621.GC27654@localhost.localdomain> References: <20140410145621.GC27654@localhost.localdomain> Date: Fri, 11 Apr 2014 15:24:11 +0530 Message-ID: Subject: Re: [Query]: tick-sched: can idle_active be false in tick_nohz_idle_exit()? From: Viresh Kumar To: Frederic Weisbecker Cc: Thomas Gleixner , Linux Kernel Mailing List , Lists linaro-kernel Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.179 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 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: , On 10 April 2014 20:26, Frederic Weisbecker wrote: > When a dynticks idle CPU is woken up (typically with an IPI), tick_nohz_stop_idle() > is called on interrupt entry but, because this is a waking up IPI, tick_nohz_start_idle() > won't be called. The reason is that need_resched() prevents tick_nohz_irq_exit() to be > called in irq_exit(). > > After all if we know that the CPU is going to exit the idle task, we don't need to account > any more idle time. We also don't need to retry to enter in dynticks idle mode since we > are going to restart the tick with tick_nohz_idle_exit(). > > So in case of wake up IPIs, we may end up with !ts->idle_active in tick_nohz_idle_exit() :) > > I must confess this is not obvious. I agree.. I didn't had a clue that this can happen. Good that I asked this question :) > It confused me as well when I met that part. A small > comment in tick_nohz_idle_exit() would be welcome ;) Looks hard. I tried for a small comment and this is the smallest I could get: I am preparing a cleanup patchset (separate from the timer/hrtimers 36 patch set) for kernel/time/ and will add this change to that.. I am waiting for the merge window to close and Thomas to comment on my timers/hrtimers patches first. Only then will I send another 40 :) --- viresh -- 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/ diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index c2d868d..26cf5bb 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -925,6 +925,22 @@ void tick_nohz_idle_exit(void) ts->inidle = 0; + /* + * Can idle_active be false here? + * Ideally this would be the sequence of calls: + * - tick_nohz_idle_enter(), i.e. idle_active = true; + * - local_irq_disable() + * - IDLE + * - wake up due to IPI or other interrupt + * - local_irq_enable() + * - tick_nohz_irq_enter(), i.e. idle_active = false; + * - tick_nohz_irq_exit(), i.e. idle_active = true; This is not called + * in case of IPI's as need_resched() will prevent that in + * tick_irq_exit(), as we don't need to account any more for idle time + * or try to enter dyntics mode (We are going to exit idle state). + * + * - tick_nohz_idle_exit() + */ if (ts->idle_active || ts->tick_stopped) now = ktime_get();