From: Pierre Gondois <pierre.gondois@arm.com>
To: "zhenglifeng (A)" <zhenglifeng1@huawei.com>,
linux-kernel@vger.kernel.org
Cc: Jie Zhan <zhanjie9@hisilicon.com>,
Ionela Voinescu <ionela.voinescu@arm.com>,
Sumit Gupta <sumitg@nvidia.com>, Huang Rui <ray.huang@amd.com>,
"Gautham R. Shenoy" <gautham.shenoy@amd.com>,
Mario Limonciello <mario.limonciello@amd.com>,
Perry Yuan <perry.yuan@amd.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Len Brown <lenb@kernel.org>,
Saravana Kannan <saravanak@kernel.org>,
linux-pm@vger.kernel.org
Subject: Re: [PATCH v6 2/4] cpufreq: Add boost_freq_req QoS request
Date: Wed, 18 Mar 2026 08:56:14 +0100 [thread overview]
Message-ID: <7604db81-f012-4faf-b558-2bd7304632e1@arm.com> (raw)
In-Reply-To: <ccc646b2-6af8-48e9-a2d5-9c9b55ae0848@huawei.com>
On 3/18/26 03:50, zhenglifeng (A) wrote:
> On 3/17/2026 6:17 PM, Pierre Gondois wrote:
>> The Power Management Quality of Service (PM QoS) allows to
>> aggregate constraints from multiple entities. It is currently
>> used to manage the min/max frequency of a given policy.
>>
>> Frequency constraints can come for instance from:
>> - Thermal framework: acpi_thermal_cpufreq_init()
>> - Firmware: _PPC objects: acpi_processor_ppc_init()
>> - User: by setting policyX/scaling_[min|max]_freq
>> The minimum of the max frequency constraints is used to compute
>> the resulting maximum allowed frequency.
>>
>> When enabling boost frequencies, the same frequency request object
>> (policy->max_freq_req) as to handle requests from users is used.
>> As a result, when setting:
>> - scaling_max_freq
>> - boost
>> The last sysfs file used overwrites the request from the other
>> sysfs file.
>>
>> To avoid this, create a per-policy boost_freq_req to save the boost
>> constraints instead of overwriting the last scaling_max_freq
>> constraint.
>>
>> policy_set_boost() calls the cpufreq set_boost callback.
>> Update the newly added boost_freq_req request from there:
>> - whenever boost is toggled
>> - to cover all possible paths
>>
>> In the existing .set_boost() callbacks:
>> - Don't update policy->max as this is done through the qos notifier
>> cpufreq_notifier_max() which calls cpufreq_set_policy().
>> - Remove freq_qos_update_request() calls as the qos request is now
>> done in policy_set_boost() and updates the new boost_freq_req
>>
>> $ ## Init state
>> scaling_max_freq:1000000
>> cpuinfo_max_freq:1000000
>>
>> $ echo 700000 > scaling_max_freq
>> scaling_max_freq:700000
>> cpuinfo_max_freq:1000000
>>
>> $ echo 1 > ../boost
>> scaling_max_freq:1200000
>> cpuinfo_max_freq:1200000
>>
>> $ echo 800000 > scaling_max_freq
>> scaling_max_freq:800000
>> cpuinfo_max_freq:1200000
>>
>> $ ## Final step:
>> $ ## Without the patches:
>> $ echo 0 > ../boost
>> scaling_max_freq:1000000
>> cpuinfo_max_freq:1000000
>>
>> $ ## With the patches:
>> $ echo 0 > ../boost
>> scaling_max_freq:800000
>> cpuinfo_max_freq:1000000
>>
>> Note:
>> cpufreq_frequency_table_cpuinfo() updates policy->min
>> and max from:
>> A.
>> cpufreq_boost_set_sw()
>> \-cpufreq_frequency_table_cpuinfo()
>> B.
>> cpufreq_policy_online()
>> \-cpufreq_table_validate_and_sort()
>> \-cpufreq_frequency_table_cpuinfo()
>> Keep these updates as some drivers expect policy->min and
>> max to be set through B.
>>
>> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
>> ---
>> drivers/cpufreq/amd-pstate.c | 2 --
>> drivers/cpufreq/cppc_cpufreq.c | 10 ++-----
>> drivers/cpufreq/cpufreq.c | 52 +++++++++++++++++++++++++++-------
>> include/linux/cpufreq.h | 1 +
>> 4 files changed, 44 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
>> index c45bc98721d24..310d5938cbdf6 100644
>> --- a/drivers/cpufreq/amd-pstate.c
>> +++ b/drivers/cpufreq/amd-pstate.c
>> @@ -756,8 +756,6 @@ static int amd_pstate_cpu_boost_update(struct cpufreq_policy *policy, bool on)
>> else if (policy->cpuinfo.max_freq > nominal_freq)
>> policy->cpuinfo.max_freq = nominal_freq;
>>
>> - policy->max = policy->cpuinfo.max_freq;
>> -
>> if (cppc_state == AMD_PSTATE_PASSIVE) {
>> ret = freq_qos_update_request(&cpudata->req[1], policy->cpuinfo.max_freq);
>> if (ret < 0)
>> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
>> index 9eac77c4f2944..4c46c7ea318eb 100644
>> --- a/drivers/cpufreq/cppc_cpufreq.c
>> +++ b/drivers/cpufreq/cppc_cpufreq.c
>> @@ -775,17 +775,11 @@ static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state)
>> {
>> struct cppc_cpudata *cpu_data = policy->driver_data;
>> struct cppc_perf_caps *caps = &cpu_data->perf_caps;
>> - int ret;
>>
>> if (state)
>> - policy->max = cppc_perf_to_khz(caps, caps->highest_perf);
>> + policy->cpuinfo.max_freq = cppc_perf_to_khz(caps, caps->highest_perf);
>> else
>> - policy->max = cppc_perf_to_khz(caps, caps->nominal_perf);
>> - policy->cpuinfo.max_freq = policy->max;
>> -
>> - ret = freq_qos_update_request(policy->max_freq_req, policy->max);
>> - if (ret < 0)
>> - return ret;
>> + policy->cpuinfo.max_freq = cppc_perf_to_khz(caps, caps->nominal_perf);
>>
>> return 0;
>> }
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index db414c052658b..e4f24754df164 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -603,10 +603,19 @@ static int policy_set_boost(struct cpufreq_policy *policy, bool enable)
>> policy->boost_enabled = enable;
>>
>> ret = cpufreq_driver->set_boost(policy, enable);
>> - if (ret)
>> + if (ret) {
>> policy->boost_enabled = !policy->boost_enabled;
>> + return ret;
>> + }
>>
>> - return ret;
>> + ret = freq_qos_update_request(policy->boost_freq_req, policy->cpuinfo.max_freq);
>> + if (ret < 0) {
>> + policy->boost_enabled = !policy->boost_enabled;
>> + cpufreq_driver->set_boost(policy, policy->boost_enabled);
>> + return ret;
>> + }
>> +
>> + return 0;
>> }
>>
>> static ssize_t store_local_boost(struct cpufreq_policy *policy,
>> @@ -1370,6 +1379,9 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)
>> freq_qos_remove_request(policy->max_freq_req);
>> }
>>
>> + if (policy->boost_freq_req)
>> + freq_qos_remove_request(policy->boost_freq_req);
>> +
>> freq_qos_remove_request(policy->min_freq_req);
>> kfree(policy->min_freq_req);
>>
>> @@ -1439,12 +1451,15 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
>> cpumask_and(policy->cpus, policy->cpus, cpu_online_mask);
>>
>> if (new_policy) {
>> + unsigned int req_nr;
>> +
>> for_each_cpu(j, policy->related_cpus) {
>> per_cpu(cpufreq_cpu_data, j) = policy;
>> add_cpu_dev_symlink(policy, j, get_cpu_device(j));
>> }
>>
>> - policy->min_freq_req = kzalloc(2 * sizeof(*policy->min_freq_req),
>> + req_nr = policy->boost_supported ? 3 : 2;
>> + policy->min_freq_req = kzalloc(req_nr * sizeof(*policy->min_freq_req),
>> GFP_KERNEL);
>> if (!policy->min_freq_req) {
>> ret = -ENOMEM;
>> @@ -1479,6 +1494,27 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
>> goto out_destroy_policy;
>> }
>>
>> + if (policy->boost_supported) {
>> + policy->boost_freq_req = policy->max_freq_req + 1;
>> +
>> + /*
>> + * If boost is supported,
>> + * init the constraint with cpuinfo.max_freq.
>> + */
>> + ret = freq_qos_add_request(&policy->constraints,
>> + policy->boost_freq_req,
>> + FREQ_QOS_MAX,
>> + policy->cpuinfo.max_freq);
>> + if (ret < 0) {
>> + /*
>> + * So we don't call freq_qos_remove_request() for an
>> + * uninitialized request.
>> + */
>> + policy->boost_freq_req = NULL;
>> + goto out_destroy_policy;
>> + }
>> + }
>> +
> Something we discussed before has resurfaced here. CPUFREQ_REMOVE_POLICY
> notification will be sent without sending CPUFREQ_CREATE_POLICY
> notification before if adding boost_freq_req fails.
>
> What about adding boost_freq_req before adding min_freq_req and removing it
> after removing min_freq_req?
Yes right, this is indeed what Rafael suggested looking back at the
messages.
I ll wait a bit before submitting a correction.
>
>> blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
>> CPUFREQ_CREATE_POLICY, policy);
>> }
>> @@ -2782,16 +2818,10 @@ int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
>> return -ENXIO;
>>
>> ret = cpufreq_frequency_table_cpuinfo(policy);
>> - if (ret) {
>> + if (ret)
>> pr_err("%s: Policy frequency update failed\n", __func__);
>> - return ret;
>> - }
>> -
>> - ret = freq_qos_update_request(policy->max_freq_req, policy->max);
>> - if (ret < 0)
>> - return ret;
>>
>> - return 0;
>> + return ret;
>> }
>> EXPORT_SYMBOL_GPL(cpufreq_boost_set_sw);
>>
>> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
>> index 0465d1e6f72ac..c292a6a19e4f5 100644
>> --- a/include/linux/cpufreq.h
>> +++ b/include/linux/cpufreq.h
>> @@ -81,6 +81,7 @@ struct cpufreq_policy {
>> struct freq_constraints constraints;
>> struct freq_qos_request *min_freq_req;
>> struct freq_qos_request *max_freq_req;
>> + struct freq_qos_request *boost_freq_req;
>>
>> struct cpufreq_frequency_table *freq_table;
>> enum cpufreq_table_sorting freq_table_sorted;
next prev parent reply other threads:[~2026-03-18 7:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 10:17 [PATCH v6 0/4] cpufreq: Introduce boost frequency QoS Pierre Gondois
2026-03-17 10:17 ` [PATCH v6 1/4] cpufreq: Remove per-CPU QoS constraint Pierre Gondois
2026-03-18 11:13 ` Viresh Kumar
2026-03-19 9:30 ` Pierre Gondois
2026-03-20 9:18 ` Viresh Kumar
2026-03-20 9:25 ` Viresh Kumar
2026-03-24 11:39 ` Pierre Gondois
2026-03-25 6:28 ` Viresh Kumar
2026-03-20 10:04 ` zhenglifeng (A)
2026-03-17 10:17 ` [PATCH v6 2/4] cpufreq: Add boost_freq_req QoS request Pierre Gondois
2026-03-18 2:50 ` zhenglifeng (A)
2026-03-18 7:56 ` Pierre Gondois [this message]
2026-03-17 10:17 ` [PATCH v6 3/4] cpufreq: Set policy->min and max as real QoS constraints Pierre Gondois
2026-03-20 10:14 ` Viresh Kumar
2026-03-24 11:40 ` Pierre Gondois
2026-03-25 6:49 ` Viresh Kumar
2026-03-25 16:54 ` Pierre Gondois
2026-03-26 4:26 ` Viresh Kumar
2026-03-17 10:17 ` [RFC PATCH v6 4/4] cpufreq/freq_table: Allow decreasing cpuinfo.max_freq Pierre Gondois
2026-03-20 10:58 ` Viresh Kumar
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=7604db81-f012-4faf-b558-2bd7304632e1@arm.com \
--to=pierre.gondois@arm.com \
--cc=gautham.shenoy@amd.com \
--cc=ionela.voinescu@arm.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=perry.yuan@amd.com \
--cc=rafael@kernel.org \
--cc=ray.huang@amd.com \
--cc=saravanak@kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=sumitg@nvidia.com \
--cc=viresh.kumar@linaro.org \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.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