diff options
author | Huang, Ying <ying.huang@intel.com> | 2008-06-22 23:20:54 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-23 19:28:20 -0400 |
commit | cd1a28e8457e6ebf72c48d84d4e736307e86436e (patch) | |
tree | 09371914495f7e3803016516ba887b593ea64a9b /kernel | |
parent | 443cd507ce7f78c6f8742b72736585c031d5a921 (diff) |
lockdep: add lock_class information to lock_chain and output it
It is based on x86/master branch of git-x86 tree, and has been tested
on x86_64 platform.
ChangeLog:
v2:
- Enclosing proc file system related code into CONFIG_PROVE_LOCKING.
- Fix nr_chain_hlocks update code.
Signed-off-by: Huang Ying <ying.huang@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/lockdep.c | 16 | ||||
-rw-r--r-- | kernel/lockdep_internals.h | 2 | ||||
-rw-r--r-- | kernel/lockdep_proc.c | 6 |
3 files changed, 17 insertions, 7 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index a796f1f38ac5..7553a28b99cd 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -1459,7 +1459,7 @@ out_bug: | |||
1459 | 1459 | ||
1460 | unsigned long nr_lock_chains; | 1460 | unsigned long nr_lock_chains; |
1461 | struct lock_chain lock_chains[MAX_LOCKDEP_CHAINS]; | 1461 | struct lock_chain lock_chains[MAX_LOCKDEP_CHAINS]; |
1462 | atomic_t nr_chain_hlocks; | 1462 | int nr_chain_hlocks; |
1463 | static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS]; | 1463 | static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS]; |
1464 | 1464 | ||
1465 | struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i) | 1465 | struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i) |
@@ -1481,7 +1481,7 @@ static inline int lookup_chain_cache(struct task_struct *curr, | |||
1481 | struct list_head *hash_head = chainhashentry(chain_key); | 1481 | struct list_head *hash_head = chainhashentry(chain_key); |
1482 | struct lock_chain *chain; | 1482 | struct lock_chain *chain; |
1483 | struct held_lock *hlock_curr, *hlock_next; | 1483 | struct held_lock *hlock_curr, *hlock_next; |
1484 | int i, j, n; | 1484 | int i, j, n, cn; |
1485 | 1485 | ||
1486 | if (DEBUG_LOCKS_WARN_ON(!irqs_disabled())) | 1486 | if (DEBUG_LOCKS_WARN_ON(!irqs_disabled())) |
1487 | return 0; | 1487 | return 0; |
@@ -1540,9 +1540,15 @@ cache_hit: | |||
1540 | } | 1540 | } |
1541 | i++; | 1541 | i++; |
1542 | chain->depth = curr->lockdep_depth + 1 - i; | 1542 | chain->depth = curr->lockdep_depth + 1 - i; |
1543 | n = atomic_add_return(chain->depth, &nr_chain_hlocks); | 1543 | cn = nr_chain_hlocks; |
1544 | if (unlikely(n < MAX_LOCKDEP_CHAIN_HLOCKS)) { | 1544 | while (cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS) { |
1545 | chain->base = n - chain->depth; | 1545 | n = cmpxchg(&nr_chain_hlocks, cn, cn + chain->depth); |
1546 | if (n == cn) | ||
1547 | break; | ||
1548 | cn = n; | ||
1549 | } | ||
1550 | if (likely(cn + chain->depth <= MAX_LOCKDEP_CHAIN_HLOCKS)) { | ||
1551 | chain->base = cn; | ||
1546 | for (j = 0; j < chain->depth - 1; j++, i++) { | 1552 | for (j = 0; j < chain->depth - 1; j++, i++) { |
1547 | int lock_id = curr->held_locks[i].class - lock_classes; | 1553 | int lock_id = curr->held_locks[i].class - lock_classes; |
1548 | chain_hlocks[chain->base + j] = lock_id; | 1554 | chain_hlocks[chain->base + j] = lock_id; |
diff --git a/kernel/lockdep_internals.h b/kernel/lockdep_internals.h index db09b176dd34..c3600a091a28 100644 --- a/kernel/lockdep_internals.h +++ b/kernel/lockdep_internals.h | |||
@@ -44,7 +44,7 @@ struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i); | |||
44 | extern unsigned long nr_lock_classes; | 44 | extern unsigned long nr_lock_classes; |
45 | extern unsigned long nr_list_entries; | 45 | extern unsigned long nr_list_entries; |
46 | extern unsigned long nr_lock_chains; | 46 | extern unsigned long nr_lock_chains; |
47 | extern atomic_t nr_chain_hlocks; | 47 | extern int nr_chain_hlocks; |
48 | extern unsigned long nr_stack_trace_entries; | 48 | extern unsigned long nr_stack_trace_entries; |
49 | 49 | ||
50 | extern unsigned int nr_hardirq_chains; | 50 | extern unsigned int nr_hardirq_chains; |
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c index 14d052c8a835..9b0e940e2545 100644 --- a/kernel/lockdep_proc.c +++ b/kernel/lockdep_proc.c | |||
@@ -178,6 +178,7 @@ static const struct file_operations proc_lockdep_operations = { | |||
178 | .release = seq_release, | 178 | .release = seq_release, |
179 | }; | 179 | }; |
180 | 180 | ||
181 | #ifdef CONFIG_PROVE_LOCKING | ||
181 | static void *lc_next(struct seq_file *m, void *v, loff_t *pos) | 182 | static void *lc_next(struct seq_file *m, void *v, loff_t *pos) |
182 | { | 183 | { |
183 | struct lock_chain *chain; | 184 | struct lock_chain *chain; |
@@ -264,6 +265,7 @@ static const struct file_operations proc_lockdep_chains_operations = { | |||
264 | .llseek = seq_lseek, | 265 | .llseek = seq_lseek, |
265 | .release = seq_release, | 266 | .release = seq_release, |
266 | }; | 267 | }; |
268 | #endif /* CONFIG_PROVE_LOCKING */ | ||
267 | 269 | ||
268 | static void lockdep_stats_debug_show(struct seq_file *m) | 270 | static void lockdep_stats_debug_show(struct seq_file *m) |
269 | { | 271 | { |
@@ -382,7 +384,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v) | |||
382 | seq_printf(m, " dependency chains: %11lu [max: %lu]\n", | 384 | seq_printf(m, " dependency chains: %11lu [max: %lu]\n", |
383 | nr_lock_chains, MAX_LOCKDEP_CHAINS); | 385 | nr_lock_chains, MAX_LOCKDEP_CHAINS); |
384 | seq_printf(m, " dependency chain hlocks: %11d [max: %lu]\n", | 386 | seq_printf(m, " dependency chain hlocks: %11d [max: %lu]\n", |
385 | atomic_read(&nr_chain_hlocks), MAX_LOCKDEP_CHAIN_HLOCKS); | 387 | nr_chain_hlocks, MAX_LOCKDEP_CHAIN_HLOCKS); |
386 | #endif | 388 | #endif |
387 | 389 | ||
388 | #ifdef CONFIG_TRACE_IRQFLAGS | 390 | #ifdef CONFIG_TRACE_IRQFLAGS |
@@ -750,8 +752,10 @@ static const struct file_operations proc_lock_stat_operations = { | |||
750 | static int __init lockdep_proc_init(void) | 752 | static int __init lockdep_proc_init(void) |
751 | { | 753 | { |
752 | proc_create("lockdep", S_IRUSR, NULL, &proc_lockdep_operations); | 754 | proc_create("lockdep", S_IRUSR, NULL, &proc_lockdep_operations); |
755 | #ifdef CONFIG_PROVE_LOCKING | ||
753 | proc_create("lockdep_chains", S_IRUSR, NULL, | 756 | proc_create("lockdep_chains", S_IRUSR, NULL, |
754 | &proc_lockdep_chains_operations); | 757 | &proc_lockdep_chains_operations); |
758 | #endif | ||
755 | proc_create("lockdep_stats", S_IRUSR, NULL, | 759 | proc_create("lockdep_stats", S_IRUSR, NULL, |
756 | &proc_lockdep_stats_operations); | 760 | &proc_lockdep_stats_operations); |
757 | 761 | ||