Re: [PATCH -v2 03/17] sched/hotplug: Ensure only per-cpu kthreads run during hotplug

From: Peter Zijlstra
Date: Tue Oct 06 2020 - 03:26:08 EST


On Mon, Oct 05, 2020 at 04:57:20PM +0200, Peter Zijlstra wrote:
> +static inline void balance_switch(struct rq *rq)
> +{
> + if (unlikely(rq->balance_flags)) {
> + /*
> + * Run the balance_callbacks, except on hotplug
> + * when we need to push the current task away.
> + */
> + if (!IS_ENABLED(CONFIG_HOTPLUG_CPU) ||
> + !(rq->balance_flags & BALANCE_PUSH) ||
> + !balance_push(rq))
> + __balance_callbacks(rq);
> + }
> +}

> @@ -1392,12 +1396,13 @@ queue_balance_callback(struct rq *rq,
> {
> lockdep_assert_held(&rq->lock);
>
> - if (unlikely(head->next))
> + if (unlikely(head->next || (rq->balance_flags & BALANCE_PUSH)))
> return;

With this bit from Valentin we can probably simplify the above function,
but I've not thought about that yet.