Received: by 10.213.65.68 with SMTP id h4csp620359imn; Tue, 20 Mar 2018 11:01:20 -0700 (PDT) X-Google-Smtp-Source: AG47ELuS/II9xzdARbS1F8yLCB/W4HFO3DQRi5mtYW49ppajBiWXgV2zIiQkU8jj9APg3S0AAKlO X-Received: by 2002:a17:902:24a5:: with SMTP id w34-v6mr17451327pla.328.1521568880306; Tue, 20 Mar 2018 11:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521568880; cv=none; d=google.com; s=arc-20160816; b=w7ZSE+ZzpOJQN0jyGZ0RtMVQCICGPUdlnJ6aJC5xuG+8ad1ddWvnaNa5isM5fMh13/ CGPB0IdB3OpmUXhSsPDjI2i28Haxq8TkTa2beFSCAwdDXtX3PK2uU/DLZXbu+8y/LTbG jqftaCFPbFtoObr88GO9l0ZX5Vk3K65FHjBmiUoqoN1DBpo4LmRM5bRfNRji++PeaKeB VybfUD6pj+Vx/B+3BrInxMK+QPsYV5YtY1Kqil21hEtE/NIF6UMh34vgDRoxsdwaf+wz a9MkEGBP7oQqS1qM0rwfS8wkXz3uYCI2DEnmEWONCAOUVV/c19coznQo6vUjfNxRMeHc 9srQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=5BNis3SSpwl66POtbsOlZ318e8N90lKqYnoufcxRgIY=; b=Qm5uWHZfVZCtPTAb+hN+RQgJV7bzSB1EtWkGm7HQxFwcZydhnenrIsozxTV/biQr++ tHqDXFUDJ5mCUaWRjaPM1vUpRBAD8iq6XyfIfooSLiH1YLTfrYNEa5AIFEopl7Rxjwib 5b9WOnD7RLky2wagWgD+x8EDdpZROWGjtBxl8pmN8zuefN1f/86q6jasIgkEEB3YJoXV 6jaJC7iuriaplwogCu6rNgy+ShgvXANgDsxoDrvoWP2Yg/hoNbOy5Z9E4OIpId9RxrVB ZrQUDXIlBL95lz+ewaIwz2qGV4VWVS4rJqjBEDmjA5F7GIqmqXOlI1xn7dSXR/lGTW+R reeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9-v6si2183759plr.21.2018.03.20.11.01.04; Tue, 20 Mar 2018 11:01:20 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751633AbeCTSAN (ORCPT + 99 others); Tue, 20 Mar 2018 14:00:13 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:52501 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751408AbeCTSAL (ORCPT ); Tue, 20 Mar 2018 14:00:11 -0400 Received: from 79.184.254.228.ipv4.supernova.orange.pl (79.184.254.228) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83) id 5163668d755bdeed; Tue, 20 Mar 2018 19:00:09 +0100 From: "Rafael J. Wysocki" To: Peter Zijlstra , Linux PM Cc: Frederic Weisbecker , Thomas Gleixner , Paul McKenney , Thomas Ilsche , Doug Smythies , Rik van Riel , Aubrey Li , Mike Galbraith , LKML Subject: [Correction][RFT][PATCH v7 3/8] sched: idle: Do not stop the tick before cpuidle_idle_call() Date: Tue, 20 Mar 2018 19:00:37 +0100 Message-ID: <8465308.mkr1foup4p@aspire.rjw.lan> In-Reply-To: <5325267.FN4F6lrTUU@aspire.rjw.lan> References: <2390019.oHdSGtR3EE@aspire.rjw.lan> <5325267.FN4F6lrTUU@aspire.rjw.lan> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Make cpuidle_idle_call() decide whether or not to stop the tick. First, the cpuidle_enter_s2idle() path deals with the tick (and with the entire timekeeping for that matter) by itself and it doesn't need the tick to be stopped beforehand. Second, to address the issue with short idle duration predictions by the idle governor after the tick has been stopped, it will be necessary to change the ordering of cpuidle_select() with respect to tick_nohz_idle_stop_tick(). To prepare for that, put a tick_nohz_idle_stop_tick() call in the same branch in which cpuidle_select() is called. Signed-off-by: Rafael J. Wysocki --- The correct patch this time. --- kernel/sched/idle.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) Index: linux-pm/kernel/sched/idle.c =================================================================== --- linux-pm.orig/kernel/sched/idle.c +++ linux-pm/kernel/sched/idle.c @@ -146,13 +146,15 @@ static void cpuidle_idle_call(void) } /* - * Tell the RCU framework we are entering an idle section, - * so no more rcu read side critical sections and one more + * The RCU framework needs to be told that we are entering an idle + * section, so no more rcu read side critical sections and one more * step to the grace period */ - rcu_idle_enter(); if (cpuidle_not_available(drv, dev)) { + tick_nohz_idle_stop_tick(); + rcu_idle_enter(); + default_idle_call(); goto exit_idle; } @@ -169,16 +171,26 @@ static void cpuidle_idle_call(void) if (idle_should_enter_s2idle() || dev->use_deepest_state) { if (idle_should_enter_s2idle()) { + rcu_idle_enter(); + entered_state = cpuidle_enter_s2idle(drv, dev); if (entered_state > 0) { local_irq_enable(); goto exit_idle; } + + rcu_idle_exit(); } + tick_nohz_idle_stop_tick(); + rcu_idle_enter(); + next_state = cpuidle_find_deepest_state(drv, dev); call_cpuidle(drv, dev, next_state); } else { + tick_nohz_idle_stop_tick(); + rcu_idle_enter(); + /* * Ask the cpuidle framework to choose a convenient idle state. */ @@ -245,7 +257,6 @@ static void do_idle(void) tick_nohz_idle_restart_tick(); cpu_idle_poll(); } else { - tick_nohz_idle_stop_tick(); cpuidle_idle_call(); } arch_cpu_idle_exit();