Re: [RFC][PATCH] stop_machine: Fix deadlock between multiple stop_two_cpus()

From: Rik van Riel
Date: Fri Jun 05 2015 - 13:08:28 EST


On 06/05/2015 11:30 AM, Peter Zijlstra wrote:
>
> Jiri reported a machine stuck in multi_cpu_stop() with
> migrate_swap_stop() as function and with the following src,dst cpu
> pairs: {11, 4} {13, 11} { 4, 13}
>
> 4 11 13
>
> cpuM: queue(4 ,13)
> *Ma
> cpuN: queue(13,11)
> *N Na
> *M Mb
> cpuO: queue(11, 4)
> *O Oa
> *Nb
> *Ob
>
> Where *X denotes the cpu running the queueing of cpu-X and X[ab] denotes
> the first/second queued work.
>
> You'll observe the top of the workqueue for each cpu: 4,11,13 to be work
> from cpus: M, O, N resp. IOW. deadlock.
>
> Do away with the queueing trickery and introduce lg_double_lock() to
> lock both CPUs and fully serialize the stop_two_cpus() callers instead
> of the partial (and buggy) serialization we have now.
>
> Completely untested..
>
> Reported-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

Certainly looks like it would work.

I suspect we should probably apply this patch after some basic
testing, since the race is so incredibly hard to reproduce.

--
All rights reversed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/