]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rcu: Use READ_ONCE() for lockless read of rnp->qsmask
authorJoel Fernandes (Google) <joel@joelfernandes.org>
Sat, 17 Sep 2022 16:41:58 +0000 (16:41 +0000)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 18 Oct 2022 21:59:57 +0000 (14:59 -0700)
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 <frederic@kernel.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/tree.c

index 0ca21ac0f0648af61d531604599a04d84de07499..5ec97e3f7468fe090f2f2d6e5495962d7353e4c5 100644 (file)
@@ -2106,7 +2106,7 @@ int rcutree_dying_cpu(unsigned int cpu)
        if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
                return 0;
 
-       blkd = !!(rnp->qsmask & rdp->grpmask);
+       blkd = !!(READ_ONCE(rnp->qsmask) & rdp->grpmask);
        trace_rcu_grace_period(rcu_state.name, READ_ONCE(rnp->gp_seq),
                               blkd ? TPS("cpuofl-bgp") : TPS("cpuofl"));
        return 0;