Skip to content

Commit dbef46a

Browse files
joelagnelpaulmckrcu
authored andcommitted
rcu: Use READ_ONCE() for lockless read of rnp->qsmask
The rnp->qsmask is locklessly accessed from rcutree_dying_cpu(). This may help avoid load tearing due to concurrent access, KCSAN issues, and preserve sanity of people reading the mask in tracing. Reviewed-by: Frederic Weisbecker <[email protected]> Signed-off-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent b39a920 commit dbef46a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/rcu/tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ int rcutree_dying_cpu(unsigned int cpu)
21062106
if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
21072107
return 0;
21082108

2109-
blkd = !!(rnp->qsmask & rdp->grpmask);
2109+
blkd = !!(READ_ONCE(rnp->qsmask) & rdp->grpmask);
21102110
trace_rcu_grace_period(rcu_state.name, READ_ONCE(rnp->gp_seq),
21112111
blkd ? TPS("cpuofl-bgp") : TPS("cpuofl"));
21122112
return 0;

0 commit comments

Comments
 (0)