On 12/02/21 15:17, Vincent Guittot wrote:
> Instead of waking up a random and already idle CPU, we can take advantage
> of this_cpu being about to enter idle to run the ILB and update the
> blocked load.
>
> Signed-off-by: Vincent Guittot <[email protected]>
> ---
>  kernel/sched/fair.c  | 24 +++++++++++++++++++++---
>  kernel/sched/idle.c  |  6 ++++++
>  kernel/sched/sched.h |  5 +++++
>  3 files changed, 32 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 5d285d93e433..cd0ea635225e 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -10453,6 +10453,24 @@ static bool nohz_idle_balance(struct rq *this_rq, 
> enum cpu_idle_type idle)
>       return true;
>  }
>
> +/*
> + * Check if we need to run the ILB for updating blocked load before entering
> + * idle state.
> + */
> +void nohz_run_idle_balance(int cpu)
> +{
> +     unsigned int flags;
> +
> +     flags = atomic_fetch_andnot(NOHZ_KICK_MASK, nohz_flags(cpu));
> +
> +     if (flags && !need_resched()) {
> +             struct rq *rq = cpu_rq(cpu);
> +
> +             rq->nohz_idle_balance = flags;
> +             nohz_idle_balance(rq, CPU_IDLE);
> +     }

So this can now run a full fledged nohz_idle_balance() if NOHZ_BALANCE_MASK
is set.

I don't think there is anything inherently wrong with it - the
nohz_idle_balance() call resulting from the kick_ilb() IPI will just bail
out due to the flags being cleared here. This wasn't immediately clear to
me however.

> +}
> +

Reply via email to