Re: [PATCH 1/2] sched/fair: Couple wakee flips with heavy wakers

From: Mel Gorman
Date: Mon Nov 01 2021 - 04:56:44 EST


On Fri, Oct 29, 2021 at 05:17:38PM +0200, Vincent Guittot wrote:
> > index ff69f245b939..d00af3b97d8f 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -5865,6 +5865,14 @@ static void record_wakee(struct task_struct *p)
> > }
> >
> > if (current->last_wakee != p) {
> > + int min = __this_cpu_read(sd_llc_size) << 1;
> > + /*
> > + * Couple the wakee flips to the waker for the case where it
> > + * doesn't accrue flips, taking care to not push the wakee
> > + * high enough that the wake_wide() heuristic fails.
> > + */
> > + if (current->wakee_flips > p->wakee_flips * min)
> > + p->wakee_flips++;
>
> I have a hard time understanding the rationale behind these changes
> and the one below. Could you provide more details about why to
> increase p->wakee_flips here ? Also would be good to add such
> explanation in the commit message


The changelog covers it in the first two paragraphs but would the
following be better as a comment?

/*
* Couple the wakee flips to the waker for the case where the
* wakee doesn't accrue any flips during a short interval where
* there are many wakeups without cpu load average being updated.
* Otherwise, it is possible for wake_wide to not trigger followed
* by an affine wake stacking multiple tasks on the same CPU due
* to a stale cpu_load() value checked in wake_affine_weight.
* This heuristic reduces excessive stacking of tasks while taking
* care to not push the wakee high enough that the wake_wide
* heuristic fails differently.
*/

Is that any better? I know this is a heuristic that is a bit on the
fuzzy side as it's trying to clamp the worst of a corner case. Ideally
"wake_wide" would be replaced with a more straight-forward heuristic but
I'm not aware of any alternatives being proposed (and I don't have one
of my own).

--
Mel Gorman
SUSE Labs