public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/4] sched: Generalize sleep inside spinlock detection
  2011-06-08 17:48 [PATCH 0/4] " Frederic Weisbecker
@ 2011-06-08 17:48 ` Frederic Weisbecker
  2011-06-08 19:41   ` Paul E. McKenney
  0 siblings, 1 reply; 20+ messages in thread
From: Frederic Weisbecker @ 2011-06-08 17:48 UTC (permalink / raw)
  To: LKML
  Cc: Frederic Weisbecker, Paul E. McKenney, Peter Zijlstra,
	Ingo Molnar, Randy Dunlap

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 5949 bytes --]

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: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
---
 Documentation/DocBook/kernel-hacking.tmpl  |    2 +-
 Documentation/SubmitChecklist              |    2 +-
 Documentation/development-process/4.Coding |    2 +-
 Documentation/ja_JP/SubmitChecklist        |    2 +-
 Documentation/zh_CN/SubmitChecklist        |    2 +-
 include/linux/kernel.h                     |    2 +-
 kernel/sched.c                             |    2 +-
 lib/Kconfig.debug                          |    8 +++++---
 8 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl
index 7b3f493..07a9c48 100644
--- a/Documentation/DocBook/kernel-hacking.tmpl
+++ b/Documentation/DocBook/kernel-hacking.tmpl
@@ -409,7 +409,7 @@ cond_resched(); /* Will sleep */
 
   <para>
    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
    the rules, you will eventually lock up your box.
   </para>
diff --git a/Documentation/SubmitChecklist b/Documentation/SubmitChecklist
index da0382d..7b13be4 100644
--- a/Documentation/SubmitChecklist
+++ b/Documentation/SubmitChecklist
@@ -53,7 +53,7 @@ kernel patches.
 
 12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
     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.
 
 13: Has been build- and runtime tested with and without CONFIG_SMP and
diff --git a/Documentation/development-process/4.Coding b/Documentation/development-process/4.Coding
index f3f1a46..83f5f5b 100644
--- a/Documentation/development-process/4.Coding
+++ b/Documentation/development-process/4.Coding
@@ -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
    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.
 
 There are quite a few other debugging options, some of which will be
diff --git a/Documentation/ja_JP/SubmitChecklist b/Documentation/ja_JP/SubmitChecklist
index 2df4576..cb5507b 100644
--- a/Documentation/ja_JP/SubmitChecklist
+++ b/Documentation/ja_JP/SubmitChecklist
@@ -68,7 +68,7 @@ Linux カーネルパッチ投稿者向けチェックリスト
 
 12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB,
     CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK,
-    CONFIG_DEBUG_SPINLOCK_SLEEP これら全てを同時に有効にして動作確認を
+    CONFIG_DEBUG_ATOMIC_SLEEP これら全てを同時に有効にして動作確認を
     行ってください。
 
 13: CONFIG_SMP, CONFIG_PREEMPT を有効にした場合と無効にした場合の両方で
diff --git a/Documentation/zh_CN/SubmitChecklist b/Documentation/zh_CN/SubmitChecklist
index 951415b..4c741d6 100644
--- a/Documentation/zh_CN/SubmitChecklist
+++ b/Documentation/zh_CN/SubmitChecklist
@@ -67,7 +67,7 @@ Linux
 
 12£ºÒѾ­Í¨¹ýCONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
     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²âÊÔÖ´ÐÐʱ¼ä¡£
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fb0e732..24b489f 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -121,7 +121,7 @@ extern int _cond_resched(void);
 # define might_resched() do { } while (0)
 #endif
 
-#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
   void __might_sleep(const char *file, int line, int preempt_offset);
 /**
  * might_sleep - annotation for functions that can sleep
diff --git a/kernel/sched.c b/kernel/sched.c
index 90ad7cf..a5f318b 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -8018,7 +8018,7 @@ void __init sched_init(void)
 	scheduler_running = 1;
 }
 
-#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
 static inline int preempt_count_equals(int preempt_offset)
 {
 	int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a7dd7b5..81a4f33 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -648,13 +648,15 @@ config TRACE_IRQFLAGS
 	  Enables hooks to interrupt enabling and disabling for
 	  either tracing or lock debugging.
 
-config DEBUG_SPINLOCK_SLEEP
-	bool "Spinlock debugging: sleep-inside-spinlock checking"
+config DEBUG_ATOMIC_SLEEP
+	bool "Sleep inside atomic section checking"
 	select PREEMPT_COUNT
 	depends on DEBUG_KERNEL
 	help
 	  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
 	bool "Locking API boot-time self-tests"
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/4] sched: Generalize sleep inside spinlock detection
  2011-06-08 17:48 ` [PATCH 4/4] sched: Generalize sleep inside spinlock detection Frederic Weisbecker
@ 2011-06-08 19:41   ` Paul E. McKenney
  0 siblings, 0 replies; 20+ messages in thread
From: Paul E. McKenney @ 2011-06-08 19:41 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: LKML, Peter Zijlstra, Ingo Molnar, Randy Dunlap

On Wed, Jun 08, 2011 at 07:48:35PM +0200, Frederic Weisbecker wrote:
> 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: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Randy Dunlap <randy.dunlap@oracle.com>
> ---
>  Documentation/DocBook/kernel-hacking.tmpl  |    2 +-
>  Documentation/SubmitChecklist              |    2 +-
>  Documentation/development-process/4.Coding |    2 +-
>  Documentation/ja_JP/SubmitChecklist        |    2 +-
>  Documentation/zh_CN/SubmitChecklist        |    2 +-
>  include/linux/kernel.h                     |    2 +-
>  kernel/sched.c                             |    2 +-
>  lib/Kconfig.debug                          |    8 +++++---
>  8 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl
> index 7b3f493..07a9c48 100644
> --- a/Documentation/DocBook/kernel-hacking.tmpl
> +++ b/Documentation/DocBook/kernel-hacking.tmpl
> @@ -409,7 +409,7 @@ cond_resched(); /* Will sleep */
> 
>    <para>
>     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
>     the rules, you will eventually lock up your box.
>    </para>
> diff --git a/Documentation/SubmitChecklist b/Documentation/SubmitChecklist
> index da0382d..7b13be4 100644
> --- a/Documentation/SubmitChecklist
> +++ b/Documentation/SubmitChecklist
> @@ -53,7 +53,7 @@ kernel patches.
> 
>  12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
>      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.
> 
>  13: Has been build- and runtime tested with and without CONFIG_SMP and
> diff --git a/Documentation/development-process/4.Coding b/Documentation/development-process/4.Coding
> index f3f1a46..83f5f5b 100644
> --- a/Documentation/development-process/4.Coding
> +++ b/Documentation/development-process/4.Coding
> @@ -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
>     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.
> 
>  There are quite a few other debugging options, some of which will be
> diff --git a/Documentation/ja_JP/SubmitChecklist b/Documentation/ja_JP/SubmitChecklist
> index 2df4576..cb5507b 100644
> --- a/Documentation/ja_JP/SubmitChecklist
> +++ b/Documentation/ja_JP/SubmitChecklist
> @@ -68,7 +68,7 @@ Linux カーネルパッチ投稿者向けチェックリスト
> 
>  12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB,
>      CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK,
> -    CONFIG_DEBUG_SPINLOCK_SLEEP これら全てを同時に有効にして動作確認を
> +    CONFIG_DEBUG_ATOMIC_SLEEP これら全てを同時に有効にして動作確認を
>      行ってください。
> 
>  13: CONFIG_SMP, CONFIG_PREEMPT を有効にした場合と無効にした場合の両方で
> diff --git a/Documentation/zh_CN/SubmitChecklist b/Documentation/zh_CN/SubmitChecklist
> index 951415b..4c741d6 100644
> --- a/Documentation/zh_CN/SubmitChecklist
> +++ b/Documentation/zh_CN/SubmitChecklist
> @@ -67,7 +67,7 @@ Linux
> 
>  12???Ѿ?ͨ??CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
>      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????ִ??ʱ?䡣
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index fb0e732..24b489f 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -121,7 +121,7 @@ extern int _cond_resched(void);
>  # define might_resched() do { } while (0)
>  #endif
> 
> -#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
> +#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
>    void __might_sleep(const char *file, int line, int preempt_offset);
>  /**
>   * might_sleep - annotation for functions that can sleep
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 90ad7cf..a5f318b 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -8018,7 +8018,7 @@ void __init sched_init(void)
>  	scheduler_running = 1;
>  }
> 
> -#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
> +#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
>  static inline int preempt_count_equals(int preempt_offset)
>  {
>  	int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index a7dd7b5..81a4f33 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -648,13 +648,15 @@ config TRACE_IRQFLAGS
>  	  Enables hooks to interrupt enabling and disabling for
>  	  either tracing or lock debugging.
> 
> -config DEBUG_SPINLOCK_SLEEP
> -	bool "Spinlock debugging: sleep-inside-spinlock checking"
> +config DEBUG_ATOMIC_SLEEP
> +	bool "Sleep inside atomic section checking"
>  	select PREEMPT_COUNT
>  	depends on DEBUG_KERNEL
>  	help
>  	  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
>  	bool "Locking API boot-time self-tests"
> -- 
> 1.7.5.4
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [GIT PULL] sched: Make sleep inside atomic detection work on !PREEMPT
@ 2011-06-10 13:30 Frederic Weisbecker
  2011-06-10 13:30 ` [PATCH 1/4] sched: Remove pointless in_atomic() definition check Frederic Weisbecker
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Frederic Weisbecker @ 2011-06-10 13:30 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: LKML, Frederic Weisbecker, Paul E. McKenney, Peter Zijlstra,
	Randy Dunlap

Ingo,

Please pull the sched/core branch that can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
	sched/core

Thanks,
	Frederic
---

Frederic Weisbecker (4):
      sched: Remove pointless in_atomic() definition check
      sched: Isolate preempt counting in its own config option
      sched: Make sleeping inside spinlock detection working in !CONFIG_PREEMPT
      sched: Generalize sleep inside spinlock detection


 Documentation/DocBook/kernel-hacking.tmpl  |    2 +-
 Documentation/SubmitChecklist              |    2 +-
 Documentation/development-process/4.Coding |    2 +-
 Documentation/ja_JP/SubmitChecklist        |    2 +-
 Documentation/zh_CN/SubmitChecklist        |    2 +-
 include/linux/bit_spinlock.h               |    2 +-
 include/linux/hardirq.h                    |    4 ++--
 include/linux/kernel.h                     |    2 +-
 include/linux/pagemap.h                    |    4 ++--
 include/linux/preempt.h                    |   26 +++++++++++++++++---------
 include/linux/rcupdate.h                   |   12 ++++++------
 include/linux/sched.h                      |    2 +-
 kernel/Kconfig.preempt                     |    3 +++
 kernel/sched.c                             |    6 ++----
 lib/Kconfig.debug                          |    9 ++++++---
 15 files changed, 46 insertions(+), 34 deletions(-)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] sched: Remove pointless in_atomic() definition check
  2011-06-10 13:30 [GIT PULL] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
@ 2011-06-10 13:30 ` Frederic Weisbecker
  2011-06-10 13:30 ` [PATCH 2/4] sched: Isolate preempt counting in its own config option Frederic Weisbecker
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Frederic Weisbecker @ 2011-06-10 13:30 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Peter Zijlstra

It's really supposed to be defined here. If it's not then
we actually want the build to crash so that we know it,
and not keep it silent.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 kernel/sched.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index fd18f39..01d9536 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -8028,7 +8028,6 @@ static inline int preempt_count_equals(int preempt_offset)
 
 void __might_sleep(const char *file, int line, int preempt_offset)
 {
-#ifdef in_atomic
 	static unsigned long prev_jiffy;	/* ratelimiting */
 
 	if ((preempt_count_equals(preempt_offset) && !irqs_disabled()) ||
@@ -8050,7 +8049,6 @@ void __might_sleep(const char *file, int line, int preempt_offset)
 	if (irqs_disabled())
 		print_irqtrace_events(current);
 	dump_stack();
-#endif
 }
 EXPORT_SYMBOL(__might_sleep);
 #endif
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/4] sched: Isolate preempt counting in its own config option
  2011-06-10 13:30 [GIT PULL] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
  2011-06-10 13:30 ` [PATCH 1/4] sched: Remove pointless in_atomic() definition check Frederic Weisbecker
@ 2011-06-10 13:30 ` Frederic Weisbecker
  2011-06-10 13:30 ` [PATCH 3/4] sched: Make sleeping inside spinlock detection working in !CONFIG_PREEMPT Frederic Weisbecker
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Frederic Weisbecker @ 2011-06-10 13:30 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Peter Zijlstra

Create a new CONFIG_PREEMPT_COUNT that handles the inc/dec
of preempt count offset independently. So that the offset
can be updated by preempt_disable() and preempt_enable()
even without the need for CONFIG_PREEMPT beeing set.

This prepares to make CONFIG_DEBUG_SPINLOCK_SLEEP working
with !CONFIG_PREEMPT where it currently doesn't detect
code that sleeps inside explicit preemption disabled
sections.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/linux/bit_spinlock.h |    2 +-
 include/linux/hardirq.h      |    4 ++--
 include/linux/pagemap.h      |    4 ++--
 include/linux/preempt.h      |   26 +++++++++++++++++---------
 include/linux/rcupdate.h     |   12 ++++++------
 include/linux/sched.h        |    2 +-
 kernel/Kconfig.preempt       |    3 +++
 kernel/sched.c               |    2 +-
 8 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h
index b4326bf..564d997 100644
--- a/include/linux/bit_spinlock.h
+++ b/include/linux/bit_spinlock.h
@@ -88,7 +88,7 @@ static inline int bit_spin_is_locked(int bitnum, unsigned long *addr)
 {
 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
 	return test_bit(bitnum, addr);
-#elif defined CONFIG_PREEMPT
+#elif defined CONFIG_PREEMPT_COUNT
 	return preempt_count();
 #else
 	return 1;
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index ba36217..f743883f 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -93,7 +93,7 @@
  */
 #define in_nmi()	(preempt_count() & NMI_MASK)
 
-#if defined(CONFIG_PREEMPT)
+#if defined(CONFIG_PREEMPT_COUNT)
 # define PREEMPT_CHECK_OFFSET 1
 #else
 # define PREEMPT_CHECK_OFFSET 0
@@ -115,7 +115,7 @@
 #define in_atomic_preempt_off() \
 		((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET)
 
-#ifdef CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT_COUNT
 # define preemptible()	(preempt_count() == 0 && !irqs_disabled())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 716875e..8e38d4c 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -134,7 +134,7 @@ static inline int page_cache_get_speculative(struct page *page)
 	VM_BUG_ON(in_interrupt());
 
 #if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU)
-# ifdef CONFIG_PREEMPT
+# ifdef CONFIG_PREEMPT_COUNT
 	VM_BUG_ON(!in_atomic());
 # endif
 	/*
@@ -172,7 +172,7 @@ static inline int page_cache_add_speculative(struct page *page, int count)
 	VM_BUG_ON(in_interrupt());
 
 #if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU)
-# ifdef CONFIG_PREEMPT
+# ifdef CONFIG_PREEMPT_COUNT
 	VM_BUG_ON(!in_atomic());
 # endif
 	VM_BUG_ON(page_count(page) == 0);
diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index 2e681d9..58969b2 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -27,6 +27,21 @@
 
 asmlinkage void preempt_schedule(void);
 
+#define preempt_check_resched() \
+do { \
+	if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \
+		preempt_schedule(); \
+} while (0)
+
+#else /* !CONFIG_PREEMPT */
+
+#define preempt_check_resched()		do { } while (0)
+
+#endif /* CONFIG_PREEMPT */
+
+
+#ifdef CONFIG_PREEMPT_COUNT
+
 #define preempt_disable() \
 do { \
 	inc_preempt_count(); \
@@ -39,12 +54,6 @@ do { \
 	dec_preempt_count(); \
 } while (0)
 
-#define preempt_check_resched() \
-do { \
-	if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \
-		preempt_schedule(); \
-} while (0)
-
 #define preempt_enable() \
 do { \
 	preempt_enable_no_resched(); \
@@ -80,18 +89,17 @@ do { \
 	preempt_check_resched(); \
 } while (0)
 
-#else
+#else /* !CONFIG_PREEMPT_COUNT */
 
 #define preempt_disable()		do { } while (0)
 #define preempt_enable_no_resched()	do { } while (0)
 #define preempt_enable()		do { } while (0)
-#define preempt_check_resched()		do { } while (0)
 
 #define preempt_disable_notrace()		do { } while (0)
 #define preempt_enable_no_resched_notrace()	do { } while (0)
 #define preempt_enable_notrace()		do { } while (0)
 
-#endif
+#endif /* CONFIG_PREEMPT_COUNT */
 
 #ifdef CONFIG_PREEMPT_NOTIFIERS
 
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 99f9aa7..8f4f881 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -239,7 +239,7 @@ extern int rcu_read_lock_bh_held(void);
  * Check debug_lockdep_rcu_enabled() to prevent false positives during boot
  * and while lockdep is disabled.
  */
-#ifdef CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT_COUNT
 static inline int rcu_read_lock_sched_held(void)
 {
 	int lockdep_opinion = 0;
@@ -250,12 +250,12 @@ static inline int rcu_read_lock_sched_held(void)
 		lockdep_opinion = lock_is_held(&rcu_sched_lock_map);
 	return lockdep_opinion || preempt_count() != 0 || irqs_disabled();
 }
-#else /* #ifdef CONFIG_PREEMPT */
+#else /* #ifdef CONFIG_PREEMPT_COUNT */
 static inline int rcu_read_lock_sched_held(void)
 {
 	return 1;
 }
-#endif /* #else #ifdef CONFIG_PREEMPT */
+#endif /* #else #ifdef CONFIG_PREEMPT_COUNT */
 
 #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
 
@@ -276,17 +276,17 @@ static inline int rcu_read_lock_bh_held(void)
 	return 1;
 }
 
-#ifdef CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT_COUNT
 static inline int rcu_read_lock_sched_held(void)
 {
 	return preempt_count() != 0 || irqs_disabled();
 }
-#else /* #ifdef CONFIG_PREEMPT */
+#else /* #ifdef CONFIG_PREEMPT_COUNT */
 static inline int rcu_read_lock_sched_held(void)
 {
 	return 1;
 }
-#endif /* #else #ifdef CONFIG_PREEMPT */
+#endif /* #else #ifdef CONFIG_PREEMPT_COUNT */
 
 #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
 
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 483c1ed..4ecd5cb 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2502,7 +2502,7 @@ extern int _cond_resched(void);
 
 extern int __cond_resched_lock(spinlock_t *lock);
 
-#ifdef CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT_COUNT
 #define PREEMPT_LOCK_OFFSET	PREEMPT_OFFSET
 #else
 #define PREEMPT_LOCK_OFFSET	0
diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
index bf987b9..24e7cb0 100644
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
@@ -35,6 +35,7 @@ config PREEMPT_VOLUNTARY
 
 config PREEMPT
 	bool "Preemptible Kernel (Low-Latency Desktop)"
+	select PREEMPT_COUNT
 	help
 	  This option reduces the latency of the kernel by making
 	  all kernel code (that is not executing in a critical section)
@@ -52,3 +53,5 @@ config PREEMPT
 
 endchoice
 
+config PREEMPT_COUNT
+       bool
\ No newline at end of file
diff --git a/kernel/sched.c b/kernel/sched.c
index 01d9536..90ad7cf 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2843,7 +2843,7 @@ void sched_fork(struct task_struct *p)
 #if defined(CONFIG_SMP)
 	p->on_cpu = 0;
 #endif
-#ifdef CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT_COUNT
 	/* Want to start with kernel preemption disabled. */
 	task_thread_info(p)->preempt_count = 1;
 #endif
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/4] sched: Make sleeping inside spinlock detection working in !CONFIG_PREEMPT
  2011-06-10 13:30 [GIT PULL] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
  2011-06-10 13:30 ` [PATCH 1/4] sched: Remove pointless in_atomic() definition check Frederic Weisbecker
  2011-06-10 13:30 ` [PATCH 2/4] sched: Isolate preempt counting in its own config option Frederic Weisbecker
@ 2011-06-10 13:30 ` Frederic Weisbecker
  2011-06-10 13:30 ` [PATCH 4/4] sched: Generalize sleep inside spinlock detection Frederic Weisbecker
  2011-06-22 22:48 ` [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
  4 siblings, 0 replies; 20+ messages in thread
From: Frederic Weisbecker @ 2011-06-10 13:30 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Peter Zijlstra

Select CONFIG_PREEMPT_COUNT when we enable the sleeping inside
spinlock detection, so that the preempt offset gets correctly
incremented/decremented from preempt_disable()/preempt_enable().

This makes the preempt count eventually working in !CONFIG_PREEMPT
when that debug option is set and thus fixes the detection of explicit
preemption disabled sections under such config. Code that sleeps
in explicitly preempt disabled section can be finally spotted
in non-preemptible kernels.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 lib/Kconfig.debug |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 28afa4c..a7dd7b5 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -650,6 +650,7 @@ config TRACE_IRQFLAGS
 
 config DEBUG_SPINLOCK_SLEEP
 	bool "Spinlock debugging: sleep-inside-spinlock checking"
+	select PREEMPT_COUNT
 	depends on DEBUG_KERNEL
 	help
 	  If you say Y here, various routines which may sleep will become very
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/4] sched: Generalize sleep inside spinlock detection
  2011-06-10 13:30 [GIT PULL] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
                   ` (2 preceding siblings ...)
  2011-06-10 13:30 ` [PATCH 3/4] sched: Make sleeping inside spinlock detection working in !CONFIG_PREEMPT Frederic Weisbecker
@ 2011-06-10 13:30 ` Frederic Weisbecker
  2011-06-10 15:37   ` Randy Dunlap
  2011-06-22 22:48 ` [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
  4 siblings, 1 reply; 20+ messages in thread
From: Frederic Weisbecker @ 2011-06-10 13:30 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Peter Zijlstra, Randy Dunlap

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 5955 bytes --]

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: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
---
 Documentation/DocBook/kernel-hacking.tmpl  |    2 +-
 Documentation/SubmitChecklist              |    2 +-
 Documentation/development-process/4.Coding |    2 +-
 Documentation/ja_JP/SubmitChecklist        |    2 +-
 Documentation/zh_CN/SubmitChecklist        |    2 +-
 include/linux/kernel.h                     |    2 +-
 kernel/sched.c                             |    2 +-
 lib/Kconfig.debug                          |    8 +++++---
 8 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl
index 7b3f493..07a9c48 100644
--- a/Documentation/DocBook/kernel-hacking.tmpl
+++ b/Documentation/DocBook/kernel-hacking.tmpl
@@ -409,7 +409,7 @@ cond_resched(); /* Will sleep */
 
   <para>
    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
    the rules, you will eventually lock up your box.
   </para>
diff --git a/Documentation/SubmitChecklist b/Documentation/SubmitChecklist
index da0382d..7b13be4 100644
--- a/Documentation/SubmitChecklist
+++ b/Documentation/SubmitChecklist
@@ -53,7 +53,7 @@ kernel patches.
 
 12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
     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.
 
 13: Has been build- and runtime tested with and without CONFIG_SMP and
diff --git a/Documentation/development-process/4.Coding b/Documentation/development-process/4.Coding
index f3f1a46..83f5f5b 100644
--- a/Documentation/development-process/4.Coding
+++ b/Documentation/development-process/4.Coding
@@ -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
    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.
 
 There are quite a few other debugging options, some of which will be
diff --git a/Documentation/ja_JP/SubmitChecklist b/Documentation/ja_JP/SubmitChecklist
index 2df4576..cb5507b 100644
--- a/Documentation/ja_JP/SubmitChecklist
+++ b/Documentation/ja_JP/SubmitChecklist
@@ -68,7 +68,7 @@ Linux カーネルパッチ投稿者向けチェックリスト
 
 12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB,
     CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK,
-    CONFIG_DEBUG_SPINLOCK_SLEEP これら全てを同時に有効にして動作確認を
+    CONFIG_DEBUG_ATOMIC_SLEEP これら全てを同時に有効にして動作確認を
     行ってください。
 
 13: CONFIG_SMP, CONFIG_PREEMPT を有効にした場合と無効にした場合の両方で
diff --git a/Documentation/zh_CN/SubmitChecklist b/Documentation/zh_CN/SubmitChecklist
index 951415b..4c741d6 100644
--- a/Documentation/zh_CN/SubmitChecklist
+++ b/Documentation/zh_CN/SubmitChecklist
@@ -67,7 +67,7 @@ Linux
 
 12£ºÒѾ­Í¨¹ýCONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
     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²âÊÔÖ´ÐÐʱ¼ä¡£
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fb0e732..24b489f 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -121,7 +121,7 @@ extern int _cond_resched(void);
 # define might_resched() do { } while (0)
 #endif
 
-#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
   void __might_sleep(const char *file, int line, int preempt_offset);
 /**
  * might_sleep - annotation for functions that can sleep
diff --git a/kernel/sched.c b/kernel/sched.c
index 90ad7cf..a5f318b 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -8018,7 +8018,7 @@ void __init sched_init(void)
 	scheduler_running = 1;
 }
 
-#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
 static inline int preempt_count_equals(int preempt_offset)
 {
 	int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a7dd7b5..81a4f33 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -648,13 +648,15 @@ config TRACE_IRQFLAGS
 	  Enables hooks to interrupt enabling and disabling for
 	  either tracing or lock debugging.
 
-config DEBUG_SPINLOCK_SLEEP
-	bool "Spinlock debugging: sleep-inside-spinlock checking"
+config DEBUG_ATOMIC_SLEEP
+	bool "Sleep inside atomic section checking"
 	select PREEMPT_COUNT
 	depends on DEBUG_KERNEL
 	help
 	  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
 	bool "Locking API boot-time self-tests"
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/4] sched: Generalize sleep inside spinlock detection
  2011-06-10 13:30 ` [PATCH 4/4] sched: Generalize sleep inside spinlock detection Frederic Weisbecker
@ 2011-06-10 15:37   ` Randy Dunlap
  2011-06-23  4:19     ` KOSAKI Motohiro
  0 siblings, 1 reply; 20+ messages in thread
From: Randy Dunlap @ 2011-06-10 15:37 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Ingo Molnar, LKML, Peter Zijlstra, Tsugikazu Shibata, Li Yang

On 06/10/11 06:30, Frederic Weisbecker wrote:
> 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: Frederic Weisbecker <fweisbec@gmail.com>
> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Randy Dunlap <randy.dunlap@oracle.com>

Acked-by: Randy Dunlap <randy.dunlap@oracle.com>

Adding JP & CH translators to see if they need any updates.

> ---
>  Documentation/DocBook/kernel-hacking.tmpl  |    2 +-
>  Documentation/SubmitChecklist              |    2 +-
>  Documentation/development-process/4.Coding |    2 +-
>  Documentation/ja_JP/SubmitChecklist        |    2 +-
>  Documentation/zh_CN/SubmitChecklist        |    2 +-
>  include/linux/kernel.h                     |    2 +-
>  kernel/sched.c                             |    2 +-
>  lib/Kconfig.debug                          |    8 +++++---
>  8 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl
> index 7b3f493..07a9c48 100644
> --- a/Documentation/DocBook/kernel-hacking.tmpl
> +++ b/Documentation/DocBook/kernel-hacking.tmpl
> @@ -409,7 +409,7 @@ cond_resched(); /* Will sleep */
>  
>    <para>
>     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
>     the rules, you will eventually lock up your box.
>    </para>
> diff --git a/Documentation/SubmitChecklist b/Documentation/SubmitChecklist
> index da0382d..7b13be4 100644
> --- a/Documentation/SubmitChecklist
> +++ b/Documentation/SubmitChecklist
> @@ -53,7 +53,7 @@ kernel patches.
>  
>  12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
>      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.
>  
>  13: Has been build- and runtime tested with and without CONFIG_SMP and
> diff --git a/Documentation/development-process/4.Coding b/Documentation/development-process/4.Coding
> index f3f1a46..83f5f5b 100644
> --- a/Documentation/development-process/4.Coding
> +++ b/Documentation/development-process/4.Coding
> @@ -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
>     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.
>  
>  There are quite a few other debugging options, some of which will be
> diff --git a/Documentation/ja_JP/SubmitChecklist b/Documentation/ja_JP/SubmitChecklist
> index 2df4576..cb5507b 100644
> --- a/Documentation/ja_JP/SubmitChecklist
> +++ b/Documentation/ja_JP/SubmitChecklist
> @@ -68,7 +68,7 @@ Linux カーネルパッチ投稿者向けチェックリスト
>  
>  12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB,
>      CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK,
> -    CONFIG_DEBUG_SPINLOCK_SLEEP これら全てを同時に有効にして動作確認を
> +    CONFIG_DEBUG_ATOMIC_SLEEP これら全てを同時に有効にして動作確認を
>      行ってください。
>  
>  13: CONFIG_SMP, CONFIG_PREEMPT を有効にした場合と無効にした場合の両方で
> diff --git a/Documentation/zh_CN/SubmitChecklist b/Documentation/zh_CN/SubmitChecklist
> index 951415b..4c741d6 100644
> --- a/Documentation/zh_CN/SubmitChecklist
> +++ b/Documentation/zh_CN/SubmitChecklist
> @@ -67,7 +67,7 @@ Linux
>  
>  12���Ѿ�ͨ��CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
>      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����ִ��ʱ�䡣
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index fb0e732..24b489f 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -121,7 +121,7 @@ extern int _cond_resched(void);
>  # define might_resched() do { } while (0)
>  #endif
>  
> -#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
> +#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
>    void __might_sleep(const char *file, int line, int preempt_offset);
>  /**
>   * might_sleep - annotation for functions that can sleep
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 90ad7cf..a5f318b 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -8018,7 +8018,7 @@ void __init sched_init(void)
>  	scheduler_running = 1;
>  }
>  
> -#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
> +#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
>  static inline int preempt_count_equals(int preempt_offset)
>  {
>  	int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index a7dd7b5..81a4f33 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -648,13 +648,15 @@ config TRACE_IRQFLAGS
>  	  Enables hooks to interrupt enabling and disabling for
>  	  either tracing or lock debugging.
>  
> -config DEBUG_SPINLOCK_SLEEP
> -	bool "Spinlock debugging: sleep-inside-spinlock checking"
> +config DEBUG_ATOMIC_SLEEP
> +	bool "Sleep inside atomic section checking"
>  	select PREEMPT_COUNT
>  	depends on DEBUG_KERNEL
>  	help
>  	  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
>  	bool "Locking API boot-time self-tests"


-- 
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-06-10 13:30 [GIT PULL] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
                   ` (3 preceding siblings ...)
  2011-06-10 13:30 ` [PATCH 4/4] sched: Generalize sleep inside spinlock detection Frederic Weisbecker
@ 2011-06-22 22:48 ` Frederic Weisbecker
  2011-07-01 12:36   ` Ingo Molnar
  4 siblings, 1 reply; 20+ messages in thread
From: Frederic Weisbecker @ 2011-06-22 22:48 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap

On Fri, Jun 10, 2011 at 03:30:18PM +0200, Frederic Weisbecker wrote:
> Ingo,
> 
> Please pull the sched/core branch that can be found at:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> 	sched/core

Hi Ingo,

I have added Randy's ack on the last patch. To get it, please pull the v2 in
the following branch:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
       sched/core-v2

There are no other changes.

Thanks.

> 
> Thanks,
> 	Frederic
> ---
> 
> Frederic Weisbecker (4):
>       sched: Remove pointless in_atomic() definition check
>       sched: Isolate preempt counting in its own config option
>       sched: Make sleeping inside spinlock detection working in !CONFIG_PREEMPT
>       sched: Generalize sleep inside spinlock detection
> 
> 
>  Documentation/DocBook/kernel-hacking.tmpl  |    2 +-
>  Documentation/SubmitChecklist              |    2 +-
>  Documentation/development-process/4.Coding |    2 +-
>  Documentation/ja_JP/SubmitChecklist        |    2 +-
>  Documentation/zh_CN/SubmitChecklist        |    2 +-
>  include/linux/bit_spinlock.h               |    2 +-
>  include/linux/hardirq.h                    |    4 ++--
>  include/linux/kernel.h                     |    2 +-
>  include/linux/pagemap.h                    |    4 ++--
>  include/linux/preempt.h                    |   26 +++++++++++++++++---------
>  include/linux/rcupdate.h                   |   12 ++++++------
>  include/linux/sched.h                      |    2 +-
>  kernel/Kconfig.preempt                     |    3 +++
>  kernel/sched.c                             |    6 ++----
>  lib/Kconfig.debug                          |    9 ++++++---
>  15 files changed, 46 insertions(+), 34 deletions(-)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/4] sched: Generalize sleep inside spinlock detection
  2011-06-10 15:37   ` Randy Dunlap
@ 2011-06-23  4:19     ` KOSAKI Motohiro
  0 siblings, 0 replies; 20+ messages in thread
From: KOSAKI Motohiro @ 2011-06-23  4:19 UTC (permalink / raw)
  To: randy.dunlap; +Cc: fweisbec, mingo, linux-kernel, a.p.zijlstra, tshibata, leoli

Hi

>>  There are quite a few other debugging options, some of which will be
>> diff --git a/Documentation/ja_JP/SubmitChecklist b/Documentation/ja_JP/SubmitChecklist
>> index 2df4576..cb5507b 100644
>> --- a/Documentation/ja_JP/SubmitChecklist
>> +++ b/Documentation/ja_JP/SubmitChecklist
>> @@ -68,7 +68,7 @@ Linux カーネルパッチ投稿者向けチェックリスト
>>  
>>  12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB,
>>      CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK,
>> -    CONFIG_DEBUG_SPINLOCK_SLEEP これら全てを同時に有効にして動作確認を
>> +    CONFIG_DEBUG_ATOMIC_SLEEP これら全てを同時に有効にして動作確認を
>>      行ってください。

This Japanese part looks correct to me. :)




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-06-22 22:48 ` [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
@ 2011-07-01 12:36   ` Ingo Molnar
  2011-07-01 12:56     ` Frederic Weisbecker
  0 siblings, 1 reply; 20+ messages in thread
From: Ingo Molnar @ 2011-07-01 12:36 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap,
	Thomas Gleixner


* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> On Fri, Jun 10, 2011 at 03:30:18PM +0200, Frederic Weisbecker wrote:
> > Ingo,
> > 
> > Please pull the sched/core branch that can be found at:
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> > 	sched/core
> 
> Hi Ingo,
> 
> I have added Randy's ack on the last patch. To get it, please pull the v2 in
> the following branch:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
>        sched/core-v2
> 
> There are no other changes.

Hm, this triggers such warnings now:

Detected 2010.217 MHz processor.
Marking TSC unstable due to TSCs unsynchronized
Calibrating delay loop (skipped), value calculated using timer frequency.. 4022.95 BogoMIPS (lpj=6700723)
pid_max: default: 4096 minimum: 301
BUG: scheduling while atomic: swapper/0/0x10000002
no locks held by swapper/0.
Pid: 0, comm: swapper Not tainted 3.0.0-rc5-tip-01401-ga7adf5f-dirty #141020
Call Trace:
 [<ffffffff81ddb3b0>] __schedule_bug+0x60/0x65
 [<ffffffff81dee803>] schedule+0x953/0x980
 [<ffffffff81571e30>] ? serial8250_console_putchar+0x30/0x40
 [<ffffffff81df177b>] ? _raw_spin_unlock+0x2b/0x50
 [<ffffffff8107882a>] __cond_resched+0x2a/0x40
 [<ffffffff81dee8e2>] _cond_resched+0x32/0x40
 [<ffffffff81110ba8>] __alloc_pages_nodemask+0x1b8/0x880
 [<ffffffff81df23ce>] ? common_interrupt+0xe/0x13
 [<ffffffff81080649>] ? vprintk+0x359/0x530
 [<ffffffff8113b4e7>] slob_new_pages+0x17/0x80
 [<ffffffff8113bd13>] __kmalloc_node+0xa3/0x270
 [<ffffffff81ddb6d5>] ? printk+0x41/0x43
 [<ffffffff82738420>] pidmap_init+0x80/0xbf
 [<ffffffff8272aa54>] start_kernel+0x28b/0x300
 [<ffffffff8272a2ee>] x86_64_start_reservations+0xfe/0x102
 [<ffffffff8272a3e2>] x86_64_start_kernel+0xf0/0xf7
Security Framework initialized
AppArmor: AppArmor initialized
Mount-cache hash table entries: 256
Initializing cgroup subsys cpuacct

Not sure we want to warn about schedule during early init, or can it 
cause problems and should thus be fixed? I bet there's more such 
instances.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-07-01 12:36   ` Ingo Molnar
@ 2011-07-01 12:56     ` Frederic Weisbecker
  2011-07-01 12:59       ` Ingo Molnar
  0 siblings, 1 reply; 20+ messages in thread
From: Frederic Weisbecker @ 2011-07-01 12:56 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap,
	Thomas Gleixner

On Fri, Jul 01, 2011 at 02:36:29PM +0200, Ingo Molnar wrote:
> 
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> 
> > On Fri, Jun 10, 2011 at 03:30:18PM +0200, Frederic Weisbecker wrote:
> > > Ingo,
> > > 
> > > Please pull the sched/core branch that can be found at:
> > > 
> > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> > > 	sched/core
> > 
> > Hi Ingo,
> > 
> > I have added Randy's ack on the last patch. To get it, please pull the v2 in
> > the following branch:
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> >        sched/core-v2
> > 
> > There are no other changes.
> 
> Hm, this triggers such warnings now:
> 
> Detected 2010.217 MHz processor.
> Marking TSC unstable due to TSCs unsynchronized
> Calibrating delay loop (skipped), value calculated using timer frequency.. 4022.95 BogoMIPS (lpj=6700723)
> pid_max: default: 4096 minimum: 301
> BUG: scheduling while atomic: swapper/0/0x10000002
> no locks held by swapper/0.
> Pid: 0, comm: swapper Not tainted 3.0.0-rc5-tip-01401-ga7adf5f-dirty #141020
> Call Trace:
>  [<ffffffff81ddb3b0>] __schedule_bug+0x60/0x65
>  [<ffffffff81dee803>] schedule+0x953/0x980
>  [<ffffffff81571e30>] ? serial8250_console_putchar+0x30/0x40
>  [<ffffffff81df177b>] ? _raw_spin_unlock+0x2b/0x50
>  [<ffffffff8107882a>] __cond_resched+0x2a/0x40
>  [<ffffffff81dee8e2>] _cond_resched+0x32/0x40
>  [<ffffffff81110ba8>] __alloc_pages_nodemask+0x1b8/0x880
>  [<ffffffff81df23ce>] ? common_interrupt+0xe/0x13
>  [<ffffffff81080649>] ? vprintk+0x359/0x530
>  [<ffffffff8113b4e7>] slob_new_pages+0x17/0x80
>  [<ffffffff8113bd13>] __kmalloc_node+0xa3/0x270
>  [<ffffffff81ddb6d5>] ? printk+0x41/0x43
>  [<ffffffff82738420>] pidmap_init+0x80/0xbf
>  [<ffffffff8272aa54>] start_kernel+0x28b/0x300
>  [<ffffffff8272a2ee>] x86_64_start_reservations+0xfe/0x102
>  [<ffffffff8272a3e2>] x86_64_start_kernel+0xf0/0xf7
> Security Framework initialized
> AppArmor: AppArmor initialized
> Mount-cache hash table entries: 256
> Initializing cgroup subsys cpuacct
> 
> Not sure we want to warn about schedule during early init, or can it 
> cause problems and should thus be fixed? I bet there's more such 
> instances.

I believe this is harmless because no other other tasks than init are queued at that
time. But I don't know, may be calling schedule() involves some things that
are not ready yet at that time.

Either we add a system_state check in schedule_debug() or we fix the callers
to not call schedule when system_state shows we are booting..

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-07-01 12:56     ` Frederic Weisbecker
@ 2011-07-01 12:59       ` Ingo Molnar
  2011-07-01 15:05         ` Ingo Molnar
  2011-07-01 16:02         ` Frederic Weisbecker
  0 siblings, 2 replies; 20+ messages in thread
From: Ingo Molnar @ 2011-07-01 12:59 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap,
	Thomas Gleixner


* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> On Fri, Jul 01, 2011 at 02:36:29PM +0200, Ingo Molnar wrote:
> > 
> > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > 
> > > On Fri, Jun 10, 2011 at 03:30:18PM +0200, Frederic Weisbecker wrote:
> > > > Ingo,
> > > > 
> > > > Please pull the sched/core branch that can be found at:
> > > > 
> > > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> > > > 	sched/core
> > > 
> > > Hi Ingo,
> > > 
> > > I have added Randy's ack on the last patch. To get it, please pull the v2 in
> > > the following branch:
> > > 
> > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> > >        sched/core-v2
> > > 
> > > There are no other changes.
> > 
> > Hm, this triggers such warnings now:
> > 
> > Detected 2010.217 MHz processor.
> > Marking TSC unstable due to TSCs unsynchronized
> > Calibrating delay loop (skipped), value calculated using timer frequency.. 4022.95 BogoMIPS (lpj=6700723)
> > pid_max: default: 4096 minimum: 301
> > BUG: scheduling while atomic: swapper/0/0x10000002
> > no locks held by swapper/0.
> > Pid: 0, comm: swapper Not tainted 3.0.0-rc5-tip-01401-ga7adf5f-dirty #141020
> > Call Trace:
> >  [<ffffffff81ddb3b0>] __schedule_bug+0x60/0x65
> >  [<ffffffff81dee803>] schedule+0x953/0x980
> >  [<ffffffff81571e30>] ? serial8250_console_putchar+0x30/0x40
> >  [<ffffffff81df177b>] ? _raw_spin_unlock+0x2b/0x50
> >  [<ffffffff8107882a>] __cond_resched+0x2a/0x40
> >  [<ffffffff81dee8e2>] _cond_resched+0x32/0x40
> >  [<ffffffff81110ba8>] __alloc_pages_nodemask+0x1b8/0x880
> >  [<ffffffff81df23ce>] ? common_interrupt+0xe/0x13
> >  [<ffffffff81080649>] ? vprintk+0x359/0x530
> >  [<ffffffff8113b4e7>] slob_new_pages+0x17/0x80
> >  [<ffffffff8113bd13>] __kmalloc_node+0xa3/0x270
> >  [<ffffffff81ddb6d5>] ? printk+0x41/0x43
> >  [<ffffffff82738420>] pidmap_init+0x80/0xbf
> >  [<ffffffff8272aa54>] start_kernel+0x28b/0x300
> >  [<ffffffff8272a2ee>] x86_64_start_reservations+0xfe/0x102
> >  [<ffffffff8272a3e2>] x86_64_start_kernel+0xf0/0xf7
> > Security Framework initialized
> > AppArmor: AppArmor initialized
> > Mount-cache hash table entries: 256
> > Initializing cgroup subsys cpuacct
> > 
> > Not sure we want to warn about schedule during early init, or can 
> > it cause problems and should thus be fixed? I bet there's more 
> > such instances.
> 
> I believe this is harmless because no other other tasks than init 
> are queued at that time. But I don't know, may be calling 
> schedule() involves some things that are not ready yet at that 
> time.

So why does it have need_resched set then? (which i presume must be a 
condition for cond_resched() to call into schedule())

> Either we add a system_state check in schedule_debug() or we fix 
> the callers to not call schedule when system_state shows we are 
> booting..

Hm, such attempts were rather fragile in the past.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-07-01 12:59       ` Ingo Molnar
@ 2011-07-01 15:05         ` Ingo Molnar
  2011-07-01 16:01           ` Frederic Weisbecker
  2011-07-01 16:44           ` Frederic Weisbecker
  2011-07-01 16:02         ` Frederic Weisbecker
  1 sibling, 2 replies; 20+ messages in thread
From: Ingo Molnar @ 2011-07-01 15:05 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap,
	Thomas Gleixner


-tip testing also found that m32r fails to build:

/home/mingo/tip/kernel/sched.c: In function 'preempt_schedule':
/home/mingo/tip/kernel/sched.c:4364: error: implicit declaration of function 'add_preempt_count_notrace'
/home/mingo/tip/kernel/sched.c:4366: error: implicit declaration of function 'sub_preempt_count_notrace'

due to:

bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a is the first bad commit
commit bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a
Author: Frederic Weisbecker <fweisbec@gmail.com>
Date:   Wed Jun 8 01:13:27 2011 +0200

    sched: Isolate preempt counting in its own config option

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-07-01 15:05         ` Ingo Molnar
@ 2011-07-01 16:01           ` Frederic Weisbecker
  2011-07-01 16:44           ` Frederic Weisbecker
  1 sibling, 0 replies; 20+ messages in thread
From: Frederic Weisbecker @ 2011-07-01 16:01 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap,
	Thomas Gleixner

On Fri, Jul 01, 2011 at 05:05:17PM +0200, Ingo Molnar wrote:
> 
> -tip testing also found that m32r fails to build:
> 
> /home/mingo/tip/kernel/sched.c: In function 'preempt_schedule':
> /home/mingo/tip/kernel/sched.c:4364: error: implicit declaration of function 'add_preempt_count_notrace'
> /home/mingo/tip/kernel/sched.c:4366: error: implicit declaration of function 'sub_preempt_count_notrace'
> 
> due to:

Ok, will fix soon. Thanks!

> 
> bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a is the first bad commit
> commit bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a
> Author: Frederic Weisbecker <fweisbec@gmail.com>
> Date:   Wed Jun 8 01:13:27 2011 +0200
> 
>     sched: Isolate preempt counting in its own config option
> 
> Thanks,
> 
> 	Ingo

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-07-01 12:59       ` Ingo Molnar
  2011-07-01 15:05         ` Ingo Molnar
@ 2011-07-01 16:02         ` Frederic Weisbecker
  1 sibling, 0 replies; 20+ messages in thread
From: Frederic Weisbecker @ 2011-07-01 16:02 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap,
	Thomas Gleixner

On Fri, Jul 01, 2011 at 02:59:26PM +0200, Ingo Molnar wrote:
> 
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> 
> > On Fri, Jul 01, 2011 at 02:36:29PM +0200, Ingo Molnar wrote:
> > > 
> > > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > > 
> > > > On Fri, Jun 10, 2011 at 03:30:18PM +0200, Frederic Weisbecker wrote:
> > > > > Ingo,
> > > > > 
> > > > > Please pull the sched/core branch that can be found at:
> > > > > 
> > > > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> > > > > 	sched/core
> > > > 
> > > > Hi Ingo,
> > > > 
> > > > I have added Randy's ack on the last patch. To get it, please pull the v2 in
> > > > the following branch:
> > > > 
> > > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> > > >        sched/core-v2
> > > > 
> > > > There are no other changes.
> > > 
> > > Hm, this triggers such warnings now:
> > > 
> > > Detected 2010.217 MHz processor.
> > > Marking TSC unstable due to TSCs unsynchronized
> > > Calibrating delay loop (skipped), value calculated using timer frequency.. 4022.95 BogoMIPS (lpj=6700723)
> > > pid_max: default: 4096 minimum: 301
> > > BUG: scheduling while atomic: swapper/0/0x10000002
> > > no locks held by swapper/0.
> > > Pid: 0, comm: swapper Not tainted 3.0.0-rc5-tip-01401-ga7adf5f-dirty #141020
> > > Call Trace:
> > >  [<ffffffff81ddb3b0>] __schedule_bug+0x60/0x65
> > >  [<ffffffff81dee803>] schedule+0x953/0x980
> > >  [<ffffffff81571e30>] ? serial8250_console_putchar+0x30/0x40
> > >  [<ffffffff81df177b>] ? _raw_spin_unlock+0x2b/0x50
> > >  [<ffffffff8107882a>] __cond_resched+0x2a/0x40
> > >  [<ffffffff81dee8e2>] _cond_resched+0x32/0x40
> > >  [<ffffffff81110ba8>] __alloc_pages_nodemask+0x1b8/0x880
> > >  [<ffffffff81df23ce>] ? common_interrupt+0xe/0x13
> > >  [<ffffffff81080649>] ? vprintk+0x359/0x530
> > >  [<ffffffff8113b4e7>] slob_new_pages+0x17/0x80
> > >  [<ffffffff8113bd13>] __kmalloc_node+0xa3/0x270
> > >  [<ffffffff81ddb6d5>] ? printk+0x41/0x43
> > >  [<ffffffff82738420>] pidmap_init+0x80/0xbf
> > >  [<ffffffff8272aa54>] start_kernel+0x28b/0x300
> > >  [<ffffffff8272a2ee>] x86_64_start_reservations+0xfe/0x102
> > >  [<ffffffff8272a3e2>] x86_64_start_kernel+0xf0/0xf7
> > > Security Framework initialized
> > > AppArmor: AppArmor initialized
> > > Mount-cache hash table entries: 256
> > > Initializing cgroup subsys cpuacct
> > > 
> > > Not sure we want to warn about schedule during early init, or can 
> > > it cause problems and should thus be fixed? I bet there's more 
> > > such instances.
> > 
> > I believe this is harmless because no other other tasks than init 
> > are queued at that time. But I don't know, may be calling 
> > schedule() involves some things that are not ready yet at that 
> > time.
> 
> So why does it have need_resched set then? (which i presume must be a 
> condition for cond_resched() to call into schedule())

Good point, I'm looking at this.
 
> > Either we add a system_state check in schedule_debug() or we fix 
> > the callers to not call schedule when system_state shows we are 
> > booting..
> 
> Hm, such attempts were rather fragile in the past.
> 
> Thanks,
> 
> 	Ingo

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-07-01 15:05         ` Ingo Molnar
  2011-07-01 16:01           ` Frederic Weisbecker
@ 2011-07-01 16:44           ` Frederic Weisbecker
  2011-07-01 17:29             ` Ingo Molnar
  1 sibling, 1 reply; 20+ messages in thread
From: Frederic Weisbecker @ 2011-07-01 16:44 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap,
	Thomas Gleixner

On Fri, Jul 01, 2011 at 05:05:17PM +0200, Ingo Molnar wrote:
> 
> -tip testing also found that m32r fails to build:
> 
> /home/mingo/tip/kernel/sched.c: In function 'preempt_schedule':
> /home/mingo/tip/kernel/sched.c:4364: error: implicit declaration of function 'add_preempt_count_notrace'
> /home/mingo/tip/kernel/sched.c:4366: error: implicit declaration of function 'sub_preempt_count_notrace'
> 
> due to:
> 
> bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a is the first bad commit
> commit bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a
> Author: Frederic Weisbecker <fweisbec@gmail.com>
> Date:   Wed Jun 8 01:13:27 2011 +0200
> 
>     sched: Isolate preempt counting in its own config option
> 
> Thanks,
> 
> 	Ingo

I have no clue how that did happen.

Can you send me your config?

Thanks.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-07-01 16:44           ` Frederic Weisbecker
@ 2011-07-01 17:29             ` Ingo Molnar
  2011-07-02 16:53               ` Frederic Weisbecker
  0 siblings, 1 reply; 20+ messages in thread
From: Ingo Molnar @ 2011-07-01 17:29 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap,
	Thomas Gleixner


* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> On Fri, Jul 01, 2011 at 05:05:17PM +0200, Ingo Molnar wrote:
> > 
> > -tip testing also found that m32r fails to build:
> > 
> > /home/mingo/tip/kernel/sched.c: In function 'preempt_schedule':
> > /home/mingo/tip/kernel/sched.c:4364: error: implicit declaration of function 'add_preempt_count_notrace'
> > /home/mingo/tip/kernel/sched.c:4366: error: implicit declaration of function 'sub_preempt_count_notrace'
> > 
> > due to:
> > 
> > bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a is the first bad commit
> > commit bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a
> > Author: Frederic Weisbecker <fweisbec@gmail.com>
> > Date:   Wed Jun 8 01:13:27 2011 +0200
> > 
> >     sched: Isolate preempt counting in its own config option
> > 
> > Thanks,
> > 
> > 	Ingo
> 
> I have no clue how that did happen.
> 
> Can you send me your config?

Just the m32r defconfig: m32700ut.smp_defconfig.

My guess would be that one of these:

 include/linux/bit_spinlock.h |    2 +-
 include/linux/hardirq.h      |    4 ++--
 include/linux/pagemap.h      |    4 ++--
 include/linux/preempt.h      |   26 +++++++++++++++++---------
 include/linux/rcupdate.h     |   12 ++++++------
 include/linux/sched.h        |    2 +-

changed/exposed some header dependency quirk on m32r, failing the 
build. Or m32r has some strange .config combo.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-07-01 17:29             ` Ingo Molnar
@ 2011-07-02 16:53               ` Frederic Weisbecker
  2011-07-03 19:49                 ` Ingo Molnar
  0 siblings, 1 reply; 20+ messages in thread
From: Frederic Weisbecker @ 2011-07-02 16:53 UTC (permalink / raw)
  To: Ingo Molnar, Michal Marek, Steven Rostedt
  Cc: LKML, Paul E. McKenney, Peter Zijlstra, Randy Dunlap,
	Thomas Gleixner

On Fri, Jul 01, 2011 at 07:29:34PM +0200, Ingo Molnar wrote:
> 
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> 
> > On Fri, Jul 01, 2011 at 05:05:17PM +0200, Ingo Molnar wrote:
> > > 
> > > -tip testing also found that m32r fails to build:
> > > 
> > > /home/mingo/tip/kernel/sched.c: In function 'preempt_schedule':
> > > /home/mingo/tip/kernel/sched.c:4364: error: implicit declaration of function 'add_preempt_count_notrace'
> > > /home/mingo/tip/kernel/sched.c:4366: error: implicit declaration of function 'sub_preempt_count_notrace'
> > > 
> > > due to:
> > > 
> > > bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a is the first bad commit
> > > commit bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a
> > > Author: Frederic Weisbecker <fweisbec@gmail.com>
> > > Date:   Wed Jun 8 01:13:27 2011 +0200
> > > 
> > >     sched: Isolate preempt counting in its own config option
> > > 
> > > Thanks,
> > > 
> > > 	Ingo
> > 
> > I have no clue how that did happen.
> > 
> > Can you send me your config?
> 
> Just the m32r defconfig: m32700ut.smp_defconfig.
> 
> My guess would be that one of these:
> 
>  include/linux/bit_spinlock.h |    2 +-
>  include/linux/hardirq.h      |    4 ++--
>  include/linux/pagemap.h      |    4 ++--
>  include/linux/preempt.h      |   26 +++++++++++++++++---------
>  include/linux/rcupdate.h     |   12 ++++++------
>  include/linux/sched.h        |    2 +-
> 
> changed/exposed some header dependency quirk on m32r, failing the 
> build. Or m32r has some strange .config combo.
> 
> Thanks,
> 
> 	Ingo

That's weird.

We have this:

	config PREEMPT
		bool
		select PREEMPT_COUNT

	config PREEMPT_COUNT
		bool

Then I run "make ARCH=m32r defconfig" that has CONFIG_PREEMPT=y
but it doesn't select PREEMPT_COUNT and happily runs to break few
times after.

Even running make ARCH=m32r oldconfig on the defconfig doesn't fix up
the issue.

I thought "select" was an unconditional action. What am I missing?

I'm adding in Cc more people who know better kconfig/kbuild than me.
Every time I finally consider I know well the Kconfig language, I quickly
get caught up by the fate...

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT
  2011-07-02 16:53               ` Frederic Weisbecker
@ 2011-07-03 19:49                 ` Ingo Molnar
  0 siblings, 0 replies; 20+ messages in thread
From: Ingo Molnar @ 2011-07-03 19:49 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Michal Marek, Steven Rostedt, LKML, Paul E. McKenney,
	Peter Zijlstra, Randy Dunlap, Thomas Gleixner


* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> On Fri, Jul 01, 2011 at 07:29:34PM +0200, Ingo Molnar wrote:
> > 
> > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > 
> > > On Fri, Jul 01, 2011 at 05:05:17PM +0200, Ingo Molnar wrote:
> > > > 
> > > > -tip testing also found that m32r fails to build:
> > > > 
> > > > /home/mingo/tip/kernel/sched.c: In function 'preempt_schedule':
> > > > /home/mingo/tip/kernel/sched.c:4364: error: implicit declaration of function 'add_preempt_count_notrace'
> > > > /home/mingo/tip/kernel/sched.c:4366: error: implicit declaration of function 'sub_preempt_count_notrace'
> > > > 
> > > > due to:
> > > > 
> > > > bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a is the first bad commit
> > > > commit bdd4e85dc36cdbcfc1608a5b2a17c80a9db8986a
> > > > Author: Frederic Weisbecker <fweisbec@gmail.com>
> > > > Date:   Wed Jun 8 01:13:27 2011 +0200
> > > > 
> > > >     sched: Isolate preempt counting in its own config option
> > > > 
> > > > Thanks,
> > > > 
> > > > 	Ingo
> > > 
> > > I have no clue how that did happen.
> > > 
> > > Can you send me your config?
> > 
> > Just the m32r defconfig: m32700ut.smp_defconfig.
> > 
> > My guess would be that one of these:
> > 
> >  include/linux/bit_spinlock.h |    2 +-
> >  include/linux/hardirq.h      |    4 ++--
> >  include/linux/pagemap.h      |    4 ++--
> >  include/linux/preempt.h      |   26 +++++++++++++++++---------
> >  include/linux/rcupdate.h     |   12 ++++++------
> >  include/linux/sched.h        |    2 +-
> > 
> > changed/exposed some header dependency quirk on m32r, failing the 
> > build. Or m32r has some strange .config combo.
> > 
> > Thanks,
> > 
> > 	Ingo
> 
> That's weird.
> 
> We have this:
> 
> 	config PREEMPT
> 		bool
> 		select PREEMPT_COUNT
> 
> 	config PREEMPT_COUNT
> 		bool
> 
> Then I run "make ARCH=m32r defconfig" that has CONFIG_PREEMPT=y
> but it doesn't select PREEMPT_COUNT and happily runs to break few
> times after.
> 
> Even running make ARCH=m32r oldconfig on the defconfig doesn't fix up
> the issue.
> 
> I thought "select" was an unconditional action. What am I missing?
> 
> I'm adding in Cc more people who know better kconfig/kbuild than me.
> Every time I finally consider I know well the Kconfig language, I quickly
> get caught up by the fate...

Architectures have to include kernel/Kconfig.preempt explicitly, 
like:

  arch/x86/Kconfig:source "kernel/Kconfig.preempt"

m32r does not appear to do this - so it does not know about 
PREEMPT_COUNT.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2011-07-03 19:50 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-10 13:30 [GIT PULL] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
2011-06-10 13:30 ` [PATCH 1/4] sched: Remove pointless in_atomic() definition check Frederic Weisbecker
2011-06-10 13:30 ` [PATCH 2/4] sched: Isolate preempt counting in its own config option Frederic Weisbecker
2011-06-10 13:30 ` [PATCH 3/4] sched: Make sleeping inside spinlock detection working in !CONFIG_PREEMPT Frederic Weisbecker
2011-06-10 13:30 ` [PATCH 4/4] sched: Generalize sleep inside spinlock detection Frederic Weisbecker
2011-06-10 15:37   ` Randy Dunlap
2011-06-23  4:19     ` KOSAKI Motohiro
2011-06-22 22:48 ` [GIT PULL v2] sched: Make sleep inside atomic detection work on !PREEMPT Frederic Weisbecker
2011-07-01 12:36   ` Ingo Molnar
2011-07-01 12:56     ` Frederic Weisbecker
2011-07-01 12:59       ` Ingo Molnar
2011-07-01 15:05         ` Ingo Molnar
2011-07-01 16:01           ` Frederic Weisbecker
2011-07-01 16:44           ` Frederic Weisbecker
2011-07-01 17:29             ` Ingo Molnar
2011-07-02 16:53               ` Frederic Weisbecker
2011-07-03 19:49                 ` Ingo Molnar
2011-07-01 16:02         ` Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2011-06-08 17:48 [PATCH 0/4] " Frederic Weisbecker
2011-06-08 17:48 ` [PATCH 4/4] sched: Generalize sleep inside spinlock detection Frederic Weisbecker
2011-06-08 19:41   ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox