Re: [PATCH RT] sched: migrate_enable: Busy loop until the migration request is completed

From: Sebastian Andrzej Siewior
Date: Fri Dec 13 2019 - 03:14:34 EST


On 2019-12-13 00:44:22 [-0600], Scott Wood wrote:
> > @@ -8239,7 +8239,10 @@ void migrate_enable(void)
> > stop_one_cpu_nowait(task_cpu(p), migration_cpu_stop,
> > &arg, &work);
> > __schedule(true);
> > - WARN_ON_ONCE(!arg.done && !work.disabled);
> > + if (!work.disabled) {
> > + while (!arg.done)
> > + cpu_relax();
> > + }
>
> We should enable preemption while spinning -- besides the general badness
> of spinning with it disabled, there could be deadlock scenarios if
> multiple CPUs are spinning in such a loop. Long term maybe have a way to
> dequeue the no-longer-needed work instead of waiting.

Hmm. My plan was to use per-CPU memory and spin before the request is
enqueued if the previous isn't done yet (which should not happenâ).
Then we could remove __schedule() here and rely on preempt_enable()
doing that. With that change we wouldn't care about migrate-disable
level vs preempt-disable level and could drop the hacks we have in futex
code for instance (where we have an extra migrate_disable() in advance
so they are later balanced).

> -Scott

Sebastian