[PATCH] cpufreq: cppc: drop invariance when FIE is disabled

Penghe Geng posted 1 patch 1 month, 3 weeks ago
drivers/cpufreq/cppc_cpufreq.c | 4 ++++
drivers/cpufreq/cpufreq.c      | 8 ++++++++
include/linux/cpufreq.h        | 3 +++
3 files changed, 15 insertions(+)
[PATCH] cpufreq: cppc: drop invariance when FIE is disabled
Posted by Penghe Geng 1 month, 3 weeks ago
CONFIG_ACPI_CPPC_CPUFREQ_FIE gates CPPC counter-based frequency
invariance support. When FIE is disabled, the CPPC driver does not
register a frequency scale source, but cpufreq_register_driver() still
enables cpufreq_freq_invariance for target/fast-switch drivers.

Disable cpufreq frequency invariance after CPPC driver registration when
FIE is disabled. This avoids scheduler behavior mismatch when no
invariance updates are provided, which can cause major performance
regressions on sensitive platforms.

Export cpufreq_disable_freq_invariance() so modular cppc_cpufreq can call
it.

Fixes: 1eb5dde674f5 ("cpufreq: CPPC: Add support for frequency invariance")
Cc: stable@vger.kernel.org
Signed-off-by: Penghe Geng <pgeng@nvidia.com>
---
 drivers/cpufreq/cppc_cpufreq.c | 4 ++++
 drivers/cpufreq/cpufreq.c      | 8 ++++++++
 include/linux/cpufreq.h        | 3 +++
 3 files changed, 15 insertions(+)

diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index 7e8042efedd1..ad96dfb731ab 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -952,6 +952,10 @@ static int __init cppc_cpufreq_init(void)
 	ret = cpufreq_register_driver(&cppc_cpufreq_driver);
 	if (ret)
 		cppc_freq_invariance_exit();
+#ifndef CONFIG_ACPI_CPPC_CPUFREQ_FIE
+	else
+		cpufreq_disable_freq_invariance();
+#endif
 
 	return ret;
 }
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index a7a69f4d7675..4e79f704a8e7 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -66,6 +66,14 @@ bool cpufreq_supports_freq_invariance(void)
 	return static_branch_likely(&cpufreq_freq_invariance);
 }
 
+void cpufreq_disable_freq_invariance(void)
+{
+	cpus_read_lock();
+	static_branch_disable_cpuslocked(&cpufreq_freq_invariance);
+	cpus_read_unlock();
+}
+EXPORT_SYMBOL_GPL(cpufreq_disable_freq_invariance);
+
 /* Flag to suspend/resume CPUFreq governors */
 static bool cpufreq_suspended;
 
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index cc894fc38971..698b8e044e89 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -249,6 +249,7 @@ void cpufreq_update_policy(unsigned int cpu);
 void cpufreq_update_limits(unsigned int cpu);
 bool have_governor_per_policy(void);
 bool cpufreq_supports_freq_invariance(void);
+void cpufreq_disable_freq_invariance(void);
 struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
 void cpufreq_enable_fast_switch(struct cpufreq_policy *policy);
 void cpufreq_disable_fast_switch(struct cpufreq_policy *policy);
@@ -280,6 +281,8 @@ static inline bool cpufreq_supports_freq_invariance(void)
 {
 	return false;
 }
+
+static inline void cpufreq_disable_freq_invariance(void) { }
 static inline void disable_cpufreq(void) { }
 static inline void cpufreq_update_limits(unsigned int cpu) { }
 static inline unsigned long cpufreq_get_pressure(int cpu)
-- 
2.43.0
Re: [PATCH] cpufreq: cppc: drop invariance when FIE is disabled
Posted by Jie Zhan 1 month, 3 weeks ago
On 2/21/2026 6:49 AM, Penghe Geng wrote:
> CONFIG_ACPI_CPPC_CPUFREQ_FIE gates CPPC counter-based frequency
> invariance support. When FIE is disabled, the CPPC driver does not
> register a frequency scale source, but cpufreq_register_driver() still
> enables cpufreq_freq_invariance for target/fast-switch drivers.
> 
> Disable cpufreq frequency invariance after CPPC driver registration when
> FIE is disabled. This avoids scheduler behavior mismatch when no
> invariance updates are provided, which can cause major performance
> regressions on sensitive platforms.
Hi Penghe,

IIUC, even if CPPC FIE is not there, cpufreq still updates frequency scales
in cpufreq_freq_transition_end() and cpufreq_driver_fast_switch(), so the
frequency scale number is still somewhat meaningful and the
'cpufreq_freq_invariance' static key reflects that correctly.

Any numbers or evidence of that "performance regressions" so that we can
understand the issue better?

Thanks,
Jie
> 
> Export cpufreq_disable_freq_invariance() so modular cppc_cpufreq can call
> it.
> 
> Fixes: 1eb5dde674f5 ("cpufreq: CPPC: Add support for frequency invariance")
> Cc: stable@vger.kernel.org
> Signed-off-by: Penghe Geng <pgeng@nvidia.com>
> ---
>  drivers/cpufreq/cppc_cpufreq.c | 4 ++++
>  drivers/cpufreq/cpufreq.c      | 8 ++++++++
>  include/linux/cpufreq.h        | 3 +++
>  3 files changed, 15 insertions(+)
> 
...