Skip to contentSkip to conversation

sched: Make sleep inside atomic detection work on !PREEMPT

PATCH In review Frederic Weisbecker 5 participants 16 messages Jun 8, 2011 – Sep 26, 2011

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover sched: Make sleep inside atomic detection work on !PREEMPT

Aside it may mostly avoid the need for a specific PROVE_RCU check when we sleep inside an rcu read side critical section.

Better make sleeping inside atomic sections work everywhere.

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(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/4 sched: Remove pointless in_atomic() definition check

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.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/sched.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
kernel/sched.c +0 -2
index fd18f39..01d9536 100644
@@ -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
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/4 sched: Isolate preempt counting in its own config option

In reply to Frederic Weisbecker

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.

Cc Paul E. McKenney <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 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(-)
include/linux/bit_spinlock.h +1 -1
index b4326bf..564d997 100644
@@ -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;
include/linux/hardirq.h +2 -2
index ba36217..f743883f 100644
@@ -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
include/linux/pagemap.h +2 -2
index 716875e..8e38d4c 100644
@@ -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);
include/linux/preempt.h +17 -9
index 2e681d9..58969b2 100644
@@ -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
 
include/linux/rcupdate.h +6 -6
index 99f9aa7..8f4f881 100644
@@ -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 */
 
include/linux/sched.h +1 -1
index 483c1ed..4ecd5cb 100644
@@ -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
kernel/Kconfig.preempt +3 -0
index bf987b9..24e7cb0 100644
@@ -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
kernel/sched.c +1 -1
index 01d9536..90ad7cf 100644
@@ -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
Signature · 1 line
1.7.5.4
Acked-by on v1 2/4
#3 lore raw

Re: [PATCH 2/4] sched: Isolate preempt counting in its own config option

Quoted 5 lines · Frederic Weisbecker

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.

Quoted 7 lines

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.

Quoted 227 lines
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 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(-)
include/linux/bit_spinlock.h +1 -1
index b4326bf..564d997 100644
@@ -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;
include/linux/hardirq.h +2 -2
index ba36217..f743883f 100644
@@ -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
include/linux/pagemap.h +2 -2
index 716875e..8e38d4c 100644
@@ -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);
include/linux/preempt.h +17 -9
index 2e681d9..58969b2 100644
@@ -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
 
include/linux/rcupdate.h +6 -6
index 99f9aa7..8f4f881 100644
@@ -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 */
 
include/linux/sched.h +1 -1
index 483c1ed..4ecd5cb 100644
@@ -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
kernel/Kconfig.preempt +3 -0
index bf987b9..24e7cb0 100644
@@ -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
kernel/sched.c +1 -1
index 01d9536..90ad7cf 100644
@@ -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
Signature · 1 line
1.7.5.4
#4 lore raw

Re: [PATCH 2/4] sched: Isolate preempt counting in its own config option

In reply to Frederic Weisbecker
Quoted 10 lines · Frederic Weisbecker

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.

The last time this got proposed it got shot down due to the extra inc/dec stuff all over the place increasing overhead significantly.

#5 lore raw

Re: [PATCH 2/4] sched: Isolate preempt counting in its own config option

Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Frederic Weisbecker

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.

Quoted 7 lines
Quoted 4 lines

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.

The last time this got proposed it got shot down due to the extra inc/dec stuff all over the place increasing overhead significantly.

Even given that the extra inc/dec stuff only happens in kernels built with DEBUG_SPINLOCK_SLEEP=y (DEBUG_ATOMIC_SLEEP=y after patch 4/4)?

Thanx, Paul

#6 lore raw

Re: [PATCH 2/4] sched: Isolate preempt counting in its own config option

Quoted 14 lines · Paul E. McKenney
Quoted 12 lines · Peter Zijlstra
Quoted 10 lines · Frederic Weisbecker

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.

Quoted 5 lines
Quoted 2 lines

The last time this got proposed it got shot down due to the extra inc/dec stuff all over the place increasing overhead significantly.

Even given that the extra inc/dec stuff only happens in kernels built with DEBUG_SPINLOCK_SLEEP=y (DEBUG_ATOMIC_SLEEP=y after patch 4/4)?

Ah, no that might be ok. That's what I get for trying to read email in no time.

#7 lore raw

PATCH 3/4 sched: Make sleeping inside spinlock detection working in !CONFIG_PREEMPT

In reply to Frederic Weisbecker

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.

Cc Paul E. McKenney <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 lib/Kconfig.debug |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
lib/Kconfig.debug +1 -0
index 28afa4c..a7dd7b5 100644
@@ -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
Signature · 1 line
1.7.5.4
Acked-by on v1 3/4
#8 lore raw

Re: [PATCH 3/4] sched: Make sleeping inside spinlock detection working in !CONFIG_PREEMPT

Quoted 4 lines · Frederic Weisbecker

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().

Quoted 8 lines

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.

Quoted 21 lines
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 lib/Kconfig.debug |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
lib/Kconfig.debug +1 -0
index 28afa4c..a7dd7b5 100644
@@ -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
Signature · 1 line
1.7.5.4
#9 lore raw

PATCH 4/4 sched: Generalize sleep inside spinlock detection

In reply to Frederic Weisbecker

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.

Cc Paul E. McKenney <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Randy Dunlap <[email protected]>
---
 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(-)
Documentation/DocBook/kernel-hacking.tmpl +1 -1
index 7b3f493..07a9c48 100644
@@ -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>
Documentation/SubmitChecklist +1 -1
index da0382d..7b13be4 100644
@@ -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
Documentation/development-process/4.Coding +1 -1
index f3f1a46..83f5f5b 100644
@@ -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
Documentation/ja_JP/SubmitChecklist +1 -1
index 2df4576..cb5507b 100644
@@ -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 を有効にした場合と無効にした場合の両方で
Documentation/zh_CN/SubmitChecklist +1 -1
index 951415b..4c741d6 100644
@@ -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����ִ��ʱ�䡣
include/linux/kernel.h +1 -1
index fb0e732..24b489f 100644
@@ -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
kernel/sched.c +1 -1
index 90ad7cf..a5f318b 100644
@@ -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();
lib/Kconfig.debug +5 -3
index a7dd7b5..81a4f33 100644
@@ -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"
Signature · 1 line
1.7.5.4
Acked-by on v1 4/4
#10 lore raw

Re: [PATCH 4/4] sched: Generalize sleep inside spinlock detection

Quoted 10 lines · Frederic Weisbecker

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.

Quoted 131 lines
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Randy Dunlap <[email protected]>
---
 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(-)
Documentation/DocBook/kernel-hacking.tmpl +1 -1
index 7b3f493..07a9c48 100644
@@ -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>
Documentation/SubmitChecklist +1 -1
index da0382d..7b13be4 100644
@@ -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
Documentation/development-process/4.Coding +1 -1
index f3f1a46..83f5f5b 100644
@@ -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
Documentation/ja_JP/SubmitChecklist +1 -1
index 2df4576..cb5507b 100644
@@ -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 を有効にした場合と無効にした場合の両方で
Documentation/zh_CN/SubmitChecklist +1 -1
index 951415b..4c741d6 100644
@@ -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????ִ??ʱ?䡣
include/linux/kernel.h +1 -1
index fb0e732..24b489f 100644
@@ -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
kernel/sched.c +1 -1
index 90ad7cf..a5f318b 100644
@@ -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();
lib/Kconfig.debug +5 -3
index a7dd7b5..81a4f33 100644
@@ -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"
Signature · 1 line
1.7.5.4
#11 lore raw

Bug: ACPI, scheduling while atomic (was Re: [PATCH 0/4] sched: Make sleep inside atomic detection work on !PREEMPT)

In reply to Frederic Weisbecker
Quoted 4 lines · Frederic Weisbecker

Aside it may mostly avoid the need for a specific PROVE_RCU check when we sleep inside an rcu read side critical section.

Better make sleeping inside atomic sections work everywhere.

BTW, it has led to detect a bug in the ACPI code. It happens in !CONFIG_PREEMPT:

[    0.160187] BUG: scheduling while atomic: swapper/0/0x10000002
[    0.166016] no locks held by swapper/0.
[    0.170014] Modules linked in:
[    0.173107] Pid: 0, comm: swapper Not tainted 2.6.39+ #124
[    0.180014] Call Trace:
[    0.182481]  [<ffffffff81048685>] __schedule_bug+0x85/0x90
[    0.187967]  [<ffffffff817da98c>] schedule+0x75c/0xa40
[    0.190022]  [<ffffffff8109a1fd>] ? trace_hardirqs_on+0xd/0x10
[    0.200023]  [<ffffffff813879c0>] ? acpi_ps_free_op+0x22/0x24
[    0.205776]  [<ffffffff810554a5>] __cond_resched+0x25/0x40
[    0.210022]  [<ffffffff817daf3b>] _cond_resched+0x2b/0x40
[    0.215420]  [<ffffffff81386cbe>] acpi_ps_complete_op+0x262/0x278
[    0.220023]  [<ffffffff813874df>] acpi_ps_parse_loop+0x80b/0x960
[    0.230023]  [<ffffffff81386607>] acpi_ps_parse_aml+0x98/0x274
[    0.235859]  [<ffffffff81384cbb>] acpi_ns_one_complete_parse+0x103/0x120
[    0.240021]  [<ffffffff810886da>] ? up+0x2a/0x50
[    0.244641]  [<ffffffff81384cf3>] acpi_ns_parse_table+0x1b/0x34
[    0.250022]  [<ffffffff8138242a>] acpi_ns_load_table+0x4a/0x8c
[    0.260023]  [<ffffffff8138947c>] acpi_load_tables+0x9c/0x15d
[    0.265774]  [<ffffffff81d0b0f8>] acpi_early_init+0x6c/0xf7
[    0.270022]  [<ffffffff81cd8d31>] start_kernel+0x400/0x415
[    0.275508]  [<ffffffff81cd8346>] x86_64_start_reservations+0x131/0x135
[    0.280022]  [<ffffffff81cd844d>] x86_64_start_kernel+0x103/0x112

ACPI_PREEMPTION_POINT() is called from acpi_ps_complete_op() and schedules if !PREEMPT. But preemption is disabled as we are in early bootup.

#12 lore raw

Re: Bug: ACPI, scheduling while atomic (was Re: [PATCH 0/4] sched: Make sleep inside atomic detection work on !PREEMPT)

Quoted 33 lines · On Thu, 9 Jun 2011 00:49:41 +0200 Frederic Weisbecker wrote:
Quoted 4 lines · Frederic Weisbecker

Aside it may mostly avoid the need for a specific PROVE_RCU check when we sleep inside an rcu read side critical section.

Better make sleeping inside atomic sections work everywhere.

BTW, it has led to detect a bug in the ACPI code. It happens in !CONFIG_PREEMPT:

[    0.160187] BUG: scheduling while atomic: swapper/0/0x10000002
[    0.166016] no locks held by swapper/0.
[    0.170014] Modules linked in:
[    0.173107] Pid: 0, comm: swapper Not tainted 2.6.39+ #124
[    0.180014] Call Trace:
[    0.182481]  [<ffffffff81048685>] __schedule_bug+0x85/0x90
[    0.187967]  [<ffffffff817da98c>] schedule+0x75c/0xa40
[    0.190022]  [<ffffffff8109a1fd>] ? trace_hardirqs_on+0xd/0x10
[    0.200023]  [<ffffffff813879c0>] ? acpi_ps_free_op+0x22/0x24
[    0.205776]  [<ffffffff810554a5>] __cond_resched+0x25/0x40
[    0.210022]  [<ffffffff817daf3b>] _cond_resched+0x2b/0x40
[    0.215420]  [<ffffffff81386cbe>] acpi_ps_complete_op+0x262/0x278
[    0.220023]  [<ffffffff813874df>] acpi_ps_parse_loop+0x80b/0x960
[    0.230023]  [<ffffffff81386607>] acpi_ps_parse_aml+0x98/0x274
[    0.235859]  [<ffffffff81384cbb>] acpi_ns_one_complete_parse+0x103/0x120
[    0.240021]  [<ffffffff810886da>] ? up+0x2a/0x50
[    0.244641]  [<ffffffff81384cf3>] acpi_ns_parse_table+0x1b/0x34
[    0.250022]  [<ffffffff8138242a>] acpi_ns_load_table+0x4a/0x8c
[    0.260023]  [<ffffffff8138947c>] acpi_load_tables+0x9c/0x15d
[    0.265774]  [<ffffffff81d0b0f8>] acpi_early_init+0x6c/0xf7
[    0.270022]  [<ffffffff81cd8d31>] start_kernel+0x400/0x415
[    0.275508]  [<ffffffff81cd8346>] x86_64_start_reservations+0x131/0x135
[    0.280022]  [<ffffffff81cd844d>] x86_64_start_kernel+0x103/0x112
Quoted 2 lines

ACPI_PREEMPTION_POINT() is called from acpi_ps_complete_op() and schedules if !PREEMPT. But preemption is disabled as we are in early bootup.

This still happens in 3.1-rc[123].
Was there a patch for it?

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

#13 lore raw

Re: Bug: ACPI, scheduling while atomic (was Re: [PATCH 0/4] sched: Make sleep inside atomic detection work on !PREEMPT)

Quoted 35 lines · Randy Dunlap
Quoted 33 lines · On Thu, 9 Jun 2011 00:49:41 +0200 Frederic Weisbecker wrote:
Quoted 4 lines · Frederic Weisbecker

Aside it may mostly avoid the need for a specific PROVE_RCU check when we sleep inside an rcu read side critical section.

Better make sleeping inside atomic sections work everywhere.

BTW, it has led to detect a bug in the ACPI code. It happens in !CONFIG_PREEMPT:

[    0.160187] BUG: scheduling while atomic: swapper/0/0x10000002
[    0.166016] no locks held by swapper/0.
[    0.170014] Modules linked in:
[    0.173107] Pid: 0, comm: swapper Not tainted 2.6.39+ #124
[    0.180014] Call Trace:
[    0.182481]  [<ffffffff81048685>] __schedule_bug+0x85/0x90
[    0.187967]  [<ffffffff817da98c>] schedule+0x75c/0xa40
[    0.190022]  [<ffffffff8109a1fd>] ? trace_hardirqs_on+0xd/0x10
[    0.200023]  [<ffffffff813879c0>] ? acpi_ps_free_op+0x22/0x24
[    0.205776]  [<ffffffff810554a5>] __cond_resched+0x25/0x40
[    0.210022]  [<ffffffff817daf3b>] _cond_resched+0x2b/0x40
[    0.215420]  [<ffffffff81386cbe>] acpi_ps_complete_op+0x262/0x278
[    0.220023]  [<ffffffff813874df>] acpi_ps_parse_loop+0x80b/0x960
[    0.230023]  [<ffffffff81386607>] acpi_ps_parse_aml+0x98/0x274
[    0.235859]  [<ffffffff81384cbb>] acpi_ns_one_complete_parse+0x103/0x120
[    0.240021]  [<ffffffff810886da>] ? up+0x2a/0x50
[    0.244641]  [<ffffffff81384cf3>] acpi_ns_parse_table+0x1b/0x34
[    0.250022]  [<ffffffff8138242a>] acpi_ns_load_table+0x4a/0x8c
[    0.260023]  [<ffffffff8138947c>] acpi_load_tables+0x9c/0x15d
[    0.265774]  [<ffffffff81d0b0f8>] acpi_early_init+0x6c/0xf7
[    0.270022]  [<ffffffff81cd8d31>] start_kernel+0x400/0x415
[    0.275508]  [<ffffffff81cd8346>] x86_64_start_reservations+0x131/0x135
[    0.280022]  [<ffffffff81cd844d>] x86_64_start_kernel+0x103/0x112
Quoted 5 lines
Quoted 2 lines

ACPI_PREEMPTION_POINT() is called from acpi_ps_complete_op() and schedules if !PREEMPT. But preemption is disabled as we are in early bootup.

This still happens in 3.1-rc[123].
Was there a patch for it?

I think this patch should fix it, and may make it to mainline soon:
http://git.kernel.org/?p=linux/kernel/git/paulmck/linux-2.6-rcu.git;a=commitdiff;h=61b12d4413c866abbf0d0cf18f5a2bd4420ca15e

#14 lore raw

Re: Bug: ACPI, scheduling while atomic (was Re: [PATCH 0/4] sched: Make sleep inside atomic detection work on !PREEMPT)

In reply to Randy Dunlap
Quoted 35 lines · Randy Dunlap
Quoted 33 lines · On Thu, 9 Jun 2011 00:49:41 +0200 Frederic Weisbecker wrote:
Quoted 4 lines · Frederic Weisbecker

Aside it may mostly avoid the need for a specific PROVE_RCU check when we sleep inside an rcu read side critical section.

Better make sleeping inside atomic sections work everywhere.

BTW, it has led to detect a bug in the ACPI code. It happens in !CONFIG_PREEMPT:

[    0.160187] BUG: scheduling while atomic: swapper/0/0x10000002
[    0.166016] no locks held by swapper/0.
[    0.170014] Modules linked in:
[    0.173107] Pid: 0, comm: swapper Not tainted 2.6.39+ #124
[    0.180014] Call Trace:
[    0.182481]  [<ffffffff81048685>] __schedule_bug+0x85/0x90
[    0.187967]  [<ffffffff817da98c>] schedule+0x75c/0xa40
[    0.190022]  [<ffffffff8109a1fd>] ? trace_hardirqs_on+0xd/0x10
[    0.200023]  [<ffffffff813879c0>] ? acpi_ps_free_op+0x22/0x24
[    0.205776]  [<ffffffff810554a5>] __cond_resched+0x25/0x40
[    0.210022]  [<ffffffff817daf3b>] _cond_resched+0x2b/0x40
[    0.215420]  [<ffffffff81386cbe>] acpi_ps_complete_op+0x262/0x278
[    0.220023]  [<ffffffff813874df>] acpi_ps_parse_loop+0x80b/0x960
[    0.230023]  [<ffffffff81386607>] acpi_ps_parse_aml+0x98/0x274
[    0.235859]  [<ffffffff81384cbb>] acpi_ns_one_complete_parse+0x103/0x120
[    0.240021]  [<ffffffff810886da>] ? up+0x2a/0x50
[    0.244641]  [<ffffffff81384cf3>] acpi_ns_parse_table+0x1b/0x34
[    0.250022]  [<ffffffff8138242a>] acpi_ns_load_table+0x4a/0x8c
[    0.260023]  [<ffffffff8138947c>] acpi_load_tables+0x9c/0x15d
[    0.265774]  [<ffffffff81d0b0f8>] acpi_early_init+0x6c/0xf7
[    0.270022]  [<ffffffff81cd8d31>] start_kernel+0x400/0x415
[    0.275508]  [<ffffffff81cd8346>] x86_64_start_reservations+0x131/0x135
[    0.280022]  [<ffffffff81cd844d>] x86_64_start_kernel+0x103/0x112
Quoted 6 lines
Quoted 2 lines

ACPI_PREEMPTION_POINT() is called from acpi_ps_complete_op() and schedules if !PREEMPT. But preemption is disabled as we are in early bootup.

This still happens in 3.1-rc[123].
Was there a patch for it?

And still in -rc7. I was looking at Paul's github
(https://github.com/paulmckrcu/linux/) but can't find it.

Quoted 9 lines

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code *** --
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#15 lore raw

Re: Bug: ACPI, scheduling while atomic (was Re: [PATCH 0/4] sched: Make sleep inside atomic detection work on !PREEMPT)

Quoted 39 lines · Davidlohr Bueso
Quoted 38 lines · Randy Dunlap
Quoted 35 lines · On Thu, 9 Jun 2011 00:49:41 +0200 Frederic Weisbecker wrote:
Quoted 4 lines · Frederic Weisbecker

Aside it may mostly avoid the need for a specific PROVE_RCU check when we sleep inside an rcu read side critical section.

Better make sleeping inside atomic sections work everywhere.

BTW, it has led to detect a bug in the ACPI code. It happens in !CONFIG_PREEMPT:

[    0.160187] BUG: scheduling while atomic: swapper/0/0x10000002
[    0.166016] no locks held by swapper/0.
[    0.170014] Modules linked in:
[    0.173107] Pid: 0, comm: swapper Not tainted 2.6.39+ #124
[    0.180014] Call Trace:
[    0.182481]  [<ffffffff81048685>] __schedule_bug+0x85/0x90
[    0.187967]  [<ffffffff817da98c>] schedule+0x75c/0xa40
[    0.190022]  [<ffffffff8109a1fd>] ? trace_hardirqs_on+0xd/0x10
[    0.200023]  [<ffffffff813879c0>] ? acpi_ps_free_op+0x22/0x24
[    0.205776]  [<ffffffff810554a5>] __cond_resched+0x25/0x40
[    0.210022]  [<ffffffff817daf3b>] _cond_resched+0x2b/0x40
[    0.215420]  [<ffffffff81386cbe>] acpi_ps_complete_op+0x262/0x278
[    0.220023]  [<ffffffff813874df>] acpi_ps_parse_loop+0x80b/0x960
[    0.230023]  [<ffffffff81386607>] acpi_ps_parse_aml+0x98/0x274
[    0.235859]  [<ffffffff81384cbb>] acpi_ns_one_complete_parse+0x103/0x120
[    0.240021]  [<ffffffff810886da>] ? up+0x2a/0x50
[    0.244641]  [<ffffffff81384cf3>] acpi_ns_parse_table+0x1b/0x34
[    0.250022]  [<ffffffff8138242a>] acpi_ns_load_table+0x4a/0x8c
[    0.260023]  [<ffffffff8138947c>] acpi_load_tables+0x9c/0x15d
[    0.265774]  [<ffffffff81d0b0f8>] acpi_early_init+0x6c/0xf7
[    0.270022]  [<ffffffff81cd8d31>] start_kernel+0x400/0x415
[    0.275508]  [<ffffffff81cd8346>] x86_64_start_reservations+0x131/0x135
[    0.280022]  [<ffffffff81cd844d>] x86_64_start_kernel+0x103/0x112

ACPI_PREEMPTION_POINT() is called from acpi_ps_complete_op() and schedules if !PREEMPT. But preemption is disabled as we are in early bootup.

Quoted 6 lines
Quoted 3 lines

This still happens in 3.1-rc[123].
Was there a patch for it?

And still in -rc7. I was looking at Paul's github
(https://github.com/paulmckrcu/linux/) but can't find it.

I just updated this with Frederic's new patch series. Or do you mean that you can't access my github tree at all?

Thanx, Paul