From fe3f6208a00f39df1c20c9e18bd55576ee1a1bd9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 8 Oct 2003 17:42:12 -0700 Subject: [PATCH] [PATCH] More barriers in module code. Paul McKenney convinced me that there's no *guarantee* that all archs will refuse the speculate the atomic ops above the state test, eg: CPU0 (stopref_set_state) CPU1 (stopref) atomic_set(&ack, 0); if (state == XXX) wmb(); atomic_inc(&ack); state = XXX; Certainly Alpha needs a rmb() inside stopref to guarantee it sees the same ordering. --- kernel/module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/module.c b/kernel/module.c index e7fa84bc231b6..e87659e3b3e48 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -485,6 +485,7 @@ static int stopref(void *cpu) set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu)); /* Ack: we are alive */ + mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ atomic_inc(&stopref_thread_ack); /* Simple state machine */ @@ -493,11 +494,13 @@ static int stopref(void *cpu) local_irq_disable(); irqs_disabled = 1; /* Ack: irqs disabled. */ + mb(); /* Must read state first. */ atomic_inc(&stopref_thread_ack); } else if (stopref_state == STOPREF_PREPARE && !prepared) { /* Everyone is in place, hold CPU. */ preempt_disable(); prepared = 1; + mb(); /* Must read state first. */ atomic_inc(&stopref_thread_ack); } if (irqs_disabled || prepared) @@ -507,6 +510,7 @@ static int stopref(void *cpu) } /* Ack: we are exiting. */ + mb(); /* Must read state first. */ atomic_inc(&stopref_thread_ack); if (irqs_disabled) -- 2.53.0