Re: [PATCH v4 1/6] sched/fair: Do not skip CPUs of similar capacity with busy SMT siblings

From: K Prateek Nayak

Date: Tue Jun 09 2026 - 00:28:31 EST


Hello Ricardo,

On 6/8/2026 6:27 PM, Ricardo Neri wrote:
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index f4ed841f766f..229f32cebf1f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -12924,6 +12924,7 @@ static struct rq *sched_balance_find_src_rq(struct lb_env *env,
> int i;
>
> for_each_cpu_and(i, sched_group_span(group), env->cpus) {
> + bool smt_degraded_cap = sched_smt_active() && !is_core_idle(i);

Based on a quick look at the generated asm, we seem to be calculating
"smt_degraded_cap" regardless of whether we are on a
"SD_ASYM_CPUCAPACITY" domain or not which is an unnecessary overhead of
doing a is_core_idle() on symmetric domains.

We can have an indicator up top like:

bool asym_balance = !!(env->sd->flags & SD_ASYM_CPUCAPACITY);

and later use that when computing smt_degraded_cap:

bool smt_degraded_cap = asym_balance && (sched_smt_active() && !is_core_idle(i));

I would even suggest pushing this until later and do ...

> unsigned long capacity, load, util;
> unsigned int nr_running;
> enum fbq_type rt;
> @@ -12964,8 +12965,12 @@ static struct rq *sched_balance_find_src_rq(struct lb_env *env,
> * eventually lead to active_balancing high->low capacity.
> * Higher per-CPU capacity is considered better than balancing
> * average load.
> + *
> + * Busy SMT siblings reduce the capacity of CPU i. Do not skip
> + * it in this case.
> */
> if (env->sd->flags & SD_ASYM_CPUCAPACITY &&

...

if (asym_balance) {
/* Busy SMT reduces capacity */
if (sched_smt_active() && !is_core_idle(i))
continue;

/* Other bits */
if (...)
continue;
}

Thoughts?

Aside from that, the changes makes sense to me. Feel free to include:

Reviewed-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>


> + !smt_degraded_cap &&
> !capacity_greater(capacity_of(env->dst_cpu), capacity) &&
> nr_running == 1)
> continue;
>
> --
> 2.43.0
>

--
Thanks and Regards,
Prateek