aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/lockdep.c16
-rw-r--r--kernel/lockdep_internals.h2
-rw-r--r--kernel/lockdep_proc.c6
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
1460unsigned long nr_lock_chains; 1460unsigned long nr_lock_chains;
1461struct lock_chain lock_chains[MAX_LOCKDEP_CHAINS]; 1461struct lock_chain lock_chains[MAX_LOCKDEP_CHAINS];
1462atomic_t nr_chain_hlocks; 1462int nr_chain_hlocks;
1463static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS]; 1463static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS];
1464 1464
1465struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i) 1465struct 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);
44extern unsigned long nr_lock_classes; 44extern unsigned long nr_lock_classes;
45extern unsigned long nr_list_entries; 45extern unsigned long nr_list_entries;
46extern unsigned long nr_lock_chains; 46extern unsigned long nr_lock_chains;
47extern atomic_t nr_chain_hlocks; 47extern int nr_chain_hlocks;
48extern unsigned long nr_stack_trace_entries; 48extern unsigned long nr_stack_trace_entries;
49 49
50extern unsigned int nr_hardirq_chains; 50extern 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
181static void *lc_next(struct seq_file *m, void *v, loff_t *pos) 182static 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
268static void lockdep_stats_debug_show(struct seq_file *m) 270static 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 = {
750static int __init lockdep_proc_init(void) 752static 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