[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_5D8919B7D1F21906868DE81406015360270A@qq.com>
Date: Wed, 6 Mar 2024 10:05:20 +0800
From: linke li <lilinke99@...com>
To:
Cc: lilinke99@...com,
Joel Fernandes <joel@...lfernandes.org>,
Davidlohr Bueso <dave@...olabs.net>,
"Paul E. McKenney" <paulmck@...nel.org>,
Josh Triplett <josh@...htriplett.org>,
Frederic Weisbecker <frederic@...nel.org>,
Neeraj Upadhyay <quic_neeraju@...cinc.com>,
Boqun Feng <boqun.feng@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>,
Zqiang <qiang.zhang1211@...il.com>,
linux-kernel@...r.kernel.org,
rcu@...r.kernel.org
Subject: [PATCH v2] rcutorture: Reuse value read using READ_ONCE instead of re-reading it
rp->rtort_pipe_count is modified concurrently by rcu_torture_writer(). To
prevent a data race, reuse i which is read using READ_ONCE before instead
of re-reading it.
Signed-off-by: linke li <lilinke99@...com>
Reviewed-by: Joel Fernandes (Google) <joel@...lfernandes.org>
---
v1 -> v2: change the patch to focus on data race in rcu_torture_pipe_update_one ; update change log
kernel/rcu/rcutorture.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 7567ca8e743c..53415121be39 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -466,7 +466,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp)
i = RCU_TORTURE_PIPE_LEN;
atomic_inc(&rcu_torture_wcount[i]);
WRITE_ONCE(rp->rtort_pipe_count, i + 1);
- if (rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
+ if (i + 1 >= RCU_TORTURE_PIPE_LEN) {
rp->rtort_mbtest = 0;
return true;
}
--
2.39.3 (Apple Git-145)
Powered by blists - more mailing lists