public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [RFC][PATCH -rt] spinlock: frob debug bits
Date: Fri, 02 Sep 2011 14:41:33 +0200	[thread overview]
Message-ID: <1314967293.1301.13.camel@twins> (raw)

Not sure this is actually worth it, but since I wrote it I thought I
might as well send it out. Didn't actually need it. Once I frobbed the
printk stuff to work again there were plenty error to point out what
gone wrong.

---
Subject: spinlock: frob debug bits
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Fri Sep 02 14:29:30 CEST 2011

gets more debug on a spinlock lockup, but also destroys all lock
debugging.. you win some, you loose some..

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-3h4nzmhbik02u9xp9logjrv4@git.kernel.org
---
 lib/spinlock_debug.c |   19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

Index: linux-2.6/lib/spinlock_debug.c
===================================================================
--- linux-2.6.orig/lib/spinlock_debug.c
+++ linux-2.6/lib/spinlock_debug.c
@@ -54,7 +54,7 @@ static void spin_bug(raw_spinlock_t *loc
 {
 	struct task_struct *owner = NULL;
 
-	if (!debug_locks_off())
+	if (unlikely(!debug_locks))
 		return;
 
 	if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT)
@@ -69,6 +69,11 @@ static void spin_bug(raw_spinlock_t *loc
 		owner ? task_pid_nr(owner) : -1,
 		lock->owner_cpu);
 	dump_stack();
+	debug_show_all_locks();
+#ifdef CONFIG_SMP
+	trigger_all_cpu_backtrace();
+#endif
+	debug_locks_off();
 }
 
 #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg)
@@ -112,17 +117,7 @@ static void __spin_lock_debug(raw_spinlo
 			__delay(1);
 		}
 		/* lockup suspected: */
-		if (print_once) {
-			print_once = 0;
-			printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, "
-					"%s/%d, %p\n",
-				raw_smp_processor_id(), current->comm,
-				task_pid_nr(current), lock);
-			dump_stack();
-#ifdef CONFIG_SMP
-			trigger_all_cpu_backtrace();
-#endif
-		}
+		SPIN_BUG_ON(1, lock, "timeout");
 	}
 }
 


                 reply	other threads:[~2011-09-02 12:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1314967293.1301.13.camel@twins \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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