mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: Ben Collins <bcollins@debian.org>
Cc: Andrew Morton <akpm@osdl.org>,
	kakadu_croc@yahoo.com, linux-kernel@vger.kernel.org,
	linux1394-devel@lists.sourceforge.net
Subject: Re: 2.6.0-test7-mm1
Date: Fri, 17 Oct 2003 00:04:00 +1000	[thread overview]
Message-ID: <20031016140400.GA17357@krispykreme> (raw)
In-Reply-To: <20031016022547.GA615@phunnypharm.org>


> > Anton had a ppc64 patch which implemented the preempt_count beancounting
> > without actually implementing premption.  So might_sleep() does the right
> > thing.
> 
> I might have to dig that out and try to make use of it. Thanks for the
> pointer.

Here is the patch with the ppc64 bits in it. (I already have
might_sleep() littered in asm-ppc64/semaphore.h and asm-ppc64/uaccess.h)

Its a bit old but it seems to dump valid warnings.

Anton


Sleep with spinlock debugging.


 foo-anton/arch/ppc64/Kconfig          |    7 +++++++
 foo-anton/include/asm-ppc64/hardirq.h |    2 +-
 foo-anton/include/linux/preempt.h     |   17 +++++++++++------
 foo-anton/kernel/fork.c               |    2 +-
 foo-anton/kernel/sched.c              |    2 +-
 5 files changed, 21 insertions(+), 9 deletions(-)

diff -puN arch/ppc64/Kconfig~spinlock_sleep arch/ppc64/Kconfig
--- foo/arch/ppc64/Kconfig~spinlock_sleep	2003-10-10 00:23:32.000000000 -0500
+++ foo-anton/arch/ppc64/Kconfig	2003-10-10 00:23:32.000000000 -0500
@@ -385,6 +385,13 @@ config DEBUG_PAGEALLOC
 	  This results in a large slowdown, but helps to find certain types
 	  of memory corruptions.
 
+config DEBUG_SPINLOCK_SLEEP
+	bool "Sleep-inside-spinlock checking"
+	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.
+
 endmenu
 
 source "security/Kconfig"
diff -puN include/asm-ppc64/hardirq.h~spinlock_sleep include/asm-ppc64/hardirq.h
--- foo/include/asm-ppc64/hardirq.h~spinlock_sleep	2003-10-10 00:23:32.000000000 -0500
+++ foo-anton/include/asm-ppc64/hardirq.h	2003-10-10 00:23:32.000000000 -0500
@@ -82,7 +82,7 @@ typedef struct {
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#ifdef CONFIG_PREEMPT
+#if defined(CONFIG_PREEMPT) || defined(CONFIG_DEBUG_SPINLOCK_SLEEP)
 # define in_atomic()	((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -puN include/linux/preempt.h~spinlock_sleep include/linux/preempt.h
--- foo/include/linux/preempt.h~spinlock_sleep	2003-10-10 00:23:32.000000000 -0500
+++ foo-anton/include/linux/preempt.h	2003-10-10 00:23:32.000000000 -0500
@@ -24,6 +24,17 @@ do { \
 
 extern void preempt_schedule(void);
 
+#define preempt_check_resched() \
+do { \
+	if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \
+		preempt_schedule(); \
+} while (0)
+#else
+#define preempt_check_resched()		do { } while (0)
+#endif
+
+#if defined(CONFIG_PREEMPT) || defined(CONFIG_DEBUG_SPINLOCK_SLEEP)
+
 #define preempt_disable() \
 do { \
 	inc_preempt_count(); \
@@ -36,12 +47,6 @@ do { \
 	barrier(); \
 } 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(); \
diff -puN kernel/fork.c~spinlock_sleep kernel/fork.c
--- foo/kernel/fork.c~spinlock_sleep	2003-10-10 00:23:32.000000000 -0500
+++ foo-anton/kernel/fork.c	2003-10-10 00:23:32.000000000 -0500
@@ -850,7 +850,7 @@ struct task_struct *copy_process(unsigne
 	if (p->binfmt && !try_module_get(p->binfmt->module))
 		goto bad_fork_cleanup_put_domain;
 
-#ifdef CONFIG_PREEMPT
+#if defined(CONFIG_PREEMPT) || defined(CONFIG_DEBUG_SPINLOCK_SLEEP)
 	/*
 	 * schedule_tail drops this_rq()->lock so we compensate with a count
 	 * of 1.  Also, we want to start with kernel preemption disabled.
diff -puN kernel/sched.c~spinlock_sleep kernel/sched.c
--- foo/kernel/sched.c~spinlock_sleep	2003-10-10 00:23:32.000000000 -0500
+++ foo-anton/kernel/sched.c	2003-10-10 00:23:32.000000000 -0500
@@ -2533,7 +2533,7 @@ void __init init_idle(task_t *idle, int 
 	local_irq_restore(flags);
 
 	/* Set the preempt count _outside_ the spinlocks! */
-#ifdef CONFIG_PREEMPT
+#if defined(CONFIG_PREEMPT) || defined(CONFIG_DEBUG_SPINLOCK_SLEEP)
 	idle->thread_info->preempt_count = (idle->lock_depth >= 0);
 #else
 	idle->thread_info->preempt_count = 0;

_

  reply	other threads:[~2003-10-16 14:06 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-15 10:11 2.6.0-test7-mm1 Bradley Chapman
2003-10-15 10:22 ` 2.6.0-test7-mm1 Andrew Morton
2003-10-15 12:34   ` 2.6.0-test7-mm1 Bradley Chapman
2003-10-15 12:46     ` 2.6.0-test7-mm1 Tim Schmielau
2003-10-15 12:53       ` 2.6.0-test7-mm1 Bradley Chapman
2003-10-15 17:28     ` 2.6.0-test7-mm1 Andrew Morton
2003-10-15 17:40       ` 2.6.0-test7-mm1 Ben Collins
2003-10-15 17:53         ` 2.6.0-test7-mm1 Andrew Morton
2003-10-16  2:25           ` 2.6.0-test7-mm1 Ben Collins
2003-10-16 14:04             ` Anton Blanchard [this message]
2003-10-18 12:39             ` 2.6.0-test7-mm1 Kristian Høgsberg
2003-10-18 13:27               ` 2.6.0-test7-mm1 Ben Collins
2003-10-18 18:07                 ` This bug appears under 2.6.0-test8 as well (was: 2.6.0-test7-mm1) Bradley Chapman
2003-10-18 19:46                   ` Ben Collins
2003-10-27 20:13                     ` Mike Fedyk
2003-10-27 20:21                       ` Ben Collins
2003-10-15 21:14   ` 2.6.0-test7-mm1 Alexander Hoogerhuis
2003-10-15 21:44     ` 2.6.0-test7-mm1 Andrew Morton
     [not found] <20031016083124.45a171a5.akpm@osdl.org>
2003-10-17  7:03 ` 2.6.0-test7-mm1 Bradley Chapman
2003-10-17  7:25   ` 2.6.0-test7-mm1 Andrew Morton
2003-10-17  9:15     ` 2.6.0-test7-mm1 Russell King
  -- strict thread matches above, loose matches on Subject: below --
2003-10-16 14:44 2.6.0-test7-mm1 Steven Pratt
2003-10-16 14:58 ` 2.6.0-test7-mm1 Andrew Morton
2003-10-16 23:13   ` 2.6.0-test7-mm1 Steven Pratt
2003-10-17  7:23   ` 2.6.0-test7-mm1 Kirill Korotaev
2003-10-16 14:58 ` 2.6.0-test7-mm1 William Lee Irwin III
2003-10-19 14:16 ` 2.6.0-test7-mm1 Alexander Hoogerhuis
2003-10-15 12:17 2.6.0-test7-mm1 Jan Killius
2003-10-15  8:36 2.6.0-test7-mm1 Andrew Morton
2003-10-15 15:20 ` 2.6.0-test7-mm1 Luiz Capitulino
2003-10-15 15:42 ` 2.6.0-test7-mm1 Luiz Capitulino
2003-10-15 16:55   ` 2.6.0-test7-mm1 William Lee Irwin III
2003-10-15 21:40     ` 2.6.0-test7-mm1 William Lee Irwin III
2003-10-16 15:11       ` 2.6.0-test7-mm1 Luiz Capitulino
2003-10-17  8:58     ` 2.6.0-test7-mm1 Kirill Korotaev
2003-10-17  9:10       ` 2.6.0-test7-mm1 William Lee Irwin III
2003-10-17 12:02       ` 2.6.0-test7-mm1 Luiz Capitulino
2003-10-18 17:43 ` 2.6.0-test7-mm1 Thomas Schlichter
2003-10-18 17:50   ` 2.6.0-test7-mm1 Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031016140400.GA17357@krispykreme \
    --to=anton@samba.org \
    --cc=akpm@osdl.org \
    --cc=bcollins@debian.org \
    --cc=kakadu_croc@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome