linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/fair: Fix frequency selection for non invariant case
@ 2024-01-14 18:36 Vincent Guittot
  2024-01-15 12:15 ` Qais Yousef
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Vincent Guittot @ 2024-01-14 18:36 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
	mgorman, bristot, vschneid, wkarny, torvalds, qyousef, tglx,
	rafael, viresh.kumar, linux-kernel, linux-pm
  Cc: Vincent Guittot

When frequency invariance is not enabled, get_capacity_ref_freq(policy)
returns the current frequency and the performance margin applied by
map_util_perf(), enabled the utilization to go above the maximum compute
capacity and to select a higher frequency than the current one.

The performance margin is now applied earlier in the path to take into
account some utilization clampings and we can't get an utilization higher
than the maximum compute capacity.

We must use a frequency above the current frequency to get a chance to
select a higher OPP when the current one becomes fully used. Apply
the same margin and returns a frequency 25% higher than the current one in
order to switch to the next OPP before we fully use the cpu at the current
one.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Closes: https://lore.kernel.org/lkml/CAHk-=wgWcYX2oXKtgvNN2LLDXP7kXkbo-xTfumEjmPbjSer2RQ@mail.gmail.com/
Reported-by: Wyes Karny <wkarny@gmail.com>
Closes: https://lore.kernel.org/lkml/20240114091240.xzdvqk75ifgfj5yx@wyes-pc/
Fixes: 9c0b4bb7f630 ("sched/cpufreq: Rework schedutil governor performance estimation")
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Tested-by: Wyes Karny <wkarny@gmail.com>
---
 kernel/sched/cpufreq_schedutil.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 95c3c097083e..d12e95d30e2e 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -133,7 +133,11 @@ unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy)
 	if (arch_scale_freq_invariant())
 		return policy->cpuinfo.max_freq;
 
-	return policy->cur;
+	/*
+	 * Apply a 25% margin so that we select a higher frequency than
+	 * the current one before the CPU is full busy
+	 */
+	return policy->cur + (policy->cur >> 2);
 }
 
 /**
-- 
2.34.1


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

end of thread, other threads:[~2024-02-15 10:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-14 18:36 [PATCH] sched/fair: Fix frequency selection for non invariant case Vincent Guittot
2024-01-15 12:15 ` Qais Yousef
2024-01-15 20:06 ` Dietmar Eggemann
2024-01-16  9:59 ` Ingo Molnar
2024-01-16 10:04   ` Vincent Guittot
2024-01-17 14:28   ` Thorsten Leemhuis
2024-02-14 17:12 ` Jon Hunter
2024-02-14 17:19   ` Vincent Guittot
2024-02-14 17:19   ` Linus Torvalds
2024-02-14 17:22     ` Vincent Guittot
2024-02-14 17:57       ` Jon Hunter
2024-02-15  8:45       ` Thorsten Leemhuis
2024-02-15  9:13         ` Greg KH
2024-02-15 10:00           ` Thorsten Leemhuis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).