Re: [RFC PATCH] sched: Add scx_cpuperf_target in sched_cpu_util()

From: Christian Loehle

Date: Wed Mar 18 2026 - 08:56:34 EST


On 3/18/26 12:17, Xuewen Yan wrote:
> Recently, while enabling sched-ext debugging, we observed abnormal behavior
> in our thermal power_allocator’s temperature control.
> Through debugging, we found that the CPU util was too low, causing
> the CPU frequency to remain unrestricted.
>
> This issue stems from the fact that in the sched_cpu_util() function,
> when scx is enabled, cpu_util_cfs becomes zero. As a result,
> the thermal subsystem perceives an extremely low CPU utilization,
> which degrades the effectiveness of the power_allocator’s control.
>
> To address this, we propose adding scx_cpuperf_target in the sched_cpu_util()
> as a replacement for cpu_util_cfs, ensuring that the thermal subsystem receives
> accurate load information and restores proper control behavior.
>
> Reported-by: Di Shen <di.shen@xxxxxxxxxx>
> Signed-off-by: Xuewen Yan <xuewen.yan@xxxxxxxxxx>

Fixes: d86adb4fc0655 ("sched_ext: Add cpuperf support")?

> ---
> kernel/sched/fair.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index bf948db905ed..20adb6fede2a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8198,7 +8198,12 @@ unsigned long effective_cpu_util(int cpu, unsigned long util_cfs,
>
> unsigned long sched_cpu_util(int cpu)
> {
> - return effective_cpu_util(cpu, cpu_util_cfs(cpu), NULL, NULL);
> + unsigned long util = scx_cpuperf_target(cpu);
> +
> + if (!scx_switched_all())
> + util += cpu_util_cfs(cpu);
> +
> + return effective_cpu_util(cpu, util, NULL, NULL);
> }
>
> /*

Ah right, I guess it's not as good as sugov as there's no guarantee it behaves
somewhat low-pass-filterish, but better than nothing.
No idea if it's worth factoring out this and sugov_get_util, maybe not given that
sugov includes ('temporary') cfs runnable boost while sched_cpu_util() doesn't.