rcu/nocb: Protect lazy shrinker against concurrent (de-)offloading
authorFrederic Weisbecker <frederic@kernel.org>
Wed, 29 Mar 2023 16:02:00 +0000 (18:02 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Wed, 10 May 2023 00:26:58 +0000 (17:26 -0700)
commit5c83cedbaaad6dfe290e50658a204556ac5ac683
treea469152744094c2a5770624c6e48df85791996f7
parentac9a78681b921877518763ba0e89202254349d1b
rcu/nocb: Protect lazy shrinker against concurrent (de-)offloading

The shrinker may run concurrently with callbacks (de-)offloading. As
such, calling rcu_nocb_lock() is very dangerous because it does a
conditional locking. The worst outcome is that rcu_nocb_lock() doesn't
lock but rcu_nocb_unlock() eventually unlocks, or the reverse, creating
an imbalance.

Fix this with protecting against (de-)offloading using the barrier mutex.
Although if the barrier mutex is contended, which should be rare, then
step aside so as not to trigger a mutex VS allocation
dependency chain.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/tree_nocb.h