From: tip-bot for Steven Rostedt <srostedt@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
torvalds@linux-foundation.org, a.p.zijlstra@chello.nl,
fweisbec@gmail.com, akpm@linux-foundation.org,
rostedt@goodmis.org, srostedt@redhat.com, tglx@linutronix.de,
mingo@elte.hu
Subject: [tip:core/locking] lockdep: Print a nicer description for normal deadlocks
Date: Fri, 22 Apr 2011 12:20:00 GMT [thread overview]
Message-ID: <tip-f4185812aa046ecb97e8817e10148cacdd7a6baa@git.kernel.org> (raw)
In-Reply-To: <20110421014259.380621789@goodmis.org>
Commit-ID: f4185812aa046ecb97e8817e10148cacdd7a6baa
Gitweb: http://git.kernel.org/tip/f4185812aa046ecb97e8817e10148cacdd7a6baa
Author: Steven Rostedt <srostedt@redhat.com>
AuthorDate: Wed, 20 Apr 2011 21:41:55 -0400
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 22 Apr 2011 11:06:57 +0200
lockdep: Print a nicer description for normal deadlocks
The lockdep output can be pretty cryptic, having nicer output
can save a lot of head scratching. When a normal deadlock
scenario is detected by lockdep (lock A -> lock B and there
exists a place where lock B -> lock A) we now get the following
new output:
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(lockB);
lock(lockA);
lock(lockB);
lock(lockA);
*** DEADLOCK ***
On cases where there's a deeper chair, it shows the partial
chain that can cause the issue:
Chain exists of:
lockC --> lockA --> lockB
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(lockB);
lock(lockA);
lock(lockB);
lock(lockC);
*** DEADLOCK ***
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20110421014259.380621789@goodmis.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/lockdep.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 7b2ffee..73cebd7 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -1065,6 +1065,56 @@ print_circular_bug_entry(struct lock_list *target, int depth)
return 0;
}
+static void
+print_circular_lock_scenario(struct held_lock *src,
+ struct held_lock *tgt,
+ struct lock_list *prt)
+{
+ struct lock_class *source = hlock_class(src);
+ struct lock_class *target = hlock_class(tgt);
+ struct lock_class *parent = prt->class;
+
+ /*
+ * A direct locking problem where unsafe_class lock is taken
+ * directly by safe_class lock, then all we need to show
+ * is the deadlock scenario, as it is obvious that the
+ * unsafe lock is taken under the safe lock.
+ *
+ * But if there is a chain instead, where the safe lock takes
+ * an intermediate lock (middle_class) where this lock is
+ * not the same as the safe lock, then the lock chain is
+ * used to describe the problem. Otherwise we would need
+ * to show a different CPU case for each link in the chain
+ * from the safe_class lock to the unsafe_class lock.
+ */
+ if (parent != source) {
+ printk("Chain exists of:\n ");
+ __print_lock_name(source);
+ printk(" --> ");
+ __print_lock_name(parent);
+ printk(" --> ");
+ __print_lock_name(target);
+ printk("\n\n");
+ }
+
+ printk(" Possible unsafe locking scenario:\n\n");
+ printk(" CPU0 CPU1\n");
+ printk(" ---- ----\n");
+ printk(" lock(");
+ __print_lock_name(target);
+ printk(");\n");
+ printk(" lock(");
+ __print_lock_name(parent);
+ printk(");\n");
+ printk(" lock(");
+ __print_lock_name(target);
+ printk(");\n");
+ printk(" lock(");
+ __print_lock_name(source);
+ printk(");\n");
+ printk("\n *** DEADLOCK ***\n\n");
+}
+
/*
* When a circular dependency is detected, print the
* header first:
@@ -1108,6 +1158,7 @@ static noinline int print_circular_bug(struct lock_list *this,
{
struct task_struct *curr = current;
struct lock_list *parent;
+ struct lock_list *first_parent;
int depth;
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
@@ -1121,6 +1172,7 @@ static noinline int print_circular_bug(struct lock_list *this,
print_circular_bug_header(target, depth, check_src, check_tgt);
parent = get_lock_parent(target);
+ first_parent = parent;
while (parent) {
print_circular_bug_entry(parent, --depth);
@@ -1128,6 +1180,9 @@ static noinline int print_circular_bug(struct lock_list *this,
}
printk("\nother info that might help us debug this:\n\n");
+ print_circular_lock_scenario(check_src, check_tgt,
+ first_parent);
+
lockdep_print_held_locks(curr);
printk("\nstack backtrace:\n");
next prev parent reply other threads:[~2011-04-22 12:20 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 1:41 [PATCH 0/7] [GIT PULL] lockdep: Show description of lockdep problems Steven Rostedt
2011-04-21 1:41 ` [PATCH 1/7] lockdep: Print a nice description of an irq locking issue Steven Rostedt
2011-04-21 6:43 ` Yong Zhang
2011-04-21 7:02 ` Yong Zhang
2011-04-21 7:08 ` Yong Zhang
2011-04-21 11:40 ` Steven Rostedt
2011-04-21 13:35 ` Yong Zhang
2011-04-21 14:24 ` Steven Rostedt
2011-04-22 1:41 ` Yong Zhang
2011-04-22 2:34 ` Steven Rostedt
2011-04-22 6:10 ` Ingo Molnar
2011-04-22 12:19 ` [tip:core/locking] lockdep: Print a nicer description for irq lock inversions tip-bot for Steven Rostedt
2011-04-21 1:41 ` [PATCH 2/7] lockdep: Print a nice description of normal deadlocks Steven Rostedt
2011-04-22 12:20 ` tip-bot for Steven Rostedt [this message]
2011-04-21 1:41 ` [PATCH 3/7] lockdep: Print a nice description of simple deadlock Steven Rostedt
2011-04-22 12:20 ` [tip:core/locking] lockdep: Print a nicer description for simple deadlocks tip-bot for Steven Rostedt
2011-04-21 1:41 ` [PATCH 4/7] lockdep: Printk nice description for irq inversion bug Steven Rostedt
2011-04-22 12:20 ` [tip:core/locking] lockdep: Print a nicer description for irq inversion bugs tip-bot for Steven Rostedt
2011-04-21 1:41 ` [PATCH 5/7] lockdep: Replace bad path error message with something sane Steven Rostedt
2011-04-22 12:21 ` [tip:core/locking] lockdep: Replace "Bad BFS generated tree" message with something less cryptic tip-bot for Steven Rostedt
2011-04-21 1:41 ` [PATCH 6/7] lockdep: Print a nice description of simple irq inversion Steven Rostedt
2011-04-22 12:21 ` [tip:core/locking] lockdep: Print a nicer description for simple irq lock inversions tip-bot for Steven Rostedt
2011-04-21 1:42 ` [PATCH 7/7] lockdep: Remove cmpxchg to update nr_chain_hlocks Steven Rostedt
2011-04-21 6:50 ` Yong Zhang
2011-04-22 12:22 ` [tip:core/locking] " tip-bot for Steven Rostedt
2011-04-21 6:25 ` [PATCH 0/7] [GIT PULL] lockdep: Show description of lockdep problems Yong Zhang
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=tip-f4185812aa046ecb97e8817e10148cacdd7a6baa@git.kernel.org \
--to=srostedt@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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