Message ID | 20231025080910.3245690-1-zengheng4@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2437501vqx; Wed, 25 Oct 2023 01:04:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCBr5YwjFG87U/EzgmxmBp/zN4cQnVhsUPQJOwifeYW+clEB+JOTlqQf/kFXApJOrwJuGh X-Received: by 2002:a81:7354:0:b0:5a8:1973:190a with SMTP id o81-20020a817354000000b005a81973190amr15886913ywc.8.1698221069293; Wed, 25 Oct 2023 01:04:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698221069; cv=none; d=google.com; s=arc-20160816; b=kxmBEy4tD1u48qI54gppZdTW2DbOd/vuWuceK+SAJpGoEGbaAin9KjBusObGg68Hdn IWO/jI0xgP1wnMVzPxUqT91K0KqjlykkvYp/iCB1uPlcpPZVL+iYYtUS7jPQb5+O/gN1 rtY4vyhQjrF/2obNpHQHrm3wzJHDzDeRCfCCde0WBKuAn2GBCxaBfo++Qz/JRzcSwZle hgOYlyQHPfaK/1XMrGBXsHLfCwjswSUgrw/LwDi7+SETHl/EqJD91YhlyhAtXUwwjE7x DrvojGJ7wLNH5tc2t1Sjq0OwuvOVLPtsrsCEh+FHOsom0nCQV1OHzMjrlLvrJAeK31WS jwgA== 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 :message-id:date:subject:cc:to:from; bh=5II+uijaAeV6oQBEYKu1kcTbVmT1A8zxC2lYAbWfLO0=; fh=MYfFq4YKRVoxHbYtHwKcL4PUsm8X46gdY0vH8QGcX6c=; b=Py98GHJi9cuy0wiLzDdWOPYiiaoyf0ypgbGyFte7mD1Azb4ly9VRF7cSHFjjZKoLYr +RJe1c4ypXmGYNhaE4WV/92pgn1yKLwfCgCv0XEFcC21urLrxa3X5USFKgAKVQjoc9gx Z8KFomOOcF1RctLeUDT4mPyoFTtDqlRLoUf/8leFRXysjVy2yV+IPouGJHQhNt8Abh8K 8A4nGnZt9un1tdqXdAg2Xce8aPcsOrJVKQKzxrbZG9WC1u7MILnzvdZap/xY3vqc4qAw /4voJAtfPUNq1RYw+cXHChxPTd+hZwhqGzb4KDBztTGHezZDlfXhVOpnY8eh7oyU/zxp 56qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id j65-20020a0de044000000b005a210c4511dsi10424498ywe.488.2023.10.25.01.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 01:04:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id C267F8020DB4; Wed, 25 Oct 2023 01:04:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234359AbjJYIER (ORCPT <rfc822;aposhian.dev@gmail.com> + 26 others); Wed, 25 Oct 2023 04:04:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234253AbjJYIEM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 25 Oct 2023 04:04:12 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1047B137; Wed, 25 Oct 2023 01:04:09 -0700 (PDT) Received: from kwepemi500024.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SFhDH0G2YzNpYd; Wed, 25 Oct 2023 15:59:59 +0800 (CST) Received: from huawei.com (10.175.103.91) by kwepemi500024.china.huawei.com (7.221.188.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 25 Oct 2023 16:04:01 +0800 From: Zeng Heng <zengheng4@huawei.com> To: <viresh.kumar@linaro.org>, <rafael@kernel.org> CC: <liwei391@huawei.com>, <linux-pm@vger.kernel.org>, <xiexiuqi@huawei.com>, <wangxiongfeng2@huawei.com>, <linux-kernel@vger.kernel.org> Subject: [PATCH -next] cpufreq: userspace: Keep the current frequency when set userspace policy Date: Wed, 25 Oct 2023 16:09:10 +0800 Message-ID: <20231025080910.3245690-1-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500024.china.huawei.com (7.221.188.100) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 25 Oct 2023 01:04:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780713855675875388 X-GMAIL-MSGID: 1780713855675875388 |
Series |
[-next] cpufreq: userspace: Keep the current frequency when set userspace policy
|
|
Commit Message
Zeng Heng
Oct. 25, 2023, 8:09 a.m. UTC
When switching to the userspace policy, if the current frequency is within
the range of policy's min and max values, the current frequency value
should be remained. The .limit() function is called when changing governor
or updating governor limits, so in both cases, there is no need to update
frequency if the current frequency does not exceed the threshold.
Additionally, when changing to userspace governor, the default value of
set_speed is set by reading the current frequency of the CPU, but there
is inevitable error between the frequency coming from .get_rate() interface
and the actual working frequency. Consequently, when switching to userspace
policy, keeping the current frequency can avoid unexpected changes.
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
---
drivers/cpufreq/cpufreq_userspace.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
--
2.25.1
Comments
On 25-10-23, 16:09, Zeng Heng wrote: > When switching to the userspace policy, if the current frequency is within > the range of policy's min and max values, the current frequency value > should be remained. The .limit() function is called when changing governor > or updating governor limits, so in both cases, there is no need to update > frequency if the current frequency does not exceed the threshold. > > Additionally, when changing to userspace governor, the default value of > set_speed is set by reading the current frequency of the CPU, but there > is inevitable error between the frequency coming from .get_rate() interface > and the actual working frequency. Consequently, when switching to userspace > policy, keeping the current frequency can avoid unexpected changes. > > Signed-off-by: Zeng Heng <zengheng4@huawei.com> > --- > drivers/cpufreq/cpufreq_userspace.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c > index 2c42fee76daa..fe55a7bb663c 100644 > --- a/drivers/cpufreq/cpufreq_userspace.c > +++ b/drivers/cpufreq/cpufreq_userspace.c > @@ -117,9 +117,7 @@ static void cpufreq_userspace_policy_limits(struct cpufreq_policy *policy) > else if (policy->min > userspace->setspeed) > __cpufreq_driver_target(policy, policy->min, > CPUFREQ_RELATION_L); > - else > - __cpufreq_driver_target(policy, userspace->setspeed, > - CPUFREQ_RELATION_L); > + /* Otherwise, keep the current frequency. */ > > mutex_unlock(&userspace->mutex); > } Here is some reasoning why it should be done the way it is: commit e43e94c1eda7 ("cpufreq: Fix GOV_LIMITS handling for the userspace governor")
在 2023/10/25 19:18, Viresh Kumar 写道: > On 25-10-23, 16:09, Zeng Heng wrote: >> When switching to the userspace policy, if the current frequency is within >> the range of policy's min and max values, the current frequency value >> should be remained. The .limit() function is called when changing governor >> or updating governor limits, so in both cases, there is no need to update >> frequency if the current frequency does not exceed the threshold. >> >> Additionally, when changing to userspace governor, the default value of >> set_speed is set by reading the current frequency of the CPU, but there >> is inevitable error between the frequency coming from .get_rate() interface >> and the actual working frequency. Consequently, when switching to userspace >> policy, keeping the current frequency can avoid unexpected changes. >> >> Signed-off-by: Zeng Heng <zengheng4@huawei.com> >> --- >> drivers/cpufreq/cpufreq_userspace.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c >> index 2c42fee76daa..fe55a7bb663c 100644 >> --- a/drivers/cpufreq/cpufreq_userspace.c >> +++ b/drivers/cpufreq/cpufreq_userspace.c >> @@ -117,9 +117,7 @@ static void cpufreq_userspace_policy_limits(struct cpufreq_policy *policy) >> else if (policy->min > userspace->setspeed) >> __cpufreq_driver_target(policy, policy->min, >> CPUFREQ_RELATION_L); >> - else >> - __cpufreq_driver_target(policy, userspace->setspeed, >> - CPUFREQ_RELATION_L); >> + /* Otherwise, keep the current frequency. */ >> >> mutex_unlock(&userspace->mutex); >> } > Here is some reasoning why it should be done the way it is: > > commit e43e94c1eda7 ("cpufreq: Fix GOV_LIMITS handling for the userspace governor") Get it, thanks for the response. Zeng Heng
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index 2c42fee76daa..fe55a7bb663c 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c @@ -117,9 +117,7 @@ static void cpufreq_userspace_policy_limits(struct cpufreq_policy *policy) else if (policy->min > userspace->setspeed) __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); - else - __cpufreq_driver_target(policy, userspace->setspeed, - CPUFREQ_RELATION_L); + /* Otherwise, keep the current frequency. */ mutex_unlock(&userspace->mutex); }