* [RFC PATCH] cpufreq: Keep global boost enabled after partial enable
@ 2026-11-26 11:08 Jiangtian Feng
2026-11-26 15:07 ` Christian Loehle
2026-11-26 15:09 ` Zhongqiu Han
0 siblings, 2 replies; 3+ 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] 3+ 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
1 sibling, 0 replies; 3+ 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] 3+ 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
1 sibling, 0 replies; 3+ 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] 3+ messages in thread
end of thread, other threads:[~2026-11-26 15:09 UTC | newest]
Thread overview: 3+ 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-26 15:09 ` 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®