Re: [PATCH -v3 8/9] sched: Fix CPU hotplug / tighten is_per_cpu_kthread()

From: Peter Zijlstra
Date: Thu Jan 21 2021 - 09:26:36 EST


On Thu, Jan 21, 2021 at 02:01:03PM +0000, Valentin Schneider wrote:
> On 21/01/21 11:17, Peter Zijlstra wrote:
> > @@ -7504,6 +7525,9 @@ int sched_cpu_deactivate(unsigned int cp
> > * preempt-disabled and RCU users of this state to go away such that
> > * all new such users will observe it.
> > *
> > + * Specifically, we rely on ttwu to no longer target this CPU, see
> > + * ttwu_queue_cond() and is_cpu_allowed().
> > + *
>
> So the last time ttwu_queue_wakelist() can append a task onto a dying
> CPU's wakelist is before sched_cpu_deactivate()'s synchronize_rcu()
> returns.
>
> As discussed on IRC, paranoia would have us issue a
>
> flush_smp_call_function_from_idle()
>
> upon returning from said sync, but this will require further surgery.

Right, specifically RCU needs a little more help there.

> Do we want something like the below in the meantime? Ideally we'd warn on
> setting rq->ttwu_pending when !cpu_active(), but as per the above this is
> allowed before the synchronize_rcu() returns.

I'm not sure I'm brave enough to add that just now :/