Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v2] cpufreq: Handle CPUFREQ_ETERNAL with a default transition latency
@ 2025-09-22 12:59 Shawn Guo
  2025-09-22 13:45 ` Zhongqiu Han
  2025-09-22 18:31 ` Rafael J. Wysocki
  0 siblings, 2 replies; 5+ messages in thread
From: Shawn Guo @ 2025-09-22 12:59 UTC (permalink / raw)
  To: Rafael J . Wysocki
  Cc: Shawn Guo, Qais Yousef, Viresh Kumar, linux-pm, linux-kernel,
	stable

From: Shawn Guo <shawnguo@kernel.org>

A regression is seen with 6.6 -> 6.12 kernel upgrade on platforms where
cpufreq-dt driver sets cpuinfo.transition_latency as CPUFREQ_ETERNAL (-1),
due to that platform's DT doesn't provide the optional property
'clock-latency-ns'.  The dbs sampling_rate was 10000 us on 6.6 and
suddently becomes 6442450 us (4294967295 / 1000 * 1.5) on 6.12 for these
platforms, because the default transition delay was dropped by the commits
below.

  commit 37c6dccd6837 ("cpufreq: Remove LATENCY_MULTIPLIER")
  commit a755d0e2d41b ("cpufreq: Honour transition_latency over transition_delay_us")
  commit e13aa799c2a6 ("cpufreq: Change default transition delay to 2ms")

It slows down dbs governor's reacting to CPU loading change
dramatically.  Also, as transition_delay_us is used by schedutil governor
as rate_limit_us, it shows a negative impact on device idle power
consumption, because the device gets slightly less time in the lowest OPP.

Fix the regressions by defining a default transition latency for
handling the case of CPUFREQ_ETERNAL.

Cc: stable@vger.kernel.org
Fixes: 37c6dccd6837 ("cpufreq: Remove LATENCY_MULTIPLIER")
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
---
Changes for v2:
- Follow Rafael's suggestion to define a default transition latency for
  handling CPUFREQ_ETERNAL, and pave the way to get rid of
  CPUFREQ_ETERNAL completely later.

v1: https://lkml.org/lkml/2025/9/10/294

 drivers/cpufreq/cpufreq.c | 3 +++
 include/linux/cpufreq.h   | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index fc7eace8b65b..c69d10f0e8ec 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -549,6 +549,9 @@ unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy)
 	if (policy->transition_delay_us)
 		return policy->transition_delay_us;
 
+	if (policy->cpuinfo.transition_latency == CPUFREQ_ETERNAL)
+		policy->cpuinfo.transition_latency = CPUFREQ_DEFAULT_TANSITION_LATENCY_NS;
+
 	latency = policy->cpuinfo.transition_latency / NSEC_PER_USEC;
 	if (latency)
 		/* Give a 50% breathing room between updates */
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 95f3807c8c55..935e9a660039 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -36,6 +36,8 @@
 /* Print length for names. Extra 1 space for accommodating '\n' in prints */
 #define CPUFREQ_NAME_PLEN		(CPUFREQ_NAME_LEN + 1)
 
+#define CPUFREQ_DEFAULT_TANSITION_LATENCY_NS	NSEC_PER_MSEC
+
 struct cpufreq_governor;
 
 enum cpufreq_table_sorting {
-- 
2.43.0


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

end of thread, other threads:[~2025-09-25 11:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 12:59 [PATCH v2] cpufreq: Handle CPUFREQ_ETERNAL with a default transition latency Shawn Guo
2025-09-22 13:45 ` Zhongqiu Han
2025-09-22 18:31 ` Rafael J. Wysocki
2025-09-25  8:04   ` Shawn Guo
2025-09-25 11:16     ` Rafael J. Wysocki

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