Skip to content

Commit 2906d21

Browse files
committed
rcu: Add WRITE_ONCE() to rcu_state ->gp_req_activity
The rcu_state structure's ->gp_req_activity field is read locklessly, so this commit adds the WRITE_ONCE() to an update in order to provide proper documentation and READ_ONCE()/WRITE_ONCE() pairing. This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 0937d04 commit 2906d21

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/rcu/tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ static bool rcu_start_this_gp(struct rcu_node *rnp_start, struct rcu_data *rdp,
12001200
}
12011201
trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("Startedroot"));
12021202
WRITE_ONCE(rcu_state.gp_flags, rcu_state.gp_flags | RCU_GP_FLAG_INIT);
1203-
rcu_state.gp_req_activity = jiffies;
1203+
WRITE_ONCE(rcu_state.gp_req_activity, jiffies);
12041204
if (!rcu_state.gp_kthread) {
12051205
trace_rcu_this_gp(rnp, rdp, gp_seq_req, TPS("NoGPkthread"));
12061206
goto unlock_out;
@@ -1775,7 +1775,7 @@ static void rcu_gp_cleanup(void)
17751775
rcu_segcblist_is_offloaded(&rdp->cblist);
17761776
if ((offloaded || !rcu_accelerate_cbs(rnp, rdp)) && needgp) {
17771777
WRITE_ONCE(rcu_state.gp_flags, RCU_GP_FLAG_INIT);
1778-
rcu_state.gp_req_activity = jiffies;
1778+
WRITE_ONCE(rcu_state.gp_req_activity, jiffies);
17791779
trace_rcu_grace_period(rcu_state.name,
17801780
READ_ONCE(rcu_state.gp_seq),
17811781
TPS("newreq"));

0 commit comments

Comments
 (0)