From 1d9ca4ce575a31bb95c123974b12bf1cd98b3c29 Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Fri, 3 Jul 2009 08:30:27 -0500
Subject: [PATCH 099/365] stop_machine: convert stop_machine_run() to
 PREEMPT_RT

Instead of playing with non-preemption, introduce explicit
startup serialization. This is more robust and cleaner as
well.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[bigeasy: XXX: stopper_lock -> stop_cpus_lock]
---
 kernel/stop_machine.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index a3bbaee77c58..4ef69a3cc811 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -450,6 +450,16 @@ repeat:
 		struct cpu_stop_done *done = work->done;
 		char ksym_buf[KSYM_NAME_LEN] __maybe_unused;
 
+		/*
+		 * Wait until the stopper finished scheduling on all
+		 * cpus
+		 */
+		lg_global_lock(&stop_cpus_lock);
+		/*
+		 * Let other cpu threads continue as well
+		 */
+		lg_global_unlock(&stop_cpus_lock);
+
 		/* cpu stop callbacks are not allowed to sleep */
 		preempt_disable();
 
-- 
2.10.2

