Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1333013pxx; Tue, 27 Oct 2020 14:11:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSY2aNOEii7eJccVfmj9B9g6oZuNU4aQlnYi7/IQkaP54uJ0G60HQzNJ+ml+ryDMw/howN X-Received: by 2002:a17:906:3bc9:: with SMTP id v9mr4287113ejf.340.1603833097676; Tue, 27 Oct 2020 14:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603833097; cv=none; d=google.com; s=arc-20160816; b=YEcqIFTTNDnaRo5hrUKB3XuHCut4EDQYWypL47sx6vGy4MbV7eC3A8K+TyVIylsJri 4dNgR+5v8XDYubN33VjCtSbpuvMgdqOoZFOz8kXRYUSQyRixvB6gZwFeG22cJUit3Wsc 3Kjm9pRgpgyF/bJehCoATcDMtvnw2uzh+NNVB6IFyKvCJl9mh7EZRwM8WaZb/fL+2+F7 ykfbGL2J89jXsHwT4dRcY/sKIzXYhBd4iAmemdXYVa8f4nEnmGbWLssJ8dZKVWX3o4NQ u7XIB0ITSVo5br3EpYTM1OM8RF0en+3FTsiaW2xo+2eNj2BxvJuEvrJdKsdkQeH3tTvS s2DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=q8a1R7APHXz6ZL6IXaQsICKfgqyJPeRktgCx//C+/Ss=; b=QWCWMP+q1Lukvc7qbqnzfV0yKQKEtl3CMAgUnW9Fkt7/dsDE/pPuK7n26k4qZc8nKx Tcg7ahkurHUjyQP0c9ssYsJFIVlHvlAOGec1r7qLyRbeLrqWpacflRjihFOZe6PR8lFI uHo1k8AkwGtytl4J+XpQPfSXz++IDSGVu8aI4WCNEZ7GCHbycwiGVHhE31s58e72Wv7C ySPhYy+iHJ3X4X/r8+v+MrlNV2N+7HtJEzCrUNHs9ZBlrcUXPDC8ddj2bHKdGO5QiwXQ dCWx3nLk/ZfUOpkyYoGQK1Jk2DKtkRYJ7QL/nT0R0KJ2DsZ7Eo0bc4N5Gy+cfglB6BJu qvEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KL+NuJfe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lu11si1901217ejb.49.2020.10.27.14.10.27; Tue, 27 Oct 2020 14:11:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KL+NuJfe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502241AbgJ0E0F (ORCPT + 99 others); Tue, 27 Oct 2020 00:26:05 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:43818 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443683AbgJ0E0F (ORCPT ); Tue, 27 Oct 2020 00:26:05 -0400 Received: by mail-pl1-f194.google.com with SMTP id o9so87210plx.10 for ; Mon, 26 Oct 2020 21:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=q8a1R7APHXz6ZL6IXaQsICKfgqyJPeRktgCx//C+/Ss=; b=KL+NuJfe1pirzhrR+nfUoyaxO2yXPH1uQXQPaV5UwSxCeRIhuE79ubRUDClresUNw4 S2EyapN9q7kGcOkjPIo2kAcI6/9l8TSMph5lrpsgX3XdISyzG5UFd6xrpfJfqTxjDoXX z8NDBKaqg0zqjTLnDyzrH1QIXIkUH2BdOpzTQTNrzyIhqNSqrdPr1907a4IzDUlJ3bkV Rx1IRL27ZvGfJS3bXAjyoHEF3hS9eOMA2zFOqUVENhekPsr7MK/WySJ8rcLugCo4beUL kNrlbI/92UBdNqKs4amVQ/BZWWznuBzGmmEJHkp8p0SFZZEaRztZz+rr5Rwq9PXYTxvn kRGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=q8a1R7APHXz6ZL6IXaQsICKfgqyJPeRktgCx//C+/Ss=; b=Ut1ljXuCCAeDV42lK2xY+K4BZG37k4nnhuVhVqtzTAKXIyCq1KZ5aywKf/Ot1jxkRk aJ++9DMvwxd6fFO3PR07aXqpJhX1G/ukQaaLmDf0cdnvH8VoSLCjG+nsAcGv0yRUOu9e aeTzJdnjdHedCvG/F/mLcVWefV4G2gv7iSrKXo4etF8SyUoMmMgfcsMyEGXUL1gPImtS MFTJn9bBcevqglvXmX5aWq0CxOY+rGe2cyhPHV4wQ2Mb3TefKPMonwgPbnvt+01c1wyR JKl0xjfuaYrs/mzH/v/XDrPIUfaysSXhQUAB88g77PbkCckyLz5M5AgrM29l3uSQ9N/5 Ug1A== X-Gm-Message-State: AOAM531vUHdi5JbJQ4zvnnR0b5NKGYvzmwlEwuINs8LdxRESWCFunswg Q42oT7beaZYGUot2eHAlxjX+Ww== X-Received: by 2002:a17:902:d706:b029:d5:dde6:f56 with SMTP id w6-20020a170902d706b02900d5dde60f56mr634056ply.26.1603772763043; Mon, 26 Oct 2020 21:26:03 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id y3sm325813pfn.167.2020.10.26.21.26.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Oct 2020 21:26:01 -0700 (PDT) Date: Tue, 27 Oct 2020 09:55:59 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: Linux PM , LKML , Srinivas Pandruvada , Zhang Rui Subject: Re: [PATCH v2 4/4] cpufreq: schedutil: Always call drvier if need_freq_update is set Message-ID: <20201027042559.hang4fnpyfd6yqu4@vireshk-i7> References: <2183878.gTFULuzKx9@kreacher> <1905098.zDJocX6404@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1905098.zDJocX6404@kreacher> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Spelling mistake in $subject (driver) On 23-10-20, 17:36, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Because sugov_update_next_freq() may skip a frequency update even if > the need_freq_update flag has been set for the policy at hand, policy > limits updates may not take effect as expected. > > For example, if the intel_pstate driver operates in the passive mode > with HWP enabled, it needs to update the HWP min and max limits when > the policy min and max limits change, respectively, but that may not > happen if the target frequency does not change along with the limit > at hand. In particular, if the policy min is changed first, causing > the target frequency to be adjusted to it, and the policy max limit > is changed later to the same value, the HWP max limit will not be > updated to follow it as expected, because the target frequency is > still equal to the policy min limit and it will not change until > that limit is updated. > > To address this issue, modify get_next_freq() to clear > need_freq_update only if the CPUFREQ_NEED_UPDATE_LIMITS flag is > not set for the cpufreq driver in use (and it should be set for all > potentially affected drivers) and make sugov_update_next_freq() > check need_freq_update and continue when it is set regardless of > whether or not the new target frequency is equal to the old one. > > Fixes: f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode with HWP enabled") > Reported-by: Zhang Rui > Cc: 5.9+ # 5.9+ > Signed-off-by: Rafael J. Wysocki > --- > > New patch in v2. > > --- > kernel/sched/cpufreq_schedutil.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > Index: linux-pm/kernel/sched/cpufreq_schedutil.c > =================================================================== > --- linux-pm.orig/kernel/sched/cpufreq_schedutil.c > +++ linux-pm/kernel/sched/cpufreq_schedutil.c > @@ -102,11 +102,12 @@ static bool sugov_should_update_freq(str > static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time, > unsigned int next_freq) > { > - if (sg_policy->next_freq == next_freq) > + if (sg_policy->next_freq == next_freq && !sg_policy->need_freq_update) > return false; > > sg_policy->next_freq = next_freq; > sg_policy->last_freq_update_time = time; > + sg_policy->need_freq_update = false; > > return true; > } > @@ -164,7 +165,10 @@ static unsigned int get_next_freq(struct > if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) > return sg_policy->next_freq; > > - sg_policy->need_freq_update = false; > + if (sg_policy->need_freq_update) > + sg_policy->need_freq_update = > + cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS); > + The behavior here is a bit different from what we did in cpufreq.c. In cpufreq core we are _always_ allowing the call to reach the driver's target() routine, but here we do it only if limits have changed. Wonder if we should have similar behavior here as well ? Over that the code here can be rewritten a bit like: if (sg_policy->need_freq_update) sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS); else if (freq == sg_policy->cached_raw_freq) return sg_policy->next_freq; -- viresh