Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e2d551e authored by Ming Lei's avatar Ming Lei Committed by Peter Zijlstra
Browse files

lockdep: Introduce match function to BFS



1,introduce match() to BFS in order to make it usable to
match different pattern;

2,also rename some functions to make them more suitable.

Signed-off-by: default avatarMing Lei <tom.leiming@gmail.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1246201486-7308-4-git-send-email-tom.leiming@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent d588e461
Loading
Loading
Loading
Loading
+26 −17
Original line number Original line Diff line number Diff line
@@ -900,8 +900,9 @@ static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
unsigned long bfs_accessed[BITS_TO_LONGS(MAX_LOCKDEP_ENTRIES)];
unsigned long bfs_accessed[BITS_TO_LONGS(MAX_LOCKDEP_ENTRIES)];
static struct circular_queue  lock_cq;
static struct circular_queue  lock_cq;


static int __search_shortest_path(struct lock_list *source_entry,
static int __bfs(struct lock_list *source_entry,
				struct lock_class *target,
			void *data,
			int (*match)(struct lock_list *entry, void *data),
			struct lock_list **target_entry,
			struct lock_list **target_entry,
			int forward)
			int forward)
{
{
@@ -910,7 +911,7 @@ static int __search_shortest_path(struct lock_list *source_entry,
	struct circular_queue *cq = &lock_cq;
	struct circular_queue *cq = &lock_cq;
	int ret = 1;
	int ret = 1;


	if (source_entry->class == target) {
	if (match(source_entry, data)) {
		*target_entry = source_entry;
		*target_entry = source_entry;
		ret = 0;
		ret = 0;
		goto exit;
		goto exit;
@@ -945,7 +946,7 @@ static int __search_shortest_path(struct lock_list *source_entry,
		list_for_each_entry(entry, head, entry) {
		list_for_each_entry(entry, head, entry) {
			if (!lock_accessed(entry)) {
			if (!lock_accessed(entry)) {
				mark_lock_accessed(entry, lock);
				mark_lock_accessed(entry, lock);
				if (entry->class == target) {
				if (match(entry, data)) {
					*target_entry = entry;
					*target_entry = entry;
					ret = 0;
					ret = 0;
					goto exit;
					goto exit;
@@ -962,19 +963,21 @@ static int __search_shortest_path(struct lock_list *source_entry,
	return ret;
	return ret;
}
}


static inline int __search_forward_shortest_path(struct lock_list *src_entry,
static inline int __bfs_forward(struct lock_list *src_entry,
				struct lock_class *target,
			void *data,
			int (*match)(struct lock_list *entry, void *data),
			struct lock_list **target_entry)
			struct lock_list **target_entry)
{
{
	return __search_shortest_path(src_entry, target, target_entry, 1);
	return __bfs(src_entry, data, match, target_entry, 1);


}
}


static inline int __search_backward_shortest_path(struct lock_list *src_entry,
static inline int __bfs_backward(struct lock_list *src_entry,
				struct lock_class *target,
			void *data,
			int (*match)(struct lock_list *entry, void *data),
			struct lock_list **target_entry)
			struct lock_list **target_entry)
{
{
	return __search_shortest_path(src_entry, target, target_entry, 0);
	return __bfs(src_entry, data, match, target_entry, 0);


}
}


@@ -1035,6 +1038,11 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth)
	return 0;
	return 0;
}
}


static inline int class_equal(struct lock_list *entry, void *data)
{
	return entry->class == data;
}

static noinline int print_circular_bug(void)
static noinline int print_circular_bug(void)
{
{
	struct task_struct *curr = current;
	struct task_struct *curr = current;
@@ -1052,8 +1060,9 @@ static noinline int print_circular_bug(void)
	if (!save_trace(&this.trace))
	if (!save_trace(&this.trace))
		return 0;
		return 0;


	result = __search_forward_shortest_path(&this,
	result = __bfs_forward(&this,
			hlock_class(check_target),
			hlock_class(check_target),
			class_equal,
			&target);
			&target);
	if (result) {
	if (result) {
		printk("\n%s:search shortest path failed:%d\n", __func__,
		printk("\n%s:search shortest path failed:%d\n", __func__,