Re: [PATCH 1/2] sched/fair: Prefer fully-idle SMT cores in asym-capacity idle selection
From: Andrea Righi
Date: Tue Apr 21 2026 - 09:41:03 EST
Hi Prateek,
On Tue, Apr 21, 2026 at 04:52:46PM +0530, K Prateek Nayak wrote:
...
> Can I trouble you to test the SIS_UTIL bailout with your series +
> the topology changes:
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 78f2d2c4e24f..1356bbdbccd4 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7990,6 +7990,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
> int fits, best_fits = 0;
> int cpu, best_cpu = -1;
> struct cpumask *cpus;
> + int nr = INT_MAX;
>
> cpus = this_cpu_cpumask_var_ptr(select_rq_mask);
> cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
> @@ -7998,10 +7999,30 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
> util_min = uclamp_eff_value(p, UCLAMP_MIN);
> util_max = uclamp_eff_value(p, UCLAMP_MAX);
>
> + if (sched_feat(SIS_UTIL) && sd->shared) {
> + /*
> + * Increment because !--nr is the condition to stop scan.
> + *
> + * Since "sd" is "sd_llc" for target CPU dereferenced in the
> + * caller, it is safe to directly dereference "sd->shared".
> + * Topology bits always ensure it assigned for "sd_llc" abd it
nit: s/abd/and/, BTW we have the same in select_idle_cpu(), consistent typo. :)
> + * cannot disappear as long as we have a RCU protected
> + * reference to one the associated "sd" here.
> + */
> + nr = READ_ONCE(sd->shared->nr_idle_scan) + 1;
> + /* overloaded LLC is unlikely to have idle cpu/core */
> + if (nr == 1)
> + return -1;
> + }
> +
> for_each_cpu_wrap(cpu, cpus, target) {
> bool preferred_core = !prefers_idle_core || is_core_idle(cpu);
> unsigned long cpu_cap = capacity_of(cpu);
>
> + /* We have found a good enough target. Just use it. */
> + if (--nr <= 0 && best_fits == -4)
> + return best_cpu;
> +
> if (!choose_idle_cpu(cpu, p))
> continue;
>
> ---
>
> You can also try "best_fits <= -3" in that last bailout condition and
> see if that help.
For the bailout condition I don't see much difference using either <= -3 or
== -4. In general, I see a small but consistent improvement with the SIS_UTIL
logic, especially when the system is close to saturation (as expected).
So, this looks good to me! Do you want me to include also this one in the new
SMT-aware asym cpu capacity patch series (keeping your authorship of course) or
do you prefer to route this separately?
Thanks,
-Andrea