Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * kernel/lockdep_internals.h |
| 3 | * |
| 4 | * Runtime locking correctness validator |
| 5 | * |
| 6 | * lockdep subsystem internal functions and variables. |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * MAX_LOCKDEP_ENTRIES is the maximum number of lock dependencies |
| 11 | * we track. |
| 12 | * |
| 13 | * We use the per-lock dependency maps in two ways: we grow it by adding |
| 14 | * every to-be-taken lock to all currently held lock's own dependency |
| 15 | * table (if it's not there yet), and we check it for lock order |
| 16 | * conflicts and deadlocks. |
| 17 | */ |
| 18 | #define MAX_LOCKDEP_ENTRIES 8192UL |
| 19 | |
Ingo Molnar | 50cc670 | 2006-12-06 20:39:30 -0800 | [diff] [blame] | 20 | #define MAX_LOCKDEP_CHAINS_BITS 14 |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 21 | #define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS) |
| 22 | |
Huang, Ying | 443cd50 | 2008-06-20 16:39:21 +0800 | [diff] [blame] | 23 | #define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5) |
| 24 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 25 | /* |
| 26 | * Stack-trace: tightly packed array of stack backtrace |
| 27 | * addresses. Protected by the hash_lock. |
| 28 | */ |
Ingo Molnar | 9bb25bf | 2006-09-12 20:35:50 -0700 | [diff] [blame] | 29 | #define MAX_STACK_TRACE_ENTRIES 262144UL |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 30 | |
| 31 | extern struct list_head all_lock_classes; |
Huang, Ying | 443cd50 | 2008-06-20 16:39:21 +0800 | [diff] [blame] | 32 | extern struct lock_chain lock_chains[]; |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 33 | |
| 34 | extern void |
| 35 | get_usage_chars(struct lock_class *class, char *c1, char *c2, char *c3, char *c4); |
| 36 | |
| 37 | extern const char * __get_key_name(struct lockdep_subclass_key *key, char *str); |
| 38 | |
Huang, Ying | 443cd50 | 2008-06-20 16:39:21 +0800 | [diff] [blame] | 39 | struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i); |
| 40 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 41 | extern unsigned long nr_lock_classes; |
| 42 | extern unsigned long nr_list_entries; |
| 43 | extern unsigned long nr_lock_chains; |
Huang, Ying | cd1a28e | 2008-06-23 11:20:54 +0800 | [diff] [blame] | 44 | extern int nr_chain_hlocks; |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 45 | extern unsigned long nr_stack_trace_entries; |
| 46 | |
| 47 | extern unsigned int nr_hardirq_chains; |
| 48 | extern unsigned int nr_softirq_chains; |
| 49 | extern unsigned int nr_process_chains; |
| 50 | extern unsigned int max_lockdep_depth; |
| 51 | extern unsigned int max_recursion_depth; |
| 52 | |
Ingo Molnar | d6672c5 | 2008-08-01 11:23:50 +0200 | [diff] [blame] | 53 | #ifdef CONFIG_PROVE_LOCKING |
David Miller | 419ca3f | 2008-07-29 21:45:03 -0700 | [diff] [blame] | 54 | extern unsigned long lockdep_count_forward_deps(struct lock_class *); |
| 55 | extern unsigned long lockdep_count_backward_deps(struct lock_class *); |
Ingo Molnar | d6672c5 | 2008-08-01 11:23:50 +0200 | [diff] [blame] | 56 | #else |
| 57 | static inline unsigned long |
| 58 | lockdep_count_forward_deps(struct lock_class *class) |
| 59 | { |
| 60 | return 0; |
| 61 | } |
| 62 | static inline unsigned long |
| 63 | lockdep_count_backward_deps(struct lock_class *class) |
| 64 | { |
| 65 | return 0; |
| 66 | } |
| 67 | #endif |
David Miller | 419ca3f | 2008-07-29 21:45:03 -0700 | [diff] [blame] | 68 | |
Ingo Molnar | fbb9ce95 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 69 | #ifdef CONFIG_DEBUG_LOCKDEP |
| 70 | /* |
| 71 | * Various lockdep statistics: |
| 72 | */ |
| 73 | extern atomic_t chain_lookup_hits; |
| 74 | extern atomic_t chain_lookup_misses; |
| 75 | extern atomic_t hardirqs_on_events; |
| 76 | extern atomic_t hardirqs_off_events; |
| 77 | extern atomic_t redundant_hardirqs_on; |
| 78 | extern atomic_t redundant_hardirqs_off; |
| 79 | extern atomic_t softirqs_on_events; |
| 80 | extern atomic_t softirqs_off_events; |
| 81 | extern atomic_t redundant_softirqs_on; |
| 82 | extern atomic_t redundant_softirqs_off; |
| 83 | extern atomic_t nr_unused_locks; |
| 84 | extern atomic_t nr_cyclic_checks; |
| 85 | extern atomic_t nr_cyclic_check_recursions; |
| 86 | extern atomic_t nr_find_usage_forwards_checks; |
| 87 | extern atomic_t nr_find_usage_forwards_recursions; |
| 88 | extern atomic_t nr_find_usage_backwards_checks; |
| 89 | extern atomic_t nr_find_usage_backwards_recursions; |
| 90 | # define debug_atomic_inc(ptr) atomic_inc(ptr) |
| 91 | # define debug_atomic_dec(ptr) atomic_dec(ptr) |
| 92 | # define debug_atomic_read(ptr) atomic_read(ptr) |
| 93 | #else |
| 94 | # define debug_atomic_inc(ptr) do { } while (0) |
| 95 | # define debug_atomic_dec(ptr) do { } while (0) |
| 96 | # define debug_atomic_read(ptr) 0 |
| 97 | #endif |