aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-12-16 14:21:05 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-17 03:46:44 -0500
commit234da7bcdc7aaa935846534c3b726dbc79a9cdd5 (patch)
treea391afd465d6493a9f1bb274c225bab4d303aad0 /kernel/sched.c
parent416eb39556a03d1c7e52b0791e9052ccd71db241 (diff)
sched: Teach might_sleep() about preemptible RCU
In practice, it is harmless to voluntarily sleep in a rcu_read_lock() section if we are running under preempt rcu, but it is illegal if we build a kernel running non-preemptable rcu. Currently, might_sleep() doesn't notice sleepable operations under rcu_read_lock() sections if we are running under preemptable rcu because preempt_count() is left untouched after rcu_read_lock() in this case. But we want developers who test their changes under such config to notice the "sleeping while atomic" issues. So we add rcu_read_lock_nesting to prempt_count() in might_sleep() checks. [ v2: Handle rcu-tiny ] Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <1260991265-8451-1-git-send-regression-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index af7dfa74e6bb..7be88a7be047 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9682,7 +9682,7 @@ void __init sched_init(void)
9682#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP 9682#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
9683static inline int preempt_count_equals(int preempt_offset) 9683static inline int preempt_count_equals(int preempt_offset)
9684{ 9684{
9685 int nested = preempt_count() & ~PREEMPT_ACTIVE; 9685 int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
9686 9686
9687 return (nested == PREEMPT_INATOMIC_BASE + preempt_offset); 9687 return (nested == PREEMPT_INATOMIC_BASE + preempt_offset);
9688} 9688}