stop_machine: Fix^2 race between stop_two_cpus() and stop_cpus()

We must use smp_call_function_single(.wait=1) for the
irq_cpu_stop_queue_work() to ensure the queueing is actually done under
stop_cpus_lock. Without this we could have dropped the lock by the time
we do the queueing and get the race we tried to fix.

Fixes: 7053ea1a34fa ("stop_machine: Fix race between stop_two_cpus() and stop_cpus()")

Signed-off-by: Peter Zijlstra <>
Cc: Prarit Bhargava <>
Cc: Rik van Riel <>
Cc: Mel Gorman <>
Cc: Christoph Hellwig <>
Cc: Andrew Morton <>
Signed-off-by: Ingo Molnar <>
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 84571e0..01fbae5 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -293,7 +293,7 @@
 	smp_call_function_single(min(cpu1, cpu2),
-				 &call_args, 0);
+				 &call_args, 1);