Re: [PATCH v3 08/20] sched/fair: load balance only among preferred CPUs

From: K Prateek Nayak

Date: Thu Jun 04 2026 - 01:21:09 EST


Hello Shrikanth,

On 5/14/2026 8:51 PM, Shrikanth Hegde wrote:
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index a704285ac55a..0a851d4b0d7e 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -12087,6 +12087,9 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
>
> cpumask_and(cpus, sched_domain_span(sd), cpu_active_mask);
>
> + /* Spread load among preferred CPUs */
> + cpumask_and(cpus, cpus, cpu_preferred_mask);

nit.

Instead of the onine_mask, can we keep the cpu_preferred_mask closer in sync
with the active_mask?

That way, if we can ensure that a preferred CPU is always a subset of the
active_mask, we can save on a couple of cpumask_and() operations by just
looking at preferred_mask instead of both the active_mask and the
preferred_mask.

Are there any complications in that approach to track it via
sched_cpu_activate() / sched_cpu_deactivate()?

> +
> schedstat_inc(sd->lb_count[idle]);
>
> redo:

--
Thanks and Regards,
Prateek