Skip to content

Commit 1a616c2

Browse files
author
Kent Overstreet
committed
lockdep: lockdep_set_notrack_class()
Add a new helper to disable lockdep tracking entirely for a given class. This is needed for bcachefs, which takes too many btree node locks for lockdep to track. Instead, we have a single lockdep_map for "btree_trans has any btree nodes locked", which makes more since given that we have centralized lock management and a cycle detector. Cc: Peter Zijlstra <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Will Deacon <[email protected]> Cc: Waiman Long <[email protected]> Cc: Boqun Feng <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 8f523d4 commit 1a616c2

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

fs/bcachefs/btree_locking.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void bch2_btree_lock_init(struct btree_bkey_cached_common *b,
1010
enum six_lock_init_flags flags)
1111
{
1212
__six_lock_init(&b->lock, "b->c.lock", &bch2_btree_node_lock_key, flags);
13-
lockdep_set_novalidate_class(&b->lock);
13+
lockdep_set_notrack_class(&b->lock);
1414
}
1515

1616
#ifdef CONFIG_LOCKDEP

include/linux/lockdep.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ static inline void lockdep_init_map(struct lockdep_map *lock, const char *name,
181181
#define lockdep_set_novalidate_class(lock) \
182182
lockdep_set_class_and_name(lock, &__lockdep_no_validate__, #lock)
183183

184+
#define lockdep_set_notrack_class(lock) \
185+
lockdep_set_class_and_name(lock, &__lockdep_no_track__, #lock)
186+
184187
/*
185188
* Compare locking classes
186189
*/
@@ -338,6 +341,7 @@ static inline void lockdep_set_selftest_task(struct task_struct *task)
338341
#define lockdep_set_subclass(lock, sub) do { } while (0)
339342

340343
#define lockdep_set_novalidate_class(lock) do { } while (0)
344+
#define lockdep_set_notrack_class(lock) do { } while (0)
341345

342346
/*
343347
* We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP

include/linux/lockdep_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct lock_class_key {
8080
};
8181

8282
extern struct lock_class_key __lockdep_no_validate__;
83+
extern struct lock_class_key __lockdep_no_track__;
8384

8485
struct lock_trace;
8586

kernel/locking/lockdep.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4918,6 +4918,9 @@ EXPORT_SYMBOL_GPL(lockdep_init_map_type);
49184918
struct lock_class_key __lockdep_no_validate__;
49194919
EXPORT_SYMBOL_GPL(__lockdep_no_validate__);
49204920

4921+
struct lock_class_key __lockdep_no_track__;
4922+
EXPORT_SYMBOL_GPL(__lockdep_no_track__);
4923+
49214924
#ifdef CONFIG_PROVE_LOCKING
49224925
void lockdep_set_lock_cmp_fn(struct lockdep_map *lock, lock_cmp_fn cmp_fn,
49234926
lock_print_fn print_fn)
@@ -5002,6 +5005,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
50025005
if (unlikely(!debug_locks))
50035006
return 0;
50045007

5008+
if (unlikely(lock->key == &__lockdep_no_track__))
5009+
return 0;
5010+
50055011
if (!prove_locking || lock->key == &__lockdep_no_validate__)
50065012
check = 0;
50075013

@@ -5764,7 +5770,8 @@ void lock_release(struct lockdep_map *lock, unsigned long ip)
57645770

57655771
trace_lock_release(lock, ip);
57665772

5767-
if (unlikely(!lockdep_enabled()))
5773+
if (unlikely(!lockdep_enabled() ||
5774+
lock->key == &__lockdep_no_track__))
57685775
return;
57695776

57705777
raw_local_irq_save(flags);

0 commit comments

Comments
 (0)