OSDN Git Service

rcu/nocb: Avoid confusing double write of rdp->nocb_cb_sleep
authorFrederic Weisbecker <frederic@kernel.org>
Thu, 28 Jan 2021 17:12:12 +0000 (18:12 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 8 Mar 2021 22:20:21 +0000 (14:20 -0800)
commit8a682b3974c36853b52fc8ede14dee966e96e19f
treea2c370f54d2e61431485efc863c6a2115cc9de06
parent64305db2856b969a5d48e8f3a5b0d06b5594591c
rcu/nocb: Avoid confusing double write of rdp->nocb_cb_sleep

The nocb_cb_wait() function first sets the rdp->nocb_cb_sleep flag to
true by after invoking the callbacks, and then sets it back to false if
it finds more callbacks that are ready to invoke.

This is confusing and will become unsafe if this flag is ever read
locklessly.  This commit therefore writes it only once, based on the
state after both callback invocation and checking.

Reported-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Neeraj Upadhyay <neeraju@codeaurora.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/tree_plugin.h