Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1082067pxx; Tue, 27 Oct 2020 07:53:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyavHC9Y/1VB6sX6JPdzPMCqo8pMHSwokPgyglBzdPpvy63axflFVv/n1TiKFUV/c+KCqPr X-Received: by 2002:aa7:c14a:: with SMTP id r10mr2708099edp.345.1603810411848; Tue, 27 Oct 2020 07:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603810411; cv=none; d=google.com; s=arc-20160816; b=bR53I65kjatPgowqc4zn6ZELTY5VGlBkN9iK5p3akOZANPTNF9T4MIRL7Au98ScDQM liqbURF9RFH2VC8X+tfNU08HM0pRHhi21EETs8MoxKWLbTjZp2xyGfD5KirGa+c2Wqdt UqgjiQqHUZDW54NgUxFY4d7HGJW6AQO3MTJfLmwUMbw1FyaUNoSR8eyBlEd5k9lLYsNm XOjodNVzXAtxSlqUlfsb1qOiSXwpTqzTPLgSv22TeGNuWiO7p+M9CANUYVtpb+XeDps7 eGI2ZLrSe98QD2YC5yz0dQ38c7VNp8cUzPJwJBI5k8E8wSf1U2lz3ebyrr/5Fz0yy1Pd 9EHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=4FVHw0e9SUzKx9pLi7k3pNny5RbxCRXgmoDZK2DUReA=; b=pTK8LRKQzqs2KMfryBDJYbcccmGCdZqeaAtifVjeRxWP1eiE8eNGkbY3hnjQX03IUj ypEGcEphfSDhxUMv+ju03XccAJ4mkqhMNMrNxjWq92XCrkv6CihIjp6PbYldnXgV62/v duTO11Kx3hVhf4Q8QCDmIEh+mjDrgZkgD6r1Fk0Fqdr0G8LZ1kgJkR3NJU5+E+y8ubop MU3tC2pt1Jg/QfpiOeaLfhxEnLrAhvmepM+KFGrjtrSOSuUXRigsU1WAYuB6uOPwEmi+ glQXnSd2FmKUmsg2Xe0ko7jliMHTFd8dF5ampZdgvjaDoK+xitSmjtA8XrAlCfCZr3Ao Zw6g== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q28si1011577edw.303.2020.10.27.07.53.06; Tue, 27 Oct 2020 07:53:31 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2900545AbgJ0NOe (ORCPT + 99 others); Tue, 27 Oct 2020 09:14:34 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:46553 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2900528AbgJ0NOd (ORCPT ); Tue, 27 Oct 2020 09:14:33 -0400 Received: by mail-oi1-f193.google.com with SMTP id x1so1185871oic.13; Tue, 27 Oct 2020 06:14:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4FVHw0e9SUzKx9pLi7k3pNny5RbxCRXgmoDZK2DUReA=; b=ASyKqCCKA1Qh+/NJtSoW1fi/BSJCjZRLwjikgqECfyJ8MKEqLBEz85EbC0gjOGObdT 941Hbxb8wfNoEjIbF+8BZXu+TNWyjOySb9U6N1JYFYkawto1YoXBWGbMayj5+ZZRZAnb OYiAUMmRCeJd3lU2xYvF2/ovZKocoifxvsiCL3ywMCIsdAgQmtk4YoFpaZu756VEg28i xKnE12Hn4bSYpnzCHt1VGkC4fc1kwG2S7wspJGparbCOyvdo+J6gItbteaUyL2dgbD3y LjxOAL4V7vodo8US/aWcm9tts3HZeVoQPvhM3nah/KV92gMNlKWodTNXKDVM1QtzKH5O Rg9g== X-Gm-Message-State: AOAM531AJHs+tIJ2z1kQn7gA3pQwEEj1PlvfAjSGbJGtrh6svdx1e6vF VskzML663UQa7r/HVkBifD13B35Zb7B+eUVMC3Q= X-Received: by 2002:aca:30d7:: with SMTP id w206mr1417593oiw.69.1603804472465; Tue, 27 Oct 2020 06:14:32 -0700 (PDT) MIME-Version: 1.0 References: <2183878.gTFULuzKx9@kreacher> <1905098.zDJocX6404@kreacher> <20201027042559.hang4fnpyfd6yqu4@vireshk-i7> In-Reply-To: <20201027042559.hang4fnpyfd6yqu4@vireshk-i7> From: "Rafael J. Wysocki" Date: Tue, 27 Oct 2020 14:14:20 +0100 Message-ID: Subject: Re: [PATCH v2 4/4] cpufreq: schedutil: Always call drvier if need_freq_update is set To: Viresh Kumar Cc: "Rafael J. Wysocki" , Linux PM , LKML , Srinivas Pandruvada , Zhang Rui Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 27, 2020 at 5:26 AM Viresh Kumar wrote: > > 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 ? I didn't think about that, but now that you mentioned it, I think that this is a good idea. Will send an updated patch with that implemented shortly. > 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; Right, but it will be somewhat different anyway. :-)