From: "zhenglifeng (A)" <zhenglifeng1@huawei.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: <rafael@kernel.org>, <linux-pm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>,
<jonathan.cameron@huawei.com>, <zhanjie9@hisilicon.com>,
<lihuisong@huawei.com>, <fanghao11@huawei.com>
Subject: Re: [PATCH 2/2] cpufreq: Introduce a more generic way to set default per-policy boost flag
Date: Thu, 16 Jan 2025 16:30:36 +0800 [thread overview]
Message-ID: <17c7ed77-21f1-4093-91fc-f3eaa863d312@huawei.com> (raw)
In-Reply-To: <20250116065408.kjifylpgse5f3k3h@vireshk-i7>
On 2025/1/16 14:54, Viresh Kumar wrote:
> On 15-01-25, 18:01, Lifeng Zheng wrote:
>> In cpufreq_online() of cpufreq.c, the per-policy boost flag is already set
>> to mirror the cpufreq_driver boost during init but using freq_table to
>> judge if the policy has boost frequency. There are two drawbacks to this
>> approach:
>>
>> 1. It doesn't work for the cpufreq drivers that do not use a frequency
>> table. For now, acpi-cpufreq and amd-pstate have to enable boost in policy
>> initialization. And cppc_cpufreq never set policy to boost when going
>> online no matter what the cpufreq_driver boost flag is.
>>
>> 2. If the cpu goes offline when cpufreq_driver boost enabled and then goes
>> online when cpufreq_driver boost disabled, the per-policy boost flag will
>> unreasonably remain true.
>
> Yeah, this is a problem. I agree. If the global boost is disabled,
> then boost shouldn't be allowed for any of the policies.
>
>> Running set_boost at the end of the online process is a more generic way
>> for all cpufreq drivers.
>>
>> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
>> ---
>> drivers/cpufreq/cpufreq.c | 16 ++++++++++++----
>> 1 file changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index 03ae879d50b9..867bda3decfd 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -1409,10 +1409,6 @@ static int cpufreq_online(unsigned int cpu)
>> goto out_free_policy;
>> }
>>
>> - /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
>> - if (cpufreq_boost_enabled() && policy_has_boost_freq(policy))
>> - policy->boost_enabled = true;
>> -
>> /*
>> * The initialization has succeeded and the policy is online.
>> * If there is a problem with its frequency table, take it
>> @@ -1576,6 +1572,18 @@ static int cpufreq_online(unsigned int cpu)
>> if (new_policy && cpufreq_thermal_control_enabled(cpufreq_driver))
>> policy->cdev = of_cpufreq_cooling_register(policy);
>>
>> + /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
>> + if (cpufreq_boost_supported()) {
>> + policy->boost_enabled = cpufreq_boost_enabled();
>> + ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
>
> Maybe we can optimize here and not call set_boost() if policy's
> boost_enabled is not changing at all.
> if (policy->boost_enabled != cpufreq_boost_enabled()) {
> policy->boost_enabled = cpufreq_boost_enabled();
> ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
> ...
> }
Makes sense. Thanks.
>
> After this patch, maybe you should simplify the drivers as well, which
> take care of enabling/boost at boot time or setting this flag ?
OK. I'll try to.
>
>> + if (ret) {
>> + /* If the set_boost fails, the online operation is not affected */
>> + pr_info("%s: CPU%d: Cannot %s BOOST\n", __func__, policy->cpu,
>> + policy->boost_enabled ? "enable" : "disable");
>> + policy->boost_enabled = !policy->boost_enabled;
>> + }
>> + }
>> +
>> pr_debug("initialization complete\n");
>>
>> return 0;
>
next prev parent reply other threads:[~2025-01-16 8:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 10:01 [PATCH 0/2] cpufreq: Introduce a more generic way to boost when cpu is going online Lifeng Zheng
2025-01-15 10:01 ` [PATCH 1/2] cpufreq: Fix re-boost issue after hotplugging a cpu Lifeng Zheng
2025-01-15 11:18 ` Viresh Kumar
2025-01-15 12:50 ` Rafael J. Wysocki
2025-01-16 1:51 ` zhenglifeng (A)
2025-01-15 10:01 ` [PATCH 2/2] cpufreq: Introduce a more generic way to set default per-policy boost flag Lifeng Zheng
2025-01-16 6:54 ` Viresh Kumar
2025-01-16 8:30 ` zhenglifeng (A) [this message]
2025-01-15 12:53 ` [PATCH 0/2] cpufreq: Introduce a more generic way to boost when cpu is going online Rafael J. Wysocki
2025-01-16 2:08 ` zhenglifeng (A)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17c7ed77-21f1-4093-91fc-f3eaa863d312@huawei.com \
--to=zhenglifeng1@huawei.com \
--cc=fanghao11@huawei.com \
--cc=jonathan.cameron@huawei.com \
--cc=lihuisong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=rafael@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=zhanjie9@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®