Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2640237imm; Fri, 24 Aug 2018 02:47:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYZznF33yugnowsPT2GMFcmwHO7V/45xkjNABH3AH4hKlzB3RtnjOIN8ZbO5/sbzG2ivwax X-Received: by 2002:a63:5fc8:: with SMTP id t191-v6mr960477pgb.183.1535104063983; Fri, 24 Aug 2018 02:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535104063; cv=none; d=google.com; s=arc-20160816; b=spiKmtGWOzDg6Rz8o63HJ6cMmRhn9rzhchBjpSWrPFc5MBXskSJ5SY7OgxWwxMErJu 0ME2focR0/51O5xSQML8UKQnN8QCqWhHpekwpKP444EQpTZE1mO5BG5znO0ne2osRWnt gXbbxf6yachBFi8H2gt6JVdo8rJiJQM509r1CMfOHZMuJBIcrljzsoxooIpNo/a8dmpd uMxHQ7MA0iXFkgNPTdiFGyHuxb0K/tL8N2jb2cxwjPDULsYLleZzwyk3B6IXzjSQMVrl 4n2cXH/MspHFO22iMMJ9oG65FrDtCA596QoJ6wnBVtqRyYFafF3/IF8KgxcnwCTAgrcP /LIA== 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=avLiXo8ZcdgMJ9DKNzV3nQoP5j31uABo5tWU30eIpz8=; b=XZGfPD4h8r/mTkcU26JRS/yd4MDCkz4lC1OVgOVXSjBvdghxnngzD7kudvAHPWmOs5 hvwDmROZjJmI05qOQ7A2zHqIWYt8y9yNC5N+bg3G1UNHa5EfDvgur3JmJErPPuT3lQ5q X2gjSkJeQAGoVG0X/huBVfw8v1AwMk3hn9i0ESHorsw47+wgglobJfcquBWVDPt95SKh JCP1ThcblZy8y8E33SNxtEi3xNc3cPi5a0W0av3QumqMvFVE9gIe6L1xuaaF31mAVEPw J4+84cRRotg7jBZKWq6UaYpsC+9DQggL9WeZjVRYHxPvvZFwSPlebLZvahiqU5kAXmi4 pE5w== 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 g6-v6si5850795plp.225.2018.08.24.02.47.27; Fri, 24 Aug 2018 02:47:43 -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 S1726860AbeHXNUO (ORCPT + 99 others); Fri, 24 Aug 2018 09:20:14 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:56038 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726382AbeHXNUO (ORCPT ); Fri, 24 Aug 2018 09:20:14 -0400 Received: from 79.184.253.33.ipv4.supernova.orange.pl (79.184.253.33) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.123) id d0a237f65705f1cf; Fri, 24 Aug 2018 11:46:21 +0200 From: "Rafael J. Wysocki" To: Linux PM , Peter Zijlstra Cc: LKML , Leo Yan , Daniel Lezcano , Frederic Weisbecker Subject: Re: [PATCH] cpuidle: menu: Retain tick when shallow state is selected Date: Fri, 24 Aug 2018 11:44:02 +0200 Message-ID: <13956743.2LRLzEsQXl@aspire.rjw.lan> In-Reply-To: <34910476.pgRhNDWo5t@aspire.rjw.lan> References: <34910476.pgRhNDWo5t@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 On Tuesday, August 21, 2018 10:44:10 AM CEST Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > The case addressed by commit 5ef499cd571c (cpuidle: menu: Handle > stopped tick more aggressively) in the stopped tick case is present > when the tick has not been stopped yet too. Namely, if only two CPU > idle states, shallow state A with target residency significantly > below the tick boundary and deep state B with target residency > significantly above it, are available and the predicted idle > duration is above the tick boundary, but below the target residency > of state B, state A will be selected and the CPU may spend indefinite > amount of time in it, which is not quite energy-efficient. > > However, if the tick has not been stopped yet and the governor is > about to select a shallow idle state for the CPU even though the idle > duration predicted by it is above the tick boundary, it should be > fine to wake up the CPU early, so the tick can be retained then and > the governor will have a chance to select a deeper state when it runs > next time. > > [Note that when this really happens, it will make the idle duration > predictor believe that the CPU might be idle longer than predicted, > which will make it more likely to predict longer idle durations going > forward, but that will also cause deeper idle states to be selected > going forward, on average, which is what's needed here.] > > Fixes: 87c9fe6ee495 (cpuidle: menu: Avoid selecting shallow states with stopped tick) > Reported-by: Leo Yan > Signed-off-by: Rafael J. Wysocki > --- > > Commit 5ef499cd571c (cpuidle: menu: Handle stopped tick more aggressively) is > in linux-next only at this point. > > --- > drivers/cpuidle/governors/menu.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > Index: linux-pm/drivers/cpuidle/governors/menu.c > =================================================================== > --- linux-pm.orig/drivers/cpuidle/governors/menu.c > +++ linux-pm/drivers/cpuidle/governors/menu.c > @@ -379,9 +379,20 @@ static int menu_select(struct cpuidle_dr > if (idx == -1) > idx = i; /* first enabled state */ > if (s->target_residency > data->predicted_us) { > - if (!tick_nohz_tick_stopped()) > + if (data->predicted_us < TICK_USEC) > break; > > + if (!tick_nohz_tick_stopped()) { > + /* > + * If the state selected so far is shallow, > + * waking up early won't hurt, so retain the > + * tick in that case and let the governor run > + * again in the next iteration of the loop. > + */ > + expected_interval = drv->states[idx].target_residency; > + break; > + } > + > /* > * If the state selected so far is shallow and this > * state's target residency matches the time till the > > Due to the lack of objections, I'm inclined to queue this up.