Re: [PATCH] sched/balance: Skip unnecessary updates to idle load balancer's flags
From: Tim Chen
Date: Tue Jun 04 2024 - 18:32:31 EST
On Tue, 2024-06-04 at 10:10 +0800, Chen Yu wrote:
>
> >
> > Not sure I follow your comments about return being safe. Let me explain
> > in details.
> >
> > We will return directly if and only if the bits set in flags are also set
> > in nohz_flags(ilb_cpu).
> >
> > The comment's intention is to say that if the above statement is true, then
> > the later operation of
> >
> > atomic_fetch_or(flags, nohz_flags(ilb_cpu))
> >
> > will be useless and not result in any change to nohz_flags(ilb_cpu), since all the set bits
> > in flags are already set in nohz_flags(ilb_cpu).
>
> Understand. My previous thought was that, what if the current nohz_flags(ilb_cpu) is 0 or
> NOHZ_NEWILB_KICK. If yes, return directly might miss one ipi to the ilb_cpu(because
> the current code checks flags & NOHZ_KICK_MASK to return directly). But from the current
> logic when we reach kick_ilb(), the flag is not 0, and the flag passed by nohz_balancer_kick()
> satisfy (flags & NOHZ_KICK_MASK), so returns here is ok.
Should not have issues of missing an IPI. kick_ilb(flags) is always called with non-zero flags
value. And the first guy who update nohz_flags(ilb_cpu) successfully with bits
in the NOHZ_KICK_MASK will send the IPI.
Tim