Re: [PATCH v3 07/20] sched/fair: Select preferred CPU at wakeup when possible

From: K Prateek Nayak

Date: Thu Jun 04 2026 - 01:14:36 EST


Hello Shrikanth,

> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 29fbb5287cfc..a704285ac55a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7743,7 +7743,8 @@ static inline int sched_balance_find_dst_cpu(struct sched_domain *sd, struct tas
> {
> int new_cpu = cpu;
>
> - if (!cpumask_intersects(sched_domain_span(sd), p->cpus_ptr))
> + if (!cpumask_intersects(sched_domain_span(sd), p->cpus_ptr) &&

Doesn't this mean we have no CPUs in this sd that fits the affinity
requirements?

> + cpu_preferred(prev_cpu))

There is no point in going down the function if the affinity constraints
aren't met since we are traversing the hierarchy top-down and none of
the groups / child domains will satisfy the affinity requirements.

Since the CPU returned here is again checked for is_cpu_allowed(), we'll
eventually hit the select_fallback_rq() path anyways so the check for
cpu_preferred(prev_cpu) seems unnecessary unless I'm missing something.

> return prev_cpu;
>
> /*

--
Thanks and Regards,
Prateek