Re: [PATCH] sched/fair: Skip sched-domain traversal when wake affine is disabled
From: Srikar Dronamraju
Date: Mon Nov 09 2026 - 20:41:29 EST
* Kayra Cizmeci <kayracizmeci@xxxxxxxxx> [2026-11-09 21:10:46]:
> On Mon, Nov 09, 2026 at 10:01:20PM +0530, Srikar Dronamraju wrote:
> > * Kayra Cizmeci <kayracizmeci@xxxxxxxxx> [2026-11-09 18:09:56]:
> >
> > Hi Kayra,
> >
> > >
> > > On Mon, Nov 09, 2026 at 05:35:22PM +0530, Srikar Dronamraju wrote:
> > > > In select_task_rq_fair(), TTWU wakeups for which wake_wide() returns
> > > > true, or where the waking CPU is not in the task's allowed CPU mask,
> > > > want_affine is set to false.
> > > >
> > >
> > >
> > > This just changes the behavior.
> > >
> > > Old Code WF_FORK 1, WF_TTWU 0:
> > >
> > > want_affine = 0, so we skip the first if block in the loop then leave
> > > once we find a domain without our flag. And go with slow path.
> > >
> > >
> > > New Code:
> > >
> > > want_affine is moved away and early exit is removed. So we enter the if
> > > block and try to find a domain with prev_cpu. Because WF_TTWU
> > > is 0, we just return new_cpu. Or if we can't fimd the domain with
> > > prev_cpu, slow path.
> > >
> >
> > When WF_TTWU is set, we are always suppose take the fast path.
> > slowpath is for WF_FORK and WF_EXEC.
>
> I know. And that is the exact problem with the above diff :-).
>
> Like let's say prev_cpu is in the first domain we are looking, the
> domain has SD_WAKE_AFFINE and SD_BALANCE_FORK set and next domain has
> only SD_WAKE_AFFINE set:
>
> Old Code:
>
> sd = first domain and we enter the slow path with the first domain.
>
> With your patch:
>
> sd = NULL and we return new_cpu
>
Oh thats a fair point, thanks for the reviewing it.
>
> Or am I missing something?
>
> Cheers,
>
> Kayra
--
Thanks and Regards
Srikar Dronamraju