public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: cppc: drop invariance when FIE is disabled
@ 2026-02-20 22:49 Penghe Geng
  2026-02-25  4:08 ` Jie Zhan
  0 siblings, 1 reply; 2+ messages in thread
From: Penghe Geng @ 2026-02-20 22:49 UTC (permalink / raw)
  To: Rafael J . Wysocki
  Cc: Viresh Kumar, Ionela Voinescu, linux-pm, linux-kernel, stable,
	Penghe Geng

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cpufreq: cppc: drop invariance when FIE is disabled
  2026-02-20 22:49 [PATCH] cpufreq: cppc: drop invariance when FIE is disabled Penghe Geng
@ 2026-02-25  4:08 ` Jie Zhan
  0 siblings, 0 replies; 2+ messages in thread
From: Jie Zhan @ 2026-02-25  4:08 UTC (permalink / raw)
  To: Penghe Geng
  Cc: Viresh Kumar, Ionela Voinescu, linux-pm, linux-kernel, stable,
	Rafael J. Wysocki


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(+)
> 
...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-25  4:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-20 22:49 [PATCH] cpufreq: cppc: drop invariance when FIE is disabled Penghe Geng
2026-02-25  4:08 ` Jie Zhan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox