Skip to content

Commit ca58abc

Browse files
Peter ZijlstraLinus Torvalds
authored andcommitted
lockdep: sanitise CONFIG_PROVE_LOCKING
Ensure that all of the lock dependency tracking code is under CONFIG_PROVE_LOCKING. This allows us to use the held lock tracking code for other purposes. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Acked-by: Ingo Molnar <mingo@elte.hu> Acked-by: Jason Baron <jbaron@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 21f8ca3 commit ca58abc

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎kernel/lockdep.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ static int lockdep_initialized;
9595
unsigned long nr_list_entries;
9696
static struct lock_list list_entries[MAX_LOCKDEP_ENTRIES];
9797

98+
#ifdef CONFIG_PROVE_LOCKING
9899
/*
99100
* Allocate a lockdep entry. (assumes the graph_lock held, returns
100101
* with NULL on failure)
@@ -111,6 +112,7 @@ static struct lock_list *alloc_list_entry(void)
111112
}
112113
return list_entries + nr_list_entries++;
113114
}
115+
#endif
114116

115117
/*
116118
* All data structures here are protected by the global debug_lock.
@@ -140,7 +142,9 @@ LIST_HEAD(all_lock_classes);
140142
static struct list_head classhash_table[CLASSHASH_SIZE];
141143

142144
unsigned long nr_lock_chains;
145+
#ifdef CONFIG_PROVE_LOCKING
143146
static struct lock_chain lock_chains[MAX_LOCKDEP_CHAINS];
147+
#endif
144148

145149
/*
146150
* We put the lock dependency chains into a hash-table as well, to cache
@@ -482,6 +486,7 @@ static void print_lock_dependencies(struct lock_class *class, int depth)
482486
}
483487
}
484488

489+
#ifdef CONFIG_PROVE_LOCKING
485490
/*
486491
* Add a new dependency to the head of the list:
487492
*/
@@ -541,6 +546,7 @@ print_circular_bug_entry(struct lock_list *target, unsigned int depth)
541546

542547
return 0;
543548
}
549+
#endif
544550

545551
static void print_kernel_version(void)
546552
{
@@ -549,6 +555,7 @@ static void print_kernel_version(void)
549555
init_utsname()->version);
550556
}
551557

558+
#ifdef CONFIG_PROVE_LOCKING
552559
/*
553560
* When a circular dependency is detected, print the
554561
* header first:
@@ -639,6 +646,7 @@ check_noncircular(struct lock_class *source, unsigned int depth)
639646
}
640647
return 1;
641648
}
649+
#endif
642650

643651
static int very_verbose(struct lock_class *class)
644652
{
@@ -823,6 +831,7 @@ check_usage(struct task_struct *curr, struct held_lock *prev,
823831

824832
#endif
825833

834+
#ifdef CONFIG_PROVE_LOCKING
826835
static int
827836
print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
828837
struct held_lock *next)
@@ -1087,7 +1096,7 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
10871096

10881097
return 0;
10891098
}
1090-
1099+
#endif
10911100

10921101
/*
10931102
* Is this the address of a static object:
@@ -1307,6 +1316,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
13071316
return class;
13081317
}
13091318

1319+
#ifdef CONFIG_PROVE_LOCKING
13101320
/*
13111321
* Look up a dependency chain. If the key is not present yet then
13121322
* add it and return 1 - in this case the new dependency chain is
@@ -1381,6 +1391,7 @@ static inline int lookup_chain_cache(u64 chain_key, struct lock_class *class)
13811391

13821392
return 1;
13831393
}
1394+
#endif
13841395

13851396
/*
13861397
* We are building curr_chain_key incrementally, so double-check

‎kernel/spinlock.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock)
8888
* _raw_spin_lock_flags() code, because lockdep assumes
8989
* that interrupts are not re-enabled during lock-acquire:
9090
*/
91-
#ifdef CONFIG_PROVE_LOCKING
91+
#ifdef CONFIG_LOCKDEP
9292
_raw_spin_lock(lock);
9393
#else
9494
_raw_spin_lock_flags(lock, &flags);
@@ -305,7 +305,7 @@ unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock, int subclas
305305
* _raw_spin_lock_flags() code, because lockdep assumes
306306
* that interrupts are not re-enabled during lock-acquire:
307307
*/
308-
#ifdef CONFIG_PROVE_SPIN_LOCKING
308+
#ifdef CONFIG_LOCKDEP
309309
_raw_spin_lock(lock);
310310
#else
311311
_raw_spin_lock_flags(lock, &flags);

0 commit comments

Comments
 (0)