Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] sched/cpufreq: Fix capacity calc in shared policy update
@ 2025-11-25  3:24 Kaushlendra Kumar
  2025-11-25  8:37 ` Christian Loehle
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Kaushlendra Kumar @ 2025-11-25  3:24 UTC (permalink / raw)
  To: rafael, viresh.kumar, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, bsegall, mgorman, vschneid
  Cc: linux-pm, Kaushlendra Kumar

In sugov_next_freq_shared(), the CPU capacity is retrieved only
for the CPU that triggered the update (sg_cpu->cpu) and then
incorrectly applied to all CPUs in the shared frequency domain
during the loop.On heterogeneous systems with CPUs of different
capacities sharing a frequency domain, this causes incorrect
frequency selection.

Calculate per-CPU capacity in the loop and track maximum across
all CPUs for proper frequency calculation.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
 kernel/sched/cpufreq_schedutil.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 0ab5f9d4bc59..9fdbc7a6063d 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -492,15 +492,15 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
 {
 	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
 	struct cpufreq_policy *policy = sg_policy->policy;
-	unsigned long util = 0, max_cap;
+	unsigned long util = 0, max_cap = 0;
 	unsigned int j;
 
-	max_cap = arch_scale_cpu_capacity(sg_cpu->cpu);
-
 	for_each_cpu(j, policy->cpus) {
 		struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
-		unsigned long boost;
+		unsigned long boost, j_max_cap;
 
+		j_max_cap = arch_scale_cpu_capacity(j);
+		max_cap = max(max_cap, j_max_cap);
 		boost = sugov_iowait_apply(j_sg_cpu, time, max_cap);
 		sugov_get_util(j_sg_cpu, boost);
 
-- 
2.34.1


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

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

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25  3:24 [PATCH] sched/cpufreq: Fix capacity calc in shared policy update Kaushlendra Kumar
2025-11-25  8:37 ` Christian Loehle
2025-11-25  9:28   ` Kumar, Kaushlendra
2025-11-25  9:04 ` Lukasz Luba
2025-11-25  9:23   ` Kumar, Kaushlendra
2025-11-25  9:38     ` Vincent Guittot
2025-11-25  9:46       ` Christian Loehle
2025-11-25  9:57         ` Vincent Guittot
2025-11-25 12:41         ` Rafael J. Wysocki
2025-11-25 14:05           ` Kumar, Kaushlendra
2025-11-25 12:09 ` 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