Re: [PATCH] sched/fair: tweak pick_next_entity

From: Peter Zijlstra
Date: Thu Oct 01 2020 - 03:33:20 EST


On Thu, Oct 01, 2020 at 09:17:43AM +0200, Vincent Guittot wrote:
> On Wed, 30 Sep 2020 at 19:35, Peter Oskolkov <posk@xxxxxxxxxx> wrote:
> >
> > Currently, pick_next_entity(...) has the following structure
> > (simplified):
> >
> > [...]
> > if (last_buddy_ok())
> > result = last_buddy;
> > if (next_buddy_ok())
> > result = next_buddy;
> > [...]
> >
> > The intended behavior is to prefer next buddy over last buddy;
> > the current code somewhat obfuscates this, and also wastes
> > cycles checking the last buddy when eventually the next buddy is
> > picked up.
> >
> > So this patch refactors two 'ifs' above into
> >
> > [...]
> > if (next_buddy_ok())
> > result = next_buddy;
> > else if (last_buddy_ok())
> > result = last_buddy;
> > [...]
> >
> > Signed-off-by: Peter Oskolkov <posk@xxxxxxxxxx>
>
> Reviewed-by: Vincent Guittot <vincent.guitttot@xxxxxxxxxx>

Thanks!