summaryrefslogtreecommitdiffstats
path: root/kernel/rcu
diff options
context:
space:
mode:
authorZqiang <qiang1.zhang@intel.com>2022-11-09 15:36:38 +0800
committerPaul E. McKenney <paulmck@kernel.org>2022-12-01 15:49:12 -0800
commit51f5f78a4f804aeb73cf12a7cbba6e5198abd908 (patch)
treedd26106fc99481083dffc714542e17214fcd2c10 /kernel/rcu
parent0cd7e350abc40eed5d3b60292dc102f700c88388 (diff)
downloadlinux-stable-51f5f78a4f804aeb73cf12a7cbba6e5198abd908.tar.gz
linux-stable-51f5f78a4f804aeb73cf12a7cbba6e5198abd908.tar.bz2
linux-stable-51f5f78a4f804aeb73cf12a7cbba6e5198abd908.zip
srcu: Make Tiny synchronize_srcu() check for readers
This commit adds lockdep checks for illegal use of synchronize_srcu() within same-type SRCU read-side critical sections and within normal RCU read-side critical sections. It also makes synchronize_srcu() be a no-op during early boot. These changes bring Tiny synchronize_srcu() into line with both Tree synchronize_srcu() and Tiny synchronize_rcu(). Signed-off-by: Zqiang <qiang1.zhang@intel.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Tested-by: John Ogness <john.ogness@linutronix.de>
Diffstat (limited to 'kernel/rcu')
-rw-r--r--kernel/rcu/srcutiny.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
index 33adafdad261..b12fb0cec44d 100644
--- a/kernel/rcu/srcutiny.c
+++ b/kernel/rcu/srcutiny.c
@@ -197,6 +197,16 @@ void synchronize_srcu(struct srcu_struct *ssp)
{
struct rcu_synchronize rs;
+ RCU_LOCKDEP_WARN(lockdep_is_held(ssp) ||
+ lock_is_held(&rcu_bh_lock_map) ||
+ lock_is_held(&rcu_lock_map) ||
+ lock_is_held(&rcu_sched_lock_map),
+ "Illegal synchronize_srcu() in same-type SRCU (or in RCU) read-side critical section");
+
+ if (rcu_scheduler_active == RCU_SCHEDULER_INACTIVE)
+ return;
+
+ might_sleep();
init_rcu_head_on_stack(&rs.head);
init_completion(&rs.completion);
call_srcu(ssp, &rs.head, wakeme_after_rcu);