Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bcache: Convert to lock_cmp_fn

Replace one of bcache's lockdep_set_novalidate_class() usage with the
newly introduced custom lock nesting annotation.

[peterz: changelog]
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Coly Li <colyli@suse.de>
Link: https://lkml.kernel.org/r/20230509195847.1745548-2-kent.overstreet@linux.dev

authored by

Kent Overstreet and committed by
Peter Zijlstra
4c8a4924 eb1cfd09

+24 -3
+22 -1
drivers/md/bcache/btree.c
··· 559 559 } 560 560 } 561 561 562 + #define cmp_int(l, r) ((l > r) - (l < r)) 563 + 564 + #ifdef CONFIG_PROVE_LOCKING 565 + static int btree_lock_cmp_fn(const struct lockdep_map *_a, 566 + const struct lockdep_map *_b) 567 + { 568 + const struct btree *a = container_of(_a, struct btree, lock.dep_map); 569 + const struct btree *b = container_of(_b, struct btree, lock.dep_map); 570 + 571 + return -cmp_int(a->level, b->level) ?: bkey_cmp(&a->key, &b->key); 572 + } 573 + 574 + static void btree_lock_print_fn(const struct lockdep_map *map) 575 + { 576 + const struct btree *b = container_of(map, struct btree, lock.dep_map); 577 + 578 + printk(KERN_CONT " l=%u %llu:%llu", b->level, 579 + KEY_INODE(&b->key), KEY_OFFSET(&b->key)); 580 + } 581 + #endif 582 + 562 583 static struct btree *mca_bucket_alloc(struct cache_set *c, 563 584 struct bkey *k, gfp_t gfp) 564 585 { ··· 593 572 return NULL; 594 573 595 574 init_rwsem(&b->lock); 596 - lockdep_set_novalidate_class(&b->lock); 575 + lock_set_cmp_fn(&b->lock, btree_lock_cmp_fn, btree_lock_print_fn); 597 576 mutex_init(&b->write_lock); 598 577 lockdep_set_novalidate_class(&b->write_lock); 599 578 INIT_LIST_HEAD(&b->list);
+2 -2
drivers/md/bcache/btree.h
··· 247 247 248 248 static inline void rw_lock(bool w, struct btree *b, int level) 249 249 { 250 - w ? down_write_nested(&b->lock, level + 1) 251 - : down_read_nested(&b->lock, level + 1); 250 + w ? down_write(&b->lock) 251 + : down_read(&b->lock); 252 252 if (w) 253 253 b->seq++; 254 254 }