[PATCH] sched/cpufreq: Reorder so non-SCX is common path

Christian Loehle
2026-03-18T13:03:53Z

scx_enabled() with sugov is probably the rarer case to fair with
sugov, so reorder the condition into scx_enabled() check instead of
the !scx_switched_all() check so the static branch is not checked when
sched_ext isn't enabled.

No functional change intended.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
@Peter
We probably also want the analogous reorder in sugov then....

kernel/sched/cpufreq_schedutil.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 153232dd8276..06bd453a37eb 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -225,10 +225,16 @@ unsigned long sugov_effective_cpu_perf(int cpu, unsigned long actual,

static void sugov_get_util(struct sugov_cpu *sg_cpu, unsigned long boost)
{
- unsigned long min, max, util = scx_cpuperf_target(sg_cpu->cpu);
+ unsigned long min, max, util = cpu_util_cfs_boost(sg_cpu->cpu);

- if (!scx_switched_all())
- util += cpu_util_cfs_boost(sg_cpu->cpu);
+ if (scx_enabled()) {
+ unsigned long scx_util = scx_cpuperf_target(sg_cpu->cpu);
+
+ if (!scx_switched_all())
+ scx_util += util;
+
+ util = scx_util;
+ }
util = effective_cpu_util(sg_cpu->cpu, util, &min, &max);
util = max(util, boost);
sg_cpu->bw_min = min;
--
2.34.1