Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp640322pxu; Fri, 23 Oct 2020 09:34:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBvtVwsWb1o7pIegvfxoXUoW4cXM16Au5qL7J7hy7miSx263kHFbdRaMtpbiRbmvfwWIXW X-Received: by 2002:a05:6402:48d:: with SMTP id k13mr3084417edv.92.1603470884604; Fri, 23 Oct 2020 09:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603470884; cv=none; d=google.com; s=arc-20160816; b=HDJIm3vGVsNiwBrycKTt5Otjsvjc0D5HUrbLEpTGwQ8eHvomId0DmiwvMeEgUBX27F pCKhInXIYvtPGze+IVeSMCgrngpc/0Wu8PJnPV9y1VhZ9o5X5xPZx10FF3Wp+Hwa1qma JGL8cPCHUnR2a1LFNX/blnFB2SBEauWPiXnBB8v+s55+I00zJvimkqrRTqZuLsdhBO70 3clW6OAA0tJEC722ywyBr+xPbYIVT7G/zb1Ri6yvfaRy51lrnHCD2rOjIw7krCUyykWu c/mm1rF8Gb5PNpFIws5sy0aZELb/ohgJs9Pr8mA6l8ttcMC0KbtmC5izQqt++nZu/jjY 9mIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9XIHITrQOCW9eaQxpnzf11bqJyFqR5ZyWLwxyx3NPtI=; b=DrUWx28bWIJVYebLlildrwiHtJm80RtLUQ+98hIvSogrx5O5aRjchOllKjHBYV6Bwe UAY19LBab2CtMrMzDhdt1l4WP5KFdKCJqiOOpBt+rJzMFjJ9zzvyDr20QjzsJ2R3f0ML wmwoxNVWPGliw4YfBzk16NcTw8tTxExmCm8AwMZeGYjdH23/N1LB4xANBIwQSH0Hf2Ig 6oUyN3HcfwSX8ICF+qUc3uJzjHlS0S6MTVBRXHeg3TBLFmvdbAeXzvk4PZ872jMHSYWv gdnABPYXA+inR21Edw5tWdicXVAnl1BZs9eaI1XytiNsYe1ROaI/aP6a+xgXCSwu05Fc C0Rw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oc24si1169033ejb.530.2020.10.23.09.34.22; Fri, 23 Oct 2020 09:34:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S465935AbgJWPgk (ORCPT + 99 others); Fri, 23 Oct 2020 11:36:40 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:49018 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S462626AbgJWPgk (ORCPT ); Fri, 23 Oct 2020 11:36:40 -0400 Received: from 89-64-88-190.dynamic.chello.pl (89.64.88.190) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.491) id caedd8ec897095a1; Fri, 23 Oct 2020 17:36:38 +0200 From: "Rafael J. Wysocki" To: Linux PM , Viresh Kumar Cc: LKML , Srinivas Pandruvada , Zhang Rui Subject: [PATCH v2 4/4] cpufreq: schedutil: Always call drvier if need_freq_update is set Date: Fri, 23 Oct 2020 17:36:05 +0200 Message-ID: <1905098.zDJocX6404@kreacher> In-Reply-To: <2183878.gTFULuzKx9@kreacher> References: <2183878.gTFULuzKx9@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + sg_policy->cached_raw_freq = freq; return cpufreq_driver_resolve_freq(policy, freq); }