From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
Sasha Levin <sashal@kernel.org>,
frederic@kernel.org, quic_neeraju@quicinc.com,
joel@joelfernandes.org, josh@joshtriplett.org,
boqun.feng@gmail.com, rcu@vger.kernel.org
Subject: [PATCH AUTOSEL 6.1 3/3] rcu: Mark rcu_cpu_kthread() accesses to ->rcu_cpu_has_work
Date: Sun, 2 Jul 2023 15:57:56 -0400 [thread overview]
Message-ID: <20230702195756.1793443-3-sashal@kernel.org> (raw)
In-Reply-To: <20230702195756.1793443-1-sashal@kernel.org>
From: "Paul E. McKenney" <paulmck@kernel.org>
[ Upstream commit a24c1aab652ebacf9ea62470a166514174c96fe1 ]
The rcu_data structure's ->rcu_cpu_has_work field can be modified by
any CPU attempting to wake up the rcuc kthread. Therefore, this commit
marks accesses to this field from the rcu_cpu_kthread() function.
This data race was reported by KCSAN. Not appropriate for backporting
due to failure being unlikely.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/rcu/tree.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index d03122f90cc48..0f07d44c389eb 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -2593,12 +2593,12 @@ static void rcu_cpu_kthread(unsigned int cpu)
*statusp = RCU_KTHREAD_RUNNING;
local_irq_disable();
work = *workp;
- *workp = 0;
+ WRITE_ONCE(*workp, 0);
local_irq_enable();
if (work)
rcu_core();
local_bh_enable();
- if (*workp == 0) {
+ if (!READ_ONCE(*workp)) {
trace_rcu_utilization(TPS("End CPU kthread@rcu_wait"));
*statusp = RCU_KTHREAD_WAITING;
return;
--
2.39.2
next prev parent reply other threads:[~2023-07-02 20:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-02 19:57 [PATCH AUTOSEL 6.1 1/3] rcu-tasks: Avoid pr_info() with spin lock in cblist_init_generic() Sasha Levin
2023-07-02 19:57 ` [PATCH AUTOSEL 6.1 2/3] rcu: Mark additional concurrent load from ->cpu_no_qs.b.exp Sasha Levin
2023-07-02 19:57 ` Sasha Levin [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-07-09 14:55 [PATCH AUTOSEL 6.1 1/3] rcu-tasks: Avoid pr_info() with spin lock in cblist_init_generic() Sasha Levin
2023-07-09 14:55 ` [PATCH AUTOSEL 6.1 3/3] rcu: Mark rcu_cpu_kthread() accesses to ->rcu_cpu_has_work Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230702195756.1793443-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=quic_neeraju@quicinc.com \
--cc=rcu@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.