Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4836659imm; Tue, 21 Aug 2018 01:40:06 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwnxZ7l/Suva5ppGEj1ZfY2mx3zQbm3b75z55Cws24bi43FbKjpiVrrtWJ4zXfRyYOqCagG X-Received: by 2002:a62:4083:: with SMTP id f3-v6mr52194412pfd.229.1534840806516; Tue, 21 Aug 2018 01:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534840806; cv=none; d=google.com; s=arc-20160816; b=AZYAPEQf7RET4uBJYtBB4YVlXJLN3mTsL/Uy/U6z9WHrY9VQZTi5hTSoidxqih1Ggc dsMXWjD3iEDlUmIiXEC6N9woBLK9S+oh6Jeq1lpky2J3QbgG7gJHOoea4wdM0CVan7Me U+aA82VjgPEdhF9WhBHG3XaF6vWqPbeK+pTBDZzCNBKER5nX6qS7efdBgLEYAjgWbImW mV84TL2zXcVqsNQjW4NgO7KV0GqCSCfvkhOkJT5oZd5zXMvfwjIb5KYA02nMtds/eGpl 1HV9YQevKiJv8rNVec1Ma3DSxg/5uE+uhYk9VQKw1VBngG44U2WBXxBKBV85YKiPoQ7U bFgw== 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=zPEstGJSuH+Wamlo71XgjPmoVW2OjAsHGFCUqgTlh/0=; b=kWu+aLWk3owo5lSnbd5zBM1lwQHFwc0ujFXe2sqvjmKv7Dx9MBIZP4Cx6fEad63uRK MKoz8RmSp4ysM5s2IJwoYFjXOASyC4h9BqVqoh4gdWvEg1ytEC16EOzmDDInGeNuBOR3 WT9K2NM4/vUfUleeUXykZq8LTdae6LfXIri2uiGUx/FS12WkifAcDTFbZPwD51F9i9pJ S2PwjOVmtHM6B4VML7Mx4RLDSkd0T5J2UNDIwUBcdhyewhj2BMgKMGwyw6ckkkJskWm+ Dl33dvlN5xMOH6vK2S+9BY73UePaLD925aIkqjZxv+EaD+U/Tm+LqXGTtAyHpYlWxzCN DpDQ== 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 o188-v6si9805040pga.132.2018.08.21.01.39.51; Tue, 21 Aug 2018 01:40:06 -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 S1726881AbeHUL4z (ORCPT + 99 others); Tue, 21 Aug 2018 07:56:55 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:49258 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726536AbeHUL4y (ORCPT ); Tue, 21 Aug 2018 07:56:54 -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) id 015ee626f3aea79a; Tue, 21 Aug 2018 10:37:40 +0200 From: "Rafael J. Wysocki" To: Leo Yan Cc: "Rafael J. Wysocki" , "Peter Zijlstra (Intel)" , Daniel Lezcano , Vincent Guittot , Ramesh Thomas , linux-kernel@vger.kernel.org, Linux PM Subject: Re: [PATCH v1 4/5] cpuidle: menu: Don't stay in shallow state for a long time Date: Tue, 21 Aug 2018 10:35:23 +0200 Message-ID: <7779444.DV2K5n5ugl@aspire.rjw.lan> In-Reply-To: <1534090171-14464-5-git-send-email-leo.yan@linaro.org> References: <1534090171-14464-1-git-send-email-leo.yan@linaro.org> <1534090171-14464-5-git-send-email-leo.yan@linaro.org> 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 Sunday, August 12, 2018 6:09:30 PM CEST Leo Yan wrote: > To avoid staying in a shallow state for a long time, the menu governor > relies on not stopping tick when detects the prediction is shorter than > the tick event. This is just luckily to cover most cases but cannot say > it is completely safe. For example, if the prediction is 2000us and the > TICK_USEC=1000 so it's impossible to meet the condition > 'data->predicted_us < TICK_USEC' and this lead to stop the tick for a > shallow state; finally the CPU is possible to stay in this shallow state > for very long time. > > This patch checks the candidate idle state isn't deepest one and find if > the timer will come after more than 2 times of the maximum target > residency, though the governor selects a shallow state according to > prediction, due the timer is most reliable waken up source but it will > come very late, so the CPU has chance to stay in the shallow state > for a long time; the patch doesn't stop the tick for this case so can > avoid powernightmares issue. > > Signed-off-by: Leo Yan > --- > drivers/cpuidle/governors/menu.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c > index 4f02207..566c65c 100644 > --- a/drivers/cpuidle/governors/menu.c > +++ b/drivers/cpuidle/governors/menu.c > @@ -284,6 +284,10 @@ static unsigned int get_typical_interval(struct menu_device *data) > static bool menu_decide_stopping_tick(struct cpuidle_driver *drv, > struct menu_device *data, int idx) > { > + int max_target_residency; > + > + max_target_residency = drv->states[drv->state_count-1].target_residency; But this state may be disabled, may it not? Thanks, Rafael