diff options
author | Ming Lei <tom.leiming@gmail.com> | 2009-07-16 09:44:29 -0400 |
---|---|---|
committer | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-07-24 04:49:46 -0400 |
commit | d588e46155e9c51217b9840db1e94a0f594c1af2 (patch) | |
tree | 0ede7d7d8338f8db15d8c690c46a0173196d7bac /kernel/lockdep.c | |
parent | c94aa5ca3088018d2a7a9bd3258aefffe29df265 (diff) |
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.c | 23 |
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 @@ | |||
42 | #include <linux/hash.h> | 42 | #include <linux/hash.h> |
43 | #include <linux/ftrace.h> | 43 | #include <linux/ftrace.h> |
44 | #include <linux/stringify.h> | 44 | #include <linux/stringify.h> |
45 | 45 | #include <linux/bitops.h> | |
46 | #include <asm/sections.h> | 46 | #include <asm/sections.h> |
47 | 47 | ||
48 | #include "lockdep_internals.h" | 48 | #include "lockdep_internals.h" |
@@ -118,7 +118,7 @@ static inline int debug_locks_off_graph_unlock(void) | |||
118 | static int lockdep_initialized; | 118 | static int lockdep_initialized; |
119 | 119 | ||
120 | unsigned long nr_list_entries; | 120 | unsigned long nr_list_entries; |
121 | static struct lock_list list_entries[MAX_LOCKDEP_ENTRIES]; | 121 | struct lock_list list_entries[MAX_LOCKDEP_ENTRIES]; |
122 | 122 | ||
123 | /* | 123 | /* |
124 | * All data structures here are protected by the global debug_lock. | 124 | * 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, | |||
897 | return 1; | 897 | return 1; |
898 | } | 898 | } |
899 | 899 | ||
900 | unsigned long bfs_accessed[BITS_TO_LONGS(MAX_LOCKDEP_ENTRIES)]; | ||
900 | static struct circular_queue lock_cq; | 901 | static struct circular_queue lock_cq; |
902 | |||
901 | static int __search_shortest_path(struct lock_list *source_entry, | 903 | static int __search_shortest_path(struct lock_list *source_entry, |
902 | struct lock_class *target, | 904 | struct lock_class *target, |
903 | struct lock_list **target_entry, | 905 | struct lock_list **target_entry, |
904 | int forward) | 906 | int forward) |
905 | { | 907 | { |
906 | struct lock_list *entry; | 908 | struct lock_list *entry; |
909 | struct list_head *head; | ||
907 | struct circular_queue *cq = &lock_cq; | 910 | struct circular_queue *cq = &lock_cq; |
908 | int ret = 1; | 911 | int ret = 1; |
909 | 912 | ||
910 | __cq_init(cq); | ||
911 | |||
912 | mark_lock_accessed(source_entry, NULL); | ||
913 | if (source_entry->class == target) { | 913 | if (source_entry->class == target) { |
914 | *target_entry = source_entry; | 914 | *target_entry = source_entry; |
915 | ret = 0; | 915 | ret = 0; |
916 | goto exit; | 916 | goto exit; |
917 | } | 917 | } |
918 | 918 | ||
919 | if (forward) | ||
920 | head = &source_entry->class->locks_after; | ||
921 | else | ||
922 | head = &source_entry->class->locks_before; | ||
923 | |||
924 | if (list_empty(head)) | ||
925 | goto exit; | ||
926 | |||
927 | __cq_init(cq); | ||
919 | __cq_enqueue(cq, (unsigned long)source_entry); | 928 | __cq_enqueue(cq, (unsigned long)source_entry); |
920 | 929 | ||
921 | while (!__cq_empty(cq)) { | 930 | while (!__cq_empty(cq)) { |
922 | struct lock_list *lock; | 931 | struct lock_list *lock; |
923 | struct list_head *head; | ||
924 | 932 | ||
925 | __cq_dequeue(cq, (unsigned long *)&lock); | 933 | __cq_dequeue(cq, (unsigned long *)&lock); |
926 | 934 | ||
@@ -1040,6 +1048,7 @@ static noinline int print_circular_bug(void) | |||
1040 | return 0; | 1048 | return 0; |
1041 | 1049 | ||
1042 | this.class = hlock_class(check_source); | 1050 | this.class = hlock_class(check_source); |
1051 | this.parent = NULL; | ||
1043 | if (!save_trace(&this.trace)) | 1052 | if (!save_trace(&this.trace)) |
1044 | return 0; | 1053 | return 0; |
1045 | 1054 | ||
@@ -1580,10 +1589,10 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev, | |||
1580 | */ | 1589 | */ |
1581 | check_source = next; | 1590 | check_source = next; |
1582 | check_target = prev; | 1591 | check_target = prev; |
1592 | |||
1583 | if (check_noncircular(hlock_class(next), 0) == 2) | 1593 | if (check_noncircular(hlock_class(next), 0) == 2) |
1584 | return print_circular_bug(); | 1594 | return print_circular_bug(); |
1585 | 1595 | ||
1586 | |||
1587 | if (!check_prev_add_irq(curr, prev, next)) | 1596 | if (!check_prev_add_irq(curr, prev, next)) |
1588 | return 0; | 1597 | return 0; |
1589 | 1598 | ||