Re: [PATCH] sched/fair: Fix nohz.next_balance update

From: Vincent Guittot
Date: Fri May 08 2020 - 11:31:57 EST


On Fri, 8 May 2020 at 15:01, Peng Liu <iwtbavbm@xxxxxxxxx> wrote:
>
> On Tue, May 05, 2020 at 04:27:11PM +0200, Vincent Guittot wrote:
> > Le mardi 05 mai 2020 Ã 21:40:56 (+0800), Peng Liu a Ãcrit :
> >
>
> [...]
>
> >
> > Your proposal below looks quite complex. IMO, one solution would be to move the
> > update of nohz.next_balance before calling rebalance_domains(this_rq, CPU_IDLE)
> > so you are back to the previous behavior.
> >
> > The only difference is that in case of an break because of need_resched, it
> > doesn't update nohz.next_balance. But on the other hand, we haven't yet
> > finished run rebalance_domains for all CPUs and some load_balance are still
> > pending. In fact, this will be done during next tick by an idle CPU.
> >
> > So I would be in favor of something as simple as :
> >
>
> Vincent, could you refine this patch with some changelog?

Hi Peng , I'm going to prepare it and another one for the case that we
discussed about kicking a new ilb in case of abort

> And have my reported-by if possible.

Yes I will

>
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 04098d678f3b..e028bc1c4744 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -10457,6 +10457,14 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
> > }
> > }
> >
> > + /*
> > + * next_balance will be updated only when there is a need.
> > + * When the CPU is attached to null domain for ex, it will not be
> > + * updated.
> > + */
> > + if (likely(update_next_balance))
> > + nohz.next_balance = next_balance;
> > +
> > /* Newly idle CPU doesn't need an update */
> > if (idle != CPU_NEWLY_IDLE) {
> > update_blocked_averages(this_cpu);
> > @@ -10477,14 +10485,6 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
> > if (has_blocked_load)
> > WRITE_ONCE(nohz.has_blocked, 1);
> >
> > - /*
> > - * next_balance will be updated only when there is a need.
> > - * When the CPU is attached to null domain for ex, it will not be
> > - * updated.
> > - */
> > - if (likely(update_next_balance))
> > - nohz.next_balance = next_balance;
> > -
> > return ret;
> > }
> >