lkml.org 
[lkml]   [2023]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] stop_machine: Apply smp_store_release() to multi_stop_data::state
Date
From: Rong Tao <rongtao@cestc.cn>

Replace smp_wmb()+WRITE_ONCE() with smp_store_release() and add comment.

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
kernel/stop_machine.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 268c2e581698..cdf4a3fe0348 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -183,8 +183,10 @@ static void set_state(struct multi_stop_data *msdata,
{
/* Reset ack counter. */
atomic_set(&msdata->thread_ack, msdata->num_threads);
- smp_wmb();
- WRITE_ONCE(msdata->state, newstate);
+ /* This smp_store_release() pair with READ_ONCE() in multi_cpu_stop().
+ * Avoid potential access multi_stop_data::state race behaviour.
+ */
+ smp_store_release(&msdata->state, newstate);
}

/* Last one to ack a state moves to the next state. */
--
2.41.0
\
 
 \ /
  Last update: 2023-10-20 16:58    [W:3.604 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site