Received: by 10.223.185.111 with SMTP id b44csp106938wrg; Fri, 9 Mar 2018 01:52:33 -0800 (PST) X-Google-Smtp-Source: AG47ELu17KaZp5mmvxgoCmilS2mexdZXqGlDtBOYi62UZh1IJ/uqwFV2mpQsmADDwqaRESWbo8FT X-Received: by 10.99.64.197 with SMTP id n188mr23716530pga.21.1520589153554; Fri, 09 Mar 2018 01:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520589153; cv=none; d=google.com; s=arc-20160816; b=wbLdaKiIHlFpQGdmJ2BoN9KCXR1oAfeAa/dQ77DaHKCy4+wksu3Tbm33V65RUuhpdq Pnq59lO8pKo18/k+0Qfz7rsSIb0YLDLJe8ANWBzmx+M8FlISIEWaTrS0s8h+AZ9rgIEM ZjZd8CNBIY7UDjQTvSvd5YTuHHa1bx4A6V7s1z6/XvFnJ6DNwOySWhKZS3eudra63uwL RFHVLbgqmOTsA6hBCJhakJusqS7HbJnnQRUlDouTty0ebG2MBBNdegclE+yWGr3FPiHU i0aKogKBKQLzZ+XiwQ34bBIWuSliXsnVGygaY5tDv9G4ccTzDlXujQ9csgeVW2sdlTzI Y3Lw== 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=pHJPDv7ii6Xlyxj1nc+ZrBrJrfmPk5wbSENynhd3aqI=; b=NFA2Tb8MlMNZADfjsrWPsqkLU5qFwyDjp/1XCEaOiBGpgTK2KL6Q4HAqWDO7Qx7k/G I0VWgv70cAK9oxwntBg2X1rSamP+ygENo+6sz+ibVuf26hippuuU9/WmWLdwpekqXcF5 GNBoPfy3Pk06D1YV7u3pnrCJ2i/cWOPZNwvWngHBS8Aa2xREdGQFXdnmtyByaMoLIBNv JF6ch1AmY1T2twxQ3fSpyBHSuDUPj3a1phz1dJCyVQSydCTreUrNf8gPzhwRLw+UAcmb Eee3VH+mjHz8rMEKEtXKF89L1HtVcpJMo5o/y4kPMr3MXiv70L0bOzlP7QOE1ERzJqbx ViYg== 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 s13-v6si564247plq.793.2018.03.09.01.52.19; Fri, 09 Mar 2018 01:52:33 -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; 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 S1751321AbeCIJu0 (ORCPT + 99 others); Fri, 9 Mar 2018 04:50:26 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:54017 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750926AbeCIJsv (ORCPT ); Fri, 9 Mar 2018 04:48:51 -0500 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 1cd6ad25bdcef088; Fri, 9 Mar 2018 10:48:49 +0100 From: "Rafael J. Wysocki" To: Peter Zijlstra , Linux PM , Frederic Weisbecker Cc: Thomas Gleixner , Paul McKenney , Thomas Ilsche , Doug Smythies , Rik van Riel , Aubrey Li , Mike Galbraith , LKML Subject: [RFC/RFT][PATCH v3 3/6] sched: idle: Do not stop the tick before cpuidle_idle_call() Date: Fri, 09 Mar 2018 10:39:27 +0100 Message-ID: <1731836.ePJh9sqWU9@aspire.rjw.lan> In-Reply-To: <2450532.XN8DODrtDf@aspire.rjw.lan> References: <2450532.XN8DODrtDf@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 --- kernel/sched/idle.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 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. */ @@ -241,12 +253,11 @@ static void do_idle(void) * broadcast device expired for us, we don't want to go deep * idle as we know that the IPI is going to arrive right away. */ - if (cpu_idle_force_poll || tick_check_broadcast_expired()) { + if (cpu_idle_force_poll || tick_check_broadcast_expired()) cpu_idle_poll(); - } else { - tick_nohz_idle_stop_tick(); + else cpuidle_idle_call(); - } + arch_cpu_idle_exit(); }