[tip/core/rcu,07/12] stop_machine: Use {READ,WRITE)_ONCE() for multi_cpu_stop() ->state
diff mbox series

Message ID 20191003013903.13079-7-paulmck@kernel.org
State New
Headers show
Series
  • NO_HZ fixes for v5.5
Related show

Commit Message

Paul E. McKenney Oct. 3, 2019, 1:38 a.m. UTC
From: "Paul E. McKenney" <paulmck@linux.ibm.com>

The multi_stop_data structure's ->state field is updated and read
concurrently, so this commit replaces the current C-language accesses
with READ_ONCE() and WRITE_ONCE().

Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
---
 kernel/stop_machine.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 34c4f11..c02c56e 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -167,7 +167,7 @@  static void set_state(struct multi_stop_data *msdata,
 	/* Reset ack counter. */
 	atomic_set(&msdata->thread_ack, msdata->num_threads);
 	smp_wmb();
-	msdata->state = newstate;
+	WRITE_ONCE(msdata->state, newstate);
 }
 
 /* Last one to ack a state moves to the next state. */
@@ -210,8 +210,8 @@  static int multi_cpu_stop(void *data)
 	do {
 		/* Chill out and ensure we re-read multi_stop_state. */
 		stop_machine_yield(cpumask);
-		if (msdata->state != curstate) {
-			curstate = msdata->state;
+		if (READ_ONCE(msdata->state) != curstate) {
+			curstate = READ_ONCE(msdata->state);
 			switch (curstate) {
 			case MULTI_STOP_DISABLE_IRQ:
 				local_irq_disable();