Received: by 10.223.185.116 with SMTP id b49csp3581629wrg; Tue, 6 Mar 2018 01:15:32 -0800 (PST) X-Google-Smtp-Source: AG47ELvy+Q2f2IjAuAfmGtAxO9VRFLzJh2BBlEbpTrBcPDh+T/+IBXghYnPLod3DYX82qO6peJ2p X-Received: by 2002:a17:902:b582:: with SMTP id a2-v6mr15805576pls.353.1520327732444; Tue, 06 Mar 2018 01:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520327732; cv=none; d=google.com; s=arc-20160816; b=N8ki/ej59wBN2WxXrJtyYfB9tz9J2ppUVBRJHxir/v3uPds1aHnge+Gw8n06MSJU+D C7sxoE+l86EpXIhuLuPOV5z5lfhneMQ6CcoE0SSavQ9LEii3XHXQN0f/Su0XstfYe1i0 0J/sEaaAizneNeeYW5DZ3wohHxdGY2Nki2MYN52mzm8oZfsMEIxaY74JC1L7tIfKk6It viVjiN9t8IT2zQyD6lVCaXcAnJs/sZwmgp8iiv8GP28XXgmU32pJClA2UKhsPSVWgILk Qw/m8zZU8rLEFcA1HC1VrawacaHM64irLrgRpaLnuvvw3cww1glAVrLj2C2Nk3O7xLAx a54g== 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=C2FMQlXJQJxgryWp070rS7IlhltSAFnLI8trd5Uf0LU=; b=OvpRmweMC02/noO6dRN3/M+zQ+baWgIGn3bUS4PHsNkECY1dR83jOdX749apzqkbWb 8T+sHCGD9Huj+OzL4V0p32ssCZNVVtZnsmal1CVAgzlP+btg5RXm1P25GM+3XznU3lDO EeWk4zWu8Bg+sSqRIeaEwhDhCrpUJC+OOHdirjXwtsuXIY1kTNk4nx0tnoJQWSgknAo+ zjeLnbAigDW+iSuy1z3ZOP+UI+dXnzvi1zVeH5lowLxos2YFeTor+tHxF/rB5gnijsvq BpDHnKww35r79vedZ0NDKJBmWiqZCq5Xz9mAPwH3ZIJywUuDY69zi0IhaRRIm14iWnAB +Ybg== 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 l5-v6si10872749pli.375.2018.03.06.01.15.18; Tue, 06 Mar 2018 01:15:32 -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 S1753458AbeCFJM6 (ORCPT + 99 others); Tue, 6 Mar 2018 04:12:58 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:61257 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885AbeCFJMe (ORCPT ); Tue, 6 Mar 2018 04:12:34 -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 5eede14c117de51c; Tue, 6 Mar 2018 10:12:32 +0100 From: "Rafael J. Wysocki" To: Peter Zijlstra , Linux PM Cc: Thomas Gleixner , Frederic Weisbecker , Paul McKenney , Thomas Ilsche , Doug Smythies , Rik van Riel , Aubrey Li , Mike Galbraith , LKML Subject: [RFC/RFT][PATCH v2 3/6] sched: idle: Do not stop the tick before cpuidle_idle_call() Date: Tue, 06 Mar 2018 10:03:16 +0100 Message-ID: <2037426.jsGIfSuYk6@aspire.rjw.lan> In-Reply-To: <2067762.1uWBf5RSRc@aspire.rjw.lan> References: <2067762.1uWBf5RSRc@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, there are code paths in cpuidle_idle_call() that don't need the tick to be stopped. In particular, 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 some governor code with respect to some code in tick_nohz_idle_go_idle(). For this purpose, call tick_nohz_idle_go_idle() in the same branch as cpuidle_select(). Signed-off-by: Rafael J. Wysocki --- -> v2: No changes. --- kernel/sched/idle.c | 17 +++++++++++++---- 1 file changed, 13 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,14 @@ 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_go_idle(false); + rcu_idle_enter(); default_idle_call(); goto exit_idle; } @@ -169,6 +170,9 @@ static void cpuidle_idle_call(void) if (idle_should_enter_s2idle() || dev->use_deepest_state) { if (idle_should_enter_s2idle()) { + tick_nohz_idle_go_idle(false); + rcu_idle_enter(); + entered_state = cpuidle_enter_s2idle(drv, dev); if (entered_state > 0) { local_irq_enable(); @@ -176,9 +180,15 @@ static void cpuidle_idle_call(void) } } + tick_nohz_idle_go_idle(true); + rcu_idle_enter(); + next_state = cpuidle_find_deepest_state(drv, dev); call_cpuidle(drv, dev, next_state); } else { + tick_nohz_idle_go_idle(true); + rcu_idle_enter(); + /* * Ask the cpuidle framework to choose a convenient idle state. */ @@ -248,7 +258,6 @@ static void do_idle(void) tick_nohz_idle_go_idle(false); cpu_idle_poll(); } else { - tick_nohz_idle_go_idle(true); cpuidle_idle_call(); } arch_cpu_idle_exit();