Commit ca268c69 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] lockdep: increase max allowed recursion depth

In general, lockdep warnings are intended to be non-fatal, so I have put in
various practical limits on internal data structure failure modes.  We haven't
had a /single/ lockdep-internal crash ever since lockdep went upstream [the
unwinder crashes are outside of lockdep], and that's largely due to the good
internal checks it does.

Recursion within the dependency graph is currently limited to 20, that's
probably not enough on some many-CPU boxes - this patch doubles it to 40.  I
have written the lockdep functions to have as small stackframes as possible,
so 40 should be OK too.  (The practical recursion limit should be somewhere
between 100 and 200 entries.  If we hit that then I'll change the algorithm to
be iteration-based.  Graph walking logic is so easy to program via recursion,
so i'd like to keep recursion as long as possible.)
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 623a4395
...@@ -575,6 +575,8 @@ static noinline int print_circular_bug_tail(void) ...@@ -575,6 +575,8 @@ static noinline int print_circular_bug_tail(void)
return 0; return 0;
} }
#define RECURSION_LIMIT 40
static int noinline print_infinite_recursion_bug(void) static int noinline print_infinite_recursion_bug(void)
{ {
__raw_spin_unlock(&hash_lock); __raw_spin_unlock(&hash_lock);
...@@ -595,7 +597,7 @@ check_noncircular(struct lock_class *source, unsigned int depth) ...@@ -595,7 +597,7 @@ check_noncircular(struct lock_class *source, unsigned int depth)
debug_atomic_inc(&nr_cyclic_check_recursions); debug_atomic_inc(&nr_cyclic_check_recursions);
if (depth > max_recursion_depth) if (depth > max_recursion_depth)
max_recursion_depth = depth; max_recursion_depth = depth;
if (depth >= 20) if (depth >= RECURSION_LIMIT)
return print_infinite_recursion_bug(); return print_infinite_recursion_bug();
/* /*
* Check this lock's dependency list: * Check this lock's dependency list:
...@@ -645,7 +647,7 @@ find_usage_forwards(struct lock_class *source, unsigned int depth) ...@@ -645,7 +647,7 @@ find_usage_forwards(struct lock_class *source, unsigned int depth)
if (depth > max_recursion_depth) if (depth > max_recursion_depth)
max_recursion_depth = depth; max_recursion_depth = depth;
if (depth >= 20) if (depth >= RECURSION_LIMIT)
return print_infinite_recursion_bug(); return print_infinite_recursion_bug();
debug_atomic_inc(&nr_find_usage_forwards_checks); debug_atomic_inc(&nr_find_usage_forwards_checks);
...@@ -684,7 +686,7 @@ find_usage_backwards(struct lock_class *source, unsigned int depth) ...@@ -684,7 +686,7 @@ find_usage_backwards(struct lock_class *source, unsigned int depth)
if (depth > max_recursion_depth) if (depth > max_recursion_depth)
max_recursion_depth = depth; max_recursion_depth = depth;
if (depth >= 20) if (depth >= RECURSION_LIMIT)
return print_infinite_recursion_bug(); return print_infinite_recursion_bug();
debug_atomic_inc(&nr_find_usage_backwards_checks); debug_atomic_inc(&nr_find_usage_backwards_checks);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment