aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2012-01-04 16:30:33 -0500
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2012-02-21 12:03:23 -0500
commitfe15d706cfc1cb321dbe2329b04b5ca185edff60 (patch)
treebec14ab52167f4f0210e8c207c93922c8270402f /kernel
parent18fec7d8758dd416904da205375e6fa667defc80 (diff)
rcu: Add lockdep-RCU checks for simple self-deadlock
It is illegal to have a grace period within a same-flavor RCU read-side critical section, so this commit adds lockdep-RCU checks to splat when such abuse is encountered. This commit does not detect more elaborate RCU deadlock situations. These situations might be a job for lockdep enhancements. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/rcutiny.c4
-rw-r--r--kernel/rcutiny_plugin.h5
-rw-r--r--kernel/rcutree.c8
-rw-r--r--kernel/rcutree_plugin.h4
-rw-r--r--kernel/srcu.c6
5 files changed, 27 insertions, 0 deletions
diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
index 977296dca0a4..8e00d461911e 100644
--- a/kernel/rcutiny.c
+++ b/kernel/rcutiny.c
@@ -319,6 +319,10 @@ static void rcu_process_callbacks(struct softirq_action *unused)
319 */ 319 */
320void synchronize_sched(void) 320void synchronize_sched(void)
321{ 321{
322 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
323 !lock_is_held(&rcu_lock_map) &&
324 !lock_is_held(&rcu_sched_lock_map),
325 "Illegal synchronize_sched() in RCU read-side critical section");
322 cond_resched(); 326 cond_resched();
323} 327}
324EXPORT_SYMBOL_GPL(synchronize_sched); 328EXPORT_SYMBOL_GPL(synchronize_sched);
diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
index 9cb1ae4aabdd..4b905404a5bd 100644
--- a/kernel/rcutiny_plugin.h
+++ b/kernel/rcutiny_plugin.h
@@ -706,6 +706,11 @@ EXPORT_SYMBOL_GPL(call_rcu);
706 */ 706 */
707void synchronize_rcu(void) 707void synchronize_rcu(void)
708{ 708{
709 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
710 !lock_is_held(&rcu_lock_map) &&
711 !lock_is_held(&rcu_sched_lock_map),
712 "Illegal synchronize_rcu() in RCU read-side critical section");
713
709#ifdef CONFIG_DEBUG_LOCK_ALLOC 714#ifdef CONFIG_DEBUG_LOCK_ALLOC
710 if (!rcu_scheduler_active) 715 if (!rcu_scheduler_active)
711 return; 716 return;
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 6c4a6722abfd..3cf713a724c1 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -1816,6 +1816,10 @@ EXPORT_SYMBOL_GPL(call_rcu_bh);
1816 */ 1816 */
1817void synchronize_sched(void) 1817void synchronize_sched(void)
1818{ 1818{
1819 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
1820 !lock_is_held(&rcu_lock_map) &&
1821 !lock_is_held(&rcu_sched_lock_map),
1822 "Illegal synchronize_sched() in RCU-sched read-side critical section");
1819 if (rcu_blocking_is_gp()) 1823 if (rcu_blocking_is_gp())
1820 return; 1824 return;
1821 wait_rcu_gp(call_rcu_sched); 1825 wait_rcu_gp(call_rcu_sched);
@@ -1833,6 +1837,10 @@ EXPORT_SYMBOL_GPL(synchronize_sched);
1833 */ 1837 */
1834void synchronize_rcu_bh(void) 1838void synchronize_rcu_bh(void)
1835{ 1839{
1840 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
1841 !lock_is_held(&rcu_lock_map) &&
1842 !lock_is_held(&rcu_sched_lock_map),
1843 "Illegal synchronize_rcu_bh() in RCU-bh read-side critical section");
1836 if (rcu_blocking_is_gp()) 1844 if (rcu_blocking_is_gp())
1837 return; 1845 return;
1838 wait_rcu_gp(call_rcu_bh); 1846 wait_rcu_gp(call_rcu_bh);
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index 8bb35d73e1f9..3680b6b35bf3 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -688,6 +688,10 @@ EXPORT_SYMBOL_GPL(call_rcu);
688 */ 688 */
689void synchronize_rcu(void) 689void synchronize_rcu(void)
690{ 690{
691 rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map) &&
692 !lock_is_held(&rcu_lock_map) &&
693 !lock_is_held(&rcu_sched_lock_map),
694 "Illegal synchronize_rcu() in RCU read-side critical section");
691 if (!rcu_scheduler_active) 695 if (!rcu_scheduler_active)
692 return; 696 return;
693 wait_rcu_gp(call_rcu); 697 wait_rcu_gp(call_rcu);
diff --git a/kernel/srcu.c b/kernel/srcu.c
index 0febf61e1aa3..3f99fa0e8ed3 100644
--- a/kernel/srcu.c
+++ b/kernel/srcu.c
@@ -172,6 +172,12 @@ static void __synchronize_srcu(struct srcu_struct *sp, void (*sync_func)(void))
172{ 172{
173 int idx; 173 int idx;
174 174
175 rcu_lockdep_assert(!lock_is_held(&sp->dep_map) &&
176 !lock_is_held(&rcu_bh_lock_map) &&
177 !lock_is_held(&rcu_lock_map) &&
178 !lock_is_held(&rcu_sched_lock_map),
179 "Illegal synchronize_srcu() in same-type SRCU (or RCU) read-side critical section");
180
175 idx = sp->completed; 181 idx = sp->completed;
176 mutex_lock(&sp->mutex); 182 mutex_lock(&sp->mutex);
177 183