summaryrefslogtreecommitdiffstats
path: root/kernel/lockdep.c
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2009-07-16 15:44:29 +0200
committerPeter Zijlstra <a.p.zijlstra@chello.nl>2009-07-24 10:49:46 +0200
commitd588e46155e9c51217b9840db1e94a0f594c1af2 (patch)
tree0ede7d7d8338f8db15d8c690c46a0173196d7bac /kernel/lockdep.c
parentc94aa5ca3088018d2a7a9bd3258aefffe29df265 (diff)
downloadlinux-d588e46155e9c51217b9840db1e94a0f594c1af2.tar.gz
linux-d588e46155e9c51217b9840db1e94a0f594c1af2.tar.bz2
linux-d588e46155e9c51217b9840db1e94a0f594c1af2.zip
lockdep: Improve implementation of BFS
1,replace %MAX_CIRCULAR_QUE_SIZE with &(MAX_CIRCULAR_QUE_SIZE-1) since we define MAX_CIRCULAR_QUE_SIZE as power of 2; 2,use bitmap to mark if a lock is accessed in BFS in order to clear it quickly, because we may search a graph many times. Signed-off-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1246201486-7308-3-git-send-email-tom.leiming@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/lockdep.c')
-rw-r--r--kernel/lockdep.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 93dc70d18cdf..5dcca26a8263 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -42,7 +42,7 @@
#include <linux/hash.h>
#include <linux/ftrace.h>
#include <linux/stringify.h>
-
+#include <linux/bitops.h>
#include <asm/sections.h>
#include "lockdep_internals.h"
@@ -118,7 +118,7 @@ static inline int debug_locks_off_graph_unlock(void)
static int lockdep_initialized;
unsigned long nr_list_entries;
-static struct lock_list list_entries[MAX_LOCKDEP_ENTRIES];
+struct lock_list list_entries[MAX_LOCKDEP_ENTRIES];
/*
* All data structures here are protected by the global debug_lock.
@@ -897,30 +897,38 @@ static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
return 1;
}
+unsigned long bfs_accessed[BITS_TO_LONGS(MAX_LOCKDEP_ENTRIES)];
static struct circular_queue lock_cq;
+
static int __search_shortest_path(struct lock_list *source_entry,
struct lock_class *target,
struct lock_list **target_entry,
int forward)
{
struct lock_list *entry;
+ struct list_head *head;
struct circular_queue *cq = &lock_cq;
int ret = 1;
- __cq_init(cq);
-
- mark_lock_accessed(source_entry, NULL);
if (source_entry->class == target) {
*target_entry = source_entry;
ret = 0;
goto exit;
}
+ if (forward)
+ head = &source_entry->class->locks_after;
+ else
+ head = &source_entry->class->locks_before;
+
+ if (list_empty(head))
+ goto exit;
+
+ __cq_init(cq);
__cq_enqueue(cq, (unsigned long)source_entry);
while (!__cq_empty(cq)) {
struct lock_list *lock;
- struct list_head *head;
__cq_dequeue(cq, (unsigned long *)&lock);
@@ -1040,6 +1048,7 @@ static noinline int print_circular_bug(void)
return 0;
this.class = hlock_class(check_source);
+ this.parent = NULL;
if (!save_trace(&this.trace))
return 0;
@@ -1580,10 +1589,10 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
*/
check_source = next;
check_target = prev;
+
if (check_noncircular(hlock_class(next), 0) == 2)
return print_circular_bug();
-
if (!check_prev_add_irq(curr, prev, next))
return 0;