* [RFC PATCH] cpufreq: Keep global boost enabled after partial enable
@ 2026-11-26 11:08 Jiangtian Feng
2026-11-26 15:07 ` Christian Loehle
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Jiangtian Feng @ 2026-11-26 11:08 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar
Cc: linux-pm, linux-kernel, Christian Loehle, Ananthu C V,
Pierre Gondois, Jiangtian Feng
When global boost is enabled from the disabled state, a failure after
one or more policies have been updated successfully currently restores
the global flag to 0 without rolling back those policies. This leaves
them locally enabled, with their boost-related driver/QoS updates
retained, while the global flag rejects per-policy sysfs writes.
Keep the global flag enabled if at least one policy_set_boost() call
succeeded, while preserving the existing error return path. Global
boost = 1 grants permission to boost; it does not require every policy
to have boost enabled. The mixed per-policy state is therefore valid
and individual policies remain accessible through per-policy sysfs.
Retain global-state restoration for enable failures without a
successful policy update, same-state resynchronization failures, and
disable failures. Do not roll back earlier policy updates.
Qoder, an AI coding assistant, helped analyze the issue, develop the fix
and state matrix, and draft this description.
Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost")
Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
---
Validation:
- mainline ARM64 defconfig build of the complete Image
- checkpatch.pl
- eight-case old-global/request/success state matrix
- independent static control-flow and locking review
NOT_RUN:
- runtime fault injection or reproduction with multiple policies
- global/local concurrency, hotplug, lockdep or KCSAN testing
- CPPC, SW frequency-table, ACPI or AMD hardware frequency/QoS testing
drivers/cpufreq/cpufreq.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 4332cb114070..f23b64c2e620 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
struct cpufreq_policy *policy;
unsigned long flags;
bool boost_enabled;
+ bool policy_success = false;
int ret = -EOPNOTSUPP;
guard(mutex)(&cpufreq_boost_mutex);
@@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state)
ret = policy_set_boost(policy, state);
if (unlikely(ret))
break;
+
+ policy_success = true;
}
cpus_read_unlock();
@@ -2918,10 +2921,15 @@ static int cpufreq_boost_trigger_state(int state)
if (likely(!ret))
return 0;
+ /* Keep partial enable usable and repairable through local sysfs. */
+ if (state && !boost_enabled && policy_success)
+ goto out_err;
+
write_lock_irqsave(&cpufreq_driver_lock, flags);
cpufreq_driver->boost_enabled = boost_enabled;
write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+out_err:
pr_err("%s: Cannot %s BOOST\n",
__func__, str_enable_disable(state));
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] cpufreq: Keep global boost enabled after partial enable
2026-11-26 11:08 [RFC PATCH] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
@ 2026-11-26 15:07 ` Christian Loehle
2026-11-27 5:59 ` Jiangtian Feng
2026-11-26 15:09 ` Zhongqiu Han
2026-11-27 1:49 ` [RFC PATCH v2] " Jiangtian Feng
2 siblings, 1 reply; 10+ messages in thread
From: Christian Loehle @ 2026-11-26 15:07 UTC (permalink / raw)
To: Jiangtian Feng, Rafael J . Wysocki, Viresh Kumar
Cc: linux-pm, linux-kernel, Ananthu C V, Pierre Gondois
On 11/26/26 11:08, Jiangtian Feng wrote:
> When global boost is enabled from the disabled state, a failure after
> one or more policies have been updated successfully currently restores
> the global flag to 0 without rolling back those policies. This leaves
> them locally enabled, with their boost-related driver/QoS updates
> retained, while the global flag rejects per-policy sysfs writes.
>
> Keep the global flag enabled if at least one policy_set_boost() call
> succeeded, while preserving the existing error return path. Global
> boost = 1 grants permission to boost; it does not require every policy
> to have boost enabled. The mixed per-policy state is therefore valid
> and individual policies remain accessible through per-policy sysfs.
>
> Retain global-state restoration for enable failures without a
> successful policy update, same-state resynchronization failures, and
> disable failures. Do not roll back earlier policy updates.
>
> Qoder, an AI coding assistant, helped analyze the issue, develop the fix
> and state matrix, and draft this description.
>
> Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost")
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
What's the RFC part for specifically?
FWIW I broadly agree with the direction of that patch.
> ---
>
> Validation:
> - mainline ARM64 defconfig build of the complete Image
> - checkpatch.pl
> - eight-case old-global/request/success state matrix
> - independent static control-flow and locking review
>
> NOT_RUN:
> - runtime fault injection or reproduction with multiple policies
> - global/local concurrency, hotplug, lockdep or KCSAN testing
> - CPPC, SW frequency-table, ACPI or AMD hardware frequency/QoS testing
>
> drivers/cpufreq/cpufreq.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 4332cb114070..f23b64c2e620 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
> struct cpufreq_policy *policy;
> unsigned long flags;
> bool boost_enabled;
> + bool policy_success = false;
> int ret = -EOPNOTSUPP;
>
> guard(mutex)(&cpufreq_boost_mutex);
> @@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state)
> ret = policy_set_boost(policy, state);
> if (unlikely(ret))
> break;
> +
> + policy_success = true;
> }
>
> cpus_read_unlock();
> @@ -2918,10 +2921,15 @@ static int cpufreq_boost_trigger_state(int state)
> if (likely(!ret))
> return 0;
>
> + /* Keep partial enable usable and repairable through local sysfs. */
> + if (state && !boost_enabled && policy_success)
> + goto out_err;
> +
> write_lock_irqsave(&cpufreq_driver_lock, flags);
> cpufreq_driver->boost_enabled = boost_enabled;
> write_unlock_irqrestore(&cpufreq_driver_lock, flags);
>
> +out_err:
> pr_err("%s: Cannot %s BOOST\n",
> __func__, str_enable_disable(state));
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] cpufreq: Keep global boost enabled after partial enable
2026-11-26 11:08 [RFC PATCH] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-11-26 15:07 ` Christian Loehle
@ 2026-11-26 15:09 ` Zhongqiu Han
2026-11-27 5:59 ` Jiangtian Feng
2026-11-27 1:49 ` [RFC PATCH v2] " Jiangtian Feng
2 siblings, 1 reply; 10+ messages in thread
From: Zhongqiu Han @ 2026-11-26 15:09 UTC (permalink / raw)
To: Jiangtian Feng, Rafael J . Wysocki, Viresh Kumar
Cc: linux-pm, linux-kernel, Christian Loehle, Ananthu C V,
Pierre Gondois, Zhongqiu Han
On 11/26/2026 7:08 PM, Jiangtian Feng wrote:
> When global boost is enabled from the disabled state, a failure after
> one or more policies have been updated successfully currently restores
> the global flag to 0 without rolling back those policies. This leaves
> them locally enabled, with their boost-related driver/QoS updates
> retained, while the global flag rejects per-policy sysfs writes.
>
> Keep the global flag enabled if at least one policy_set_boost() call
> succeeded, while preserving the existing error return path. Global
> boost = 1 grants permission to boost; it does not require every policy
> to have boost enabled. The mixed per-policy state is therefore valid
Yeah, it is a real issue, global boost "only means a permission to use
the frequency boost mechanism" (cpufreq.rst), and "per-policy boost can
then be enabled or disabled individually" while "disabling global boost
makes the per-policy boost interface illegal" (commit 218a06a79d9a).
> and individual policies remain accessible through per-policy sysfs.
>
> Retain global-state restoration for enable failures without a
> successful policy update, same-state resynchronization failures, and
> disable failures. Do not roll back earlier policy updates.
>
> Qoder, an AI coding assistant, helped analyze the issue, develop the fix
> and state matrix, and draft this description.
>
> Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost")
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
> ---
>
> Validation:
> - mainline ARM64 defconfig build of the complete Image
> - checkpatch.pl
> - eight-case old-global/request/success state matrix
> - independent static control-flow and locking review
>
> NOT_RUN:
> - runtime fault injection or reproduction with multiple policies
> - global/local concurrency, hotplug, lockdep or KCSAN testing
> - CPPC, SW frequency-table, ACPI or AMD hardware frequency/QoS testing
>
> drivers/cpufreq/cpufreq.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 4332cb114070..f23b64c2e620 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
> struct cpufreq_policy *policy;
> unsigned long flags;
> bool boost_enabled;
> + bool policy_success = false;
> int ret = -EOPNOTSUPP;
>
> guard(mutex)(&cpufreq_boost_mutex);
> @@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state)
> ret = policy_set_boost(policy, state);
> if (unlikely(ret))
> break;
> +
> + policy_success = true;
> }
>
> cpus_read_unlock();
> @@ -2918,10 +2921,15 @@ static int cpufreq_boost_trigger_state(int state)
> if (likely(!ret))
> return 0;
>
> + /* Keep partial enable usable and repairable through local sysfs. */
> + if (state && !boost_enabled && policy_success)
> + goto out_err;
This function uses guard(), and cleanup.h says "usage of "goto" and
cleanup helpers is never mixed in the same function".
Besides, the !boost_enabled check is redundant, right? so maybe:
if (!state || !policy_success) {
write_lock_irqsave(&cpufreq_driver_lock, flags);
cpufreq_driver->boost_enabled = boost_enabled;
write_unlock_irqrestore(&cpufreq_driver_lock, flags);
}
> +
> write_lock_irqsave(&cpufreq_driver_lock, flags);
> cpufreq_driver->boost_enabled = boost_enabled;
> write_unlock_irqrestore(&cpufreq_driver_lock, flags);
>
> +out_err:
> pr_err("%s: Cannot %s BOOST\n",
> __func__, str_enable_disable(state));
>
Separately, the disable side can end up in a similar state: if global
boost is already 0 and a resync write of 0 fails on some policy, that
policy stays boosted under global boost = 0. That's outside the scope
of this patch, though.
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC PATCH v2] cpufreq: Keep global boost enabled after partial enable
2026-11-26 11:08 [RFC PATCH] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-11-26 15:07 ` Christian Loehle
2026-11-26 15:09 ` Zhongqiu Han
@ 2026-11-27 1:49 ` Jiangtian Feng
2026-11-27 3:41 ` Zhongqiu Han
2026-11-27 6:03 ` [RFC PATCH v3] " Jiangtian Feng
2 siblings, 2 replies; 10+ messages in thread
From: Jiangtian Feng @ 2026-11-27 1:49 UTC (permalink / raw)
To: rafael, viresh.kumar
Cc: linux-pm, linux-kernel, christian.loehle, ananthu.cv,
pierre.gondois, zhongqiu.han, jiangtianfeng
When global boost is enabled from the disabled state, a failure after
one or more policies have been updated successfully currently restores
the global flag to 0 without rolling back those policies. This leaves
them locally enabled, with their boost-related driver/QoS updates
retained, while the global flag rejects per-policy sysfs writes.
Keep the global flag enabled if at least one policy_set_boost() call
succeeded, while preserving the existing error return path. Global
boost = 1 grants permission to boost; it does not require every policy
to have boost enabled. The mixed per-policy state is therefore valid
and individual policies remain accessible through per-policy sysfs.
Retain global-state restoration for enable failures without a
successful policy update, same-state resynchronization failures, and
disable failures. Do not roll back earlier policy updates.
Qoder, an AI coding assistant, helped analyze the issue, develop the fix
and state matrix, and draft this description.
Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost")
Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
---
drivers/cpufreq/cpufreq.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 4332cb114070..707de10ad36b 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
struct cpufreq_policy *policy;
unsigned long flags;
bool boost_enabled;
+ bool policy_success = false;
int ret = -EOPNOTSUPP;
guard(mutex)(&cpufreq_boost_mutex);
@@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state)
ret = policy_set_boost(policy, state);
if (unlikely(ret))
break;
+
+ policy_success = true;
}
cpus_read_unlock();
@@ -2918,9 +2921,12 @@ static int cpufreq_boost_trigger_state(int state)
if (likely(!ret))
return 0;
- write_lock_irqsave(&cpufreq_driver_lock, flags);
- cpufreq_driver->boost_enabled = boost_enabled;
- write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ /* Keep partial enable usable and repairable through local sysfs. */
+ if (!state || !policy_success) {
+ write_lock_irqsave(&cpufreq_driver_lock, flags);
+ cpufreq_driver->boost_enabled = boost_enabled;
+ write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ }
pr_err("%s: Cannot %s BOOST\n",
__func__, str_enable_disable(state));
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v2] cpufreq: Keep global boost enabled after partial enable
2026-11-27 1:49 ` [RFC PATCH v2] " Jiangtian Feng
@ 2026-11-27 3:41 ` Zhongqiu Han
2026-11-27 5:59 ` Jiangtian Feng
2026-11-27 6:03 ` [RFC PATCH v3] " Jiangtian Feng
1 sibling, 1 reply; 10+ messages in thread
From: Zhongqiu Han @ 2026-11-27 3:41 UTC (permalink / raw)
To: Jiangtian Feng, rafael, viresh.kumar
Cc: linux-pm, linux-kernel, christian.loehle, ananthu.cv,
pierre.gondois, Zhongqiu Han
On 11/27/2026 9:49 AM, Jiangtian Feng wrote:
> When global boost is enabled from the disabled state, a failure after
> one or more policies have been updated successfully currently restores
> the global flag to 0 without rolling back those policies. This leaves
> them locally enabled, with their boost-related driver/QoS updates
> retained, while the global flag rejects per-policy sysfs writes.
>
> Keep the global flag enabled if at least one policy_set_boost() call
> succeeded, while preserving the existing error return path. Global
> boost = 1 grants permission to boost; it does not require every policy
> to have boost enabled. The mixed per-policy state is therefore valid
> and individual policies remain accessible through per-policy sysfs.
>
> Retain global-state restoration for enable failures without a
> successful policy update, same-state resynchronization failures, and
> disable failures. Do not roll back earlier policy updates.
The "same-state resynchronization failures" part of the changelog is
left over from v1. With v2's condition, if global boost is already 1,
writing 1 again fails, and some policy was boosted before the failure,
the restore is skipped. This is harmless because the restore would write
1 anyway, but the changelog no longer matches the code. Please update
that sentence along with the comment.
>
> Qoder, an AI coding assistant, helped analyze the issue, develop the fix
> and state matrix, and draft this description.
>
> Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost")
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
> ---
When posting a new version of a patch, such as this v2, please
describe what changed since the previous version below the "---"
line, with a link to the previous posting. See
Documentation/process/submitting-patches.rst for details.
Please also reply to the review comments on the previous version
before posting a new one, so reviewers know whether each comment was
accepted, and if not, why.
> drivers/cpufreq/cpufreq.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 4332cb114070..707de10ad36b 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
> struct cpufreq_policy *policy;
> unsigned long flags;
> bool boost_enabled;
> + bool policy_success = false;
> int ret = -EOPNOTSUPP;
>
> guard(mutex)(&cpufreq_boost_mutex);
> @@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state)
> ret = policy_set_boost(policy, state);
> if (unlikely(ret))
> break;
> +
> + policy_success = true;
> }
>
> cpus_read_unlock();
> @@ -2918,9 +2921,12 @@ static int cpufreq_boost_trigger_state(int state)
> if (likely(!ret))
> return 0;
>
> - write_lock_irqsave(&cpufreq_driver_lock, flags);
> - cpufreq_driver->boost_enabled = boost_enabled;
> - write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> + /* Keep partial enable usable and repairable through local sysfs. */
This comment is left over from v1's goto branch. In v2 it sits above
the restore path but only describes the skipped case, so please reword
it to say when the previous state is restored and why a partial enable
keeps global boost set.
> + if (!state || !policy_success) {
> + write_lock_irqsave(&cpufreq_driver_lock, flags);
> + cpufreq_driver->boost_enabled = boost_enabled;
> + write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> + }
>
> pr_err("%s: Cannot %s BOOST\n",
> __func__, str_enable_disable(state));
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] cpufreq: Keep global boost enabled after partial enable
2026-11-26 15:07 ` Christian Loehle
@ 2026-11-27 5:59 ` Jiangtian Feng
0 siblings, 0 replies; 10+ messages in thread
From: Jiangtian Feng @ 2026-11-27 5:59 UTC (permalink / raw)
To: christian.loehle
Cc: rafael, viresh.kumar, linux-pm, linux-kernel, ananthu.cv,
pierre.gondois, jiangtianfeng, zhongqiu.han
On Thu, 26 Nov 2026 15:07:41 +0000, Christian Loehle wrote:
> What's the RFC part for specifically?
The RFC is specifically about the user-visible partial-success semantics:
whether a partially successful global enable may remain globally enabled
as a valid and locally repairable state, instead of restoring global=0
while leaving earlier policies locally enabled.
No normal in-tree trigger for this sequence has been identified, and no
runtime fault injection or hardware validation has been performed. This
is not proposed as a Vera or stable prerequisite.
> FWIW I broadly agree with the direction of that patch.
Thank you. The implementation change in v2 only removes goto and
simplifies the restoration condition; it does not change that proposed
partial-enable semantic.
Best regards,
Jiangtian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH] cpufreq: Keep global boost enabled after partial enable
2026-11-26 15:09 ` Zhongqiu Han
@ 2026-11-27 5:59 ` Jiangtian Feng
0 siblings, 0 replies; 10+ messages in thread
From: Jiangtian Feng @ 2026-11-27 5:59 UTC (permalink / raw)
To: zhongqiu.han
Cc: rafael, viresh.kumar, linux-pm, linux-kernel, ananthu.cv,
pierre.gondois, jiangtianfeng, christian.loehle
On Thu, 26 Nov 2026 23:09:42 +0800, Zhongqiu Han wrote:
> Yeah, it is a real issue, global boost "only means a permission to use
> the frequency boost mechanism" (cpufreq.rst), and "per-policy boost can
> then be enabled or disabled individually" while "disabling global boost
> makes the per-policy boost interface illegal" (commit 218a06a79d9a).
Thank you for confirming the state semantics. That is the inconsistency
this RFC is intended to address.
> This function uses guard(), and cleanup.h says "usage of "goto" and
> cleanup helpers is never mixed in the same function".
Accepted. v2 removes both the goto and out_err label from this function.
> Besides, the !boost_enabled check is redundant, right? so maybe:
>
> if (!state || !policy_success) {
> write_lock_irqsave(&cpufreq_driver_lock, flags);
> cpufreq_driver->boost_enabled = boost_enabled;
> write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> }
Accepted. v2 uses this condition. When the old global value is already
1, skipping the restore is equivalent because the restore would only
write 1 again.
> Separately, the disable side can end up in a similar state: if global
> boost is already 0 and a resync write of 0 fails on some policy, that
> policy stays boosted under global boost = 0. That's outside the scope
> of this patch, though.
Agreed. I have left that case for separate discussion rather than
expanding this patch.
I should also acknowledge that the v2 changelog and comment retained the
v1 wording. I will correct both in v3 and include per-version changes and
links to the previous postings. I should have replied to these comments
before posting v2, and will do so for subsequent revisions.
Best regards,
Jiangtian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v2] cpufreq: Keep global boost enabled after partial enable
2026-11-27 3:41 ` Zhongqiu Han
@ 2026-11-27 5:59 ` Jiangtian Feng
0 siblings, 0 replies; 10+ messages in thread
From: Jiangtian Feng @ 2026-11-27 5:59 UTC (permalink / raw)
To: zhongqiu.han
Cc: rafael, viresh.kumar, linux-pm, linux-kernel, ananthu.cv,
pierre.gondois, jiangtianfeng, christian.loehle
On Fri, 27 Nov 2026 11:41:36 +0800, Zhongqiu Han wrote:
> The "same-state resynchronization failures" part of the changelog is
> left over from v1. With v2's condition, if global boost is already 1,
> writing 1 again fails, and some policy was boosted before the failure,
> the restore is skipped. This is harmless because the restore would write
> 1 anyway, but the changelog no longer matches the code. Please update
> that sentence along with the comment.
Agreed. In v3 the changelog instead says that the previous global state
is restored on disable or when no policy was enabled successfully. After
a partial enable, global boost remains enabled so individual policies
remain repairable through sysfs.
> When posting a new version of a patch, such as this v2, please
> describe what changed since the previous version below the "---"
> line, with a link to the previous posting. See
> Documentation/process/submitting-patches.rst for details.
Accepted. v3 includes separate v2 and v3 change descriptions and links to
both previous postings below the "---" line.
> Please also reply to the review comments on the previous version
> before posting a new one, so reviewers know whether each comment was
> accepted, and if not, why.
Understood. I have replied to the v1 comments separately and will follow
this order for subsequent versions.
> This comment is left over from v1's goto branch. In v2 it sits above
> the restore path but only describes the skipped case, so please reword
> it to say when the previous state is restored and why a partial enable
> keeps global boost set.
Accepted. v3 changes the comment to describe restoring the old state on
failure unless a partial enable needs to remain locally repairable.
Best regards,
Jiangtian
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC PATCH v3] cpufreq: Keep global boost enabled after partial enable
2026-11-27 1:49 ` [RFC PATCH v2] " Jiangtian Feng
2026-11-27 3:41 ` Zhongqiu Han
@ 2026-11-27 6:03 ` Jiangtian Feng
2026-11-27 6:54 ` Zhongqiu Han
1 sibling, 1 reply; 10+ messages in thread
From: Jiangtian Feng @ 2026-11-27 6:03 UTC (permalink / raw)
To: rafael, viresh.kumar
Cc: linux-pm, linux-kernel, christian.loehle, ananthu.cv,
pierre.gondois, zhongqiu.han, jiangtianfeng
When global boost is enabled from the disabled state, a failure after
one or more policies have been updated successfully currently restores
the global flag to 0 without rolling back those policies. This leaves
them locally enabled, with their boost-related driver/QoS updates
retained, while the global flag rejects per-policy sysfs writes.
Keep the global flag enabled if at least one policy_set_boost() call
succeeded, while preserving the existing error return path. Global
boost = 1 grants permission to boost; it does not require every policy
to have boost enabled. The mixed per-policy state is therefore valid
and individual policies remain accessible through per-policy sysfs.
Restore the previous global state on disable and when no policy was
enabled successfully. After a partial enable, keep global boost enabled
so users can repair individual policies through sysfs. Do not roll back
earlier policy updates.
Qoder, an AI coding assistant, helped analyze the issue, develop the fix
and state matrix, and draft this description.
Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost")
Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
---
This RFC discusses the user-visible partial-success semantics: a failed
write of 1 can leave the global flag readable as 1 when at least one
policy was enabled successfully.
Changes in v3:
- Correct the changelog and comment to describe restoration on disable
or when no policy was enabled successfully, and local repair after a
partial enable.
- No code-logic change from v2.
- Link: https://lore.kernel.org/linux-pm/20261127014937.413500-1-jiangtianfeng@linux.alibaba.com/
Changes in v2:
- Remove goto/out_err from the function using cleanup guards.
- Simplify the restoration condition to !state || !policy_success.
- Link: https://lore.kernel.org/linux-pm/20261126110903.3747240-1-jiangtianfeng@linux.alibaba.com/
No normal in-tree trigger for the partial-enable sequence has been
identified. Same-state global writes already provide a resynchronization
mechanism. The same-state disable/resync failure noted by Zhongqiu is
left for separate discussion instead of expanding this patch.
This AI-assisted draft requires human review and DCO sign-off before
submission.
Validation:
- mainline ARM64 defconfig build of the complete Image
- checkpatch.pl
- eight-case old-global/request/success state matrix
- independent static control-flow and locking review
NOT_RUN:
- runtime fault injection or reproduction with multiple policies
- global/local concurrency, hotplug, lockdep or KCSAN testing
- CPPC, SW frequency-table, ACPI or AMD hardware frequency/QoS testing
drivers/cpufreq/cpufreq.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 4332cb114070..57f1874e087a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
struct cpufreq_policy *policy;
unsigned long flags;
bool boost_enabled;
+ bool policy_success = false;
int ret = -EOPNOTSUPP;
guard(mutex)(&cpufreq_boost_mutex);
@@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state)
ret = policy_set_boost(policy, state);
if (unlikely(ret))
break;
+
+ policy_success = true;
}
cpus_read_unlock();
@@ -2918,9 +2921,12 @@ static int cpufreq_boost_trigger_state(int state)
if (likely(!ret))
return 0;
- write_lock_irqsave(&cpufreq_driver_lock, flags);
- cpufreq_driver->boost_enabled = boost_enabled;
- write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ /* On failure, restore old state unless partial enable needs local repair. */
+ if (!state || !policy_success) {
+ write_lock_irqsave(&cpufreq_driver_lock, flags);
+ cpufreq_driver->boost_enabled = boost_enabled;
+ write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ }
pr_err("%s: Cannot %s BOOST\n",
__func__, str_enable_disable(state));
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v3] cpufreq: Keep global boost enabled after partial enable
2026-11-27 6:03 ` [RFC PATCH v3] " Jiangtian Feng
@ 2026-11-27 6:54 ` Zhongqiu Han
0 siblings, 0 replies; 10+ messages in thread
From: Zhongqiu Han @ 2026-11-27 6:54 UTC (permalink / raw)
To: Jiangtian Feng, rafael, viresh.kumar
Cc: linux-pm, linux-kernel, christian.loehle, ananthu.cv,
pierre.gondois, Zhongqiu Han
On 11/27/2026 2:03 PM, Jiangtian Feng wrote:
> When global boost is enabled from the disabled state, a failure after
> one or more policies have been updated successfully currently restores
> the global flag to 0 without rolling back those policies. This leaves
> them locally enabled, with their boost-related driver/QoS updates
> retained, while the global flag rejects per-policy sysfs writes.
>
> Keep the global flag enabled if at least one policy_set_boost() call
> succeeded, while preserving the existing error return path. Global
> boost = 1 grants permission to boost; it does not require every policy
> to have boost enabled. The mixed per-policy state is therefore valid
> and individual policies remain accessible through per-policy sysfs.
>
> Restore the previous global state on disable and when no policy was
> enabled successfully. After a partial enable, keep global boost enabled
> so users can repair individual policies through sysfs. Do not roll back
> earlier policy updates.
>
> Qoder, an AI coding assistant, helped analyze the issue, develop the fix
> and state matrix, and draft this description.
>
> Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost")
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
One thing to note is that a failed 0->1 write may now read back as 1,
though the resulting state itself is valid since 218a06a79d9a.
Looks good to me:
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
> ---
> This RFC discusses the user-visible partial-success semantics: a failed
> write of 1 can leave the global flag readable as 1 when at least one
> policy was enabled successfully.
>
> Changes in v3:
> - Correct the changelog and comment to describe restoration on disable
> or when no policy was enabled successfully, and local repair after a
> partial enable.
> - No code-logic change from v2.
> - Link: https://lore.kernel.org/linux-pm/20261127014937.413500-1-jiangtianfeng@linux.alibaba.com/
>
> Changes in v2:
> - Remove goto/out_err from the function using cleanup guards.
> - Simplify the restoration condition to !state || !policy_success.
> - Link: https://lore.kernel.org/linux-pm/20261126110903.3747240-1-jiangtianfeng@linux.alibaba.com/
>
> No normal in-tree trigger for the partial-enable sequence has been
> identified. Same-state global writes already provide a resynchronization
> mechanism. The same-state disable/resync failure noted by Zhongqiu is
> left for separate discussion instead of expanding this patch.
>
> This AI-assisted draft requires human review and DCO sign-off before
> submission.
Please drop notes like this from future postings.
>
> Validation:
> - mainline ARM64 defconfig build of the complete Image
> - checkpatch.pl
> - eight-case old-global/request/success state matrix
> - independent static control-flow and locking review
>
> NOT_RUN:
> - runtime fault injection or reproduction with multiple policies
> - global/local concurrency, hotplug, lockdep or KCSAN testing
> - CPPC, SW frequency-table, ACPI or AMD hardware frequency/QoS testing
>
> drivers/cpufreq/cpufreq.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 4332cb114070..57f1874e087a 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
> struct cpufreq_policy *policy;
> unsigned long flags;
> bool boost_enabled;
> + bool policy_success = false;
> int ret = -EOPNOTSUPP;
>
> guard(mutex)(&cpufreq_boost_mutex);
> @@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state)
> ret = policy_set_boost(policy, state);
> if (unlikely(ret))
> break;
> +
> + policy_success = true;
> }
>
> cpus_read_unlock();
> @@ -2918,9 +2921,12 @@ static int cpufreq_boost_trigger_state(int state)
> if (likely(!ret))
> return 0;
>
> - write_lock_irqsave(&cpufreq_driver_lock, flags);
> - cpufreq_driver->boost_enabled = boost_enabled;
> - write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> + /* On failure, restore old state unless partial enable needs local repair. */
> + if (!state || !policy_success) {
> + write_lock_irqsave(&cpufreq_driver_lock, flags);
> + cpufreq_driver->boost_enabled = boost_enabled;
> + write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> + }
>
> pr_err("%s: Cannot %s BOOST\n",
> __func__, str_enable_disable(state));
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-27 6:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 11:08 [RFC PATCH] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-11-26 15:07 ` Christian Loehle
2026-11-27 5:59 ` Jiangtian Feng
2026-11-26 15:09 ` Zhongqiu Han
2026-11-27 5:59 ` Jiangtian Feng
2026-11-27 1:49 ` [RFC PATCH v2] " Jiangtian Feng
2026-11-27 3:41 ` Zhongqiu Han
2026-11-27 5:59 ` Jiangtian Feng
2026-11-27 6:03 ` [RFC PATCH v3] " Jiangtian Feng
2026-11-27 6:54 ` Zhongqiu Han
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®