Commit d902db1e authored by Frederic Weisbecker's avatar Frederic Weisbecker

sched: Generalize sleep inside spinlock detection

The sleeping inside spinlock detection is actually used
for more general sleeping inside atomic sections
debugging: preemption disabled, rcu read side critical
sections, interrupts, interrupt disabled, etc...

Change the name of the config and its help section to
reflect its more general role.
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Acked-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
parent e8f7c70f
...@@ -409,7 +409,7 @@ cond_resched(); /* Will sleep */ ...@@ -409,7 +409,7 @@ cond_resched(); /* Will sleep */
<para> <para>
You should always compile your kernel You should always compile your kernel
<symbol>CONFIG_DEBUG_SPINLOCK_SLEEP</symbol> on, and it will warn <symbol>CONFIG_DEBUG_ATOMIC_SLEEP</symbol> on, and it will warn
you if you break these rules. If you <emphasis>do</emphasis> break you if you break these rules. If you <emphasis>do</emphasis> break
the rules, you will eventually lock up your box. the rules, you will eventually lock up your box.
</para> </para>
......
...@@ -53,7 +53,7 @@ kernel patches. ...@@ -53,7 +53,7 @@ kernel patches.
12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, 12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES,
CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_SPINLOCK_SLEEP all simultaneously CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_ATOMIC_SLEEP all simultaneously
enabled. enabled.
13: Has been build- and runtime tested with and without CONFIG_SMP and 13: Has been build- and runtime tested with and without CONFIG_SMP and
......
...@@ -244,7 +244,7 @@ testing purposes. In particular, you should turn on: ...@@ -244,7 +244,7 @@ testing purposes. In particular, you should turn on:
- DEBUG_SLAB can find a variety of memory allocation and use errors; it - DEBUG_SLAB can find a variety of memory allocation and use errors; it
should be used on most development kernels. should be used on most development kernels.
- DEBUG_SPINLOCK, DEBUG_SPINLOCK_SLEEP, and DEBUG_MUTEXES will find a - DEBUG_SPINLOCK, DEBUG_ATOMIC_SLEEP, and DEBUG_MUTEXES will find a
number of common locking errors. number of common locking errors.
There are quite a few other debugging options, some of which will be There are quite a few other debugging options, some of which will be
......
...@@ -68,7 +68,7 @@ Linux カーネルパッチ投稿者向けチェックリスト ...@@ -68,7 +68,7 @@ Linux カーネルパッチ投稿者向けチェックリスト
12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB, 12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB,
CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK,
CONFIG_DEBUG_SPINLOCK_SLEEP これら全てを同時に有効にして動作確認を CONFIG_DEBUG_ATOMIC_SLEEP これら全てを同時に有効にして動作確認を
行ってください。 行ってください。
13: CONFIG_SMP, CONFIG_PREEMPT を有効にした場合と無効にした場合の両方で 13: CONFIG_SMP, CONFIG_PREEMPT を有効にした場合と無効にした場合の両方で
......
...@@ -67,7 +67,7 @@ Linux ...@@ -67,7 +67,7 @@ Linux
12:已经通过CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, 12:已经通过CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES,
CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_SPINLOCK_SLEEP测试,并且同时都 CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_ATOMIC_SLEEP测试,并且同时都
使能。 使能。
13:已经都构建并且使用或者不使用 CONFIG_SMP 和 CONFIG_PREEMPT测试执行时间。 13:已经都构建并且使用或者不使用 CONFIG_SMP 和 CONFIG_PREEMPT测试执行时间。
......
...@@ -121,7 +121,7 @@ extern int _cond_resched(void); ...@@ -121,7 +121,7 @@ extern int _cond_resched(void);
# define might_resched() do { } while (0) # define might_resched() do { } while (0)
#endif #endif
#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
void __might_sleep(const char *file, int line, int preempt_offset); void __might_sleep(const char *file, int line, int preempt_offset);
/** /**
* might_sleep - annotation for functions that can sleep * might_sleep - annotation for functions that can sleep
......
...@@ -8018,7 +8018,7 @@ void __init sched_init(void) ...@@ -8018,7 +8018,7 @@ void __init sched_init(void)
scheduler_running = 1; scheduler_running = 1;
} }
#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
static inline int preempt_count_equals(int preempt_offset) static inline int preempt_count_equals(int preempt_offset)
{ {
int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth(); int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
......
...@@ -648,13 +648,15 @@ config TRACE_IRQFLAGS ...@@ -648,13 +648,15 @@ config TRACE_IRQFLAGS
Enables hooks to interrupt enabling and disabling for Enables hooks to interrupt enabling and disabling for
either tracing or lock debugging. either tracing or lock debugging.
config DEBUG_SPINLOCK_SLEEP config DEBUG_ATOMIC_SLEEP
bool "Spinlock debugging: sleep-inside-spinlock checking" bool "Sleep inside atomic section checking"
select PREEMPT_COUNT select PREEMPT_COUNT
depends on DEBUG_KERNEL depends on DEBUG_KERNEL
help help
If you say Y here, various routines which may sleep will become very If you say Y here, various routines which may sleep will become very
noisy if they are called with a spinlock held. noisy if they are called inside atomic sections: when a spinlock is
held, inside an rcu read side critical section, inside preempt disabled
sections, inside an interrupt, etc...
config DEBUG_LOCKING_API_SELFTESTS config DEBUG_LOCKING_API_SELFTESTS
bool "Locking API boot-time self-tests" bool "Locking API boot-time self-tests"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment