Skip to contentSkip to conversation

kernel:lockdep:print the shortest dependency chain if finding a circle

PATCH In review [email protected] 2 participants 3 messages May 21, 2009 – May 22, 2009 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel:lockdep:print the shortest dependency chain if finding a circle

From: Ming Lei <[email protected]>

Currently lockdep will print the 1st circle detected if it exists when acquiring a new (next) lock.

This patch prints the shortest path from the next lock to be acquired to the previous held lock if a circle is found.

The patch still uses the current method to check circle, and once the circle is found, breadth-first search algorithem is used to compute the shortest path from the next lock to the previous lock in the forward lock dependency graph.

Printing the shortest path will shorten the dependency chain, and make troubleshooting for possible circular locking easier.

---
 include/linux/lockdep.h    |    6 ++
 kernel/lockdep.c           |  115 ++++++++++++++++++++++++++++++++++++++++----
 kernel/lockdep_internals.h |   83 +++++++++++++++++++++++++++++++
 3 files changed, 195 insertions(+), 9 deletions(-)
include/linux/lockdep.h +6 -0
index da5a5a1..5bd21fc 100644
@@ -149,6 +149,12 @@ struct lock_list {
 	struct lock_class		*class;
 	struct stack_trace		trace;
 	int				distance;
+
+	/*The parent field is used to implement breadth-first search,and
+	 *the bit 0 is reused to indicate if the lock has been accessed
+	 *in BFS.
+	 */
+	struct lock_list		*parent;
 };
 
 /*
kernel/lockdep.c +106 -9

160 lines not on this page · raw message

kernel/lockdep_internals.h +83 -0

86 lines not on this page · raw message

Signature · 1 line
1.6.0.GIT
author
#1 lore raw

Any objections or suggestions?

Thanks.

Signature · 1 line
Lei Ming
#2 lore raw
Quoted 1 line · Ming Lei

Any objections or suggestions?

Non yet, yesterday was a holiday here in Europe and I haven't had time to go over the patch in detail yet.

I do appreciate it though and at a first glance it does look good.