From: Kent Overstreet <kent.overstreet@linux.dev>
To: linux-kernel@vger.kernel.org, peterz@infradead.org
Cc: Kent Overstreet <kent.overstreet@linux.dev>, Coly Li <colyli@suse.de>
Subject: [PATCH 2/2] bcache: Convert to lock_cmp_fn
Date: Tue, 9 May 2023 15:58:47 -0400 [thread overview]
Message-ID: <20230509195847.1745548-2-kent.overstreet@linux.dev> (raw)
In-Reply-To: <20230509195847.1745548-1-kent.overstreet@linux.dev>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Coly Li <colyli@suse.de>
---
drivers/md/bcache/btree.c | 23 ++++++++++++++++++++++-
drivers/md/bcache/btree.h | 4 ++--
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 147c493a98..569f48958b 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -559,6 +559,27 @@ static void mca_data_alloc(struct btree *b, struct bkey *k, gfp_t gfp)
}
}
+#define cmp_int(l, r) ((l > r) - (l < r))
+
+#ifdef CONFIG_PROVE_LOCKING
+static int btree_lock_cmp_fn(const struct lockdep_map *_a,
+ const struct lockdep_map *_b)
+{
+ const struct btree *a = container_of(_a, struct btree, lock.dep_map);
+ const struct btree *b = container_of(_b, struct btree, lock.dep_map);
+
+ return -cmp_int(a->level, b->level) ?: bkey_cmp(&a->key, &b->key);
+}
+
+static void btree_lock_print_fn(const struct lockdep_map *map)
+{
+ const struct btree *b = container_of(map, struct btree, lock.dep_map);
+
+ printk(KERN_CONT " l=%u %llu:%llu", b->level,
+ KEY_INODE(&b->key), KEY_OFFSET(&b->key));
+}
+#endif
+
static struct btree *mca_bucket_alloc(struct cache_set *c,
struct bkey *k, gfp_t gfp)
{
@@ -572,7 +593,7 @@ static struct btree *mca_bucket_alloc(struct cache_set *c,
return NULL;
init_rwsem(&b->lock);
- lockdep_set_novalidate_class(&b->lock);
+ lock_set_cmp_fn(&b->lock, btree_lock_cmp_fn, btree_lock_print_fn);
mutex_init(&b->write_lock);
lockdep_set_novalidate_class(&b->write_lock);
INIT_LIST_HEAD(&b->list);
diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h
index 1b5fdbc0d8..17b1d201ce 100644
--- a/drivers/md/bcache/btree.h
+++ b/drivers/md/bcache/btree.h
@@ -247,8 +247,8 @@ static inline void bch_btree_op_init(struct btree_op *op, int write_lock_level)
static inline void rw_lock(bool w, struct btree *b, int level)
{
- w ? down_write_nested(&b->lock, level + 1)
- : down_read_nested(&b->lock, level + 1);
+ w ? down_write(&b->lock)
+ : down_read(&b->lock);
if (w)
b->seq++;
}
--
2.40.1
next prev parent reply other threads:[~2023-05-09 19:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 19:58 [PATCH 1/2] lockdep: lock_set_cmp_fn() Kent Overstreet
2023-05-09 19:58 ` Kent Overstreet [this message]
2023-05-10 5:25 ` [PATCH 2/2] bcache: Convert to lock_cmp_fn Coly Li
2023-05-10 13:01 ` Peter Zijlstra
2023-05-10 17:05 ` Kent Overstreet
2023-05-25 5:07 ` Kent Overstreet
[not found] ` <168457974565.404.16611061652498882569.tip-bot2@tip-bot2>
2023-05-21 13:21 ` [tip: locking/core] " Coly Li
2023-05-22 8:34 ` Peter Zijlstra
2023-05-24 10:31 ` tip-bot2 for Kent Overstreet
2023-05-09 21:54 ` [PATCH 1/2] lockdep: lock_set_cmp_fn() kernel test robot
2023-05-09 23:26 ` kernel test robot
2023-05-20 10:49 ` [tip: locking/core] lockdep: Add lock_set_cmp_fn() annotation tip-bot2 for Kent Overstreet
-- strict thread matches above, loose matches on Subject: below --
2023-02-18 3:21 [PATCH 0/2] lockdep lock comparison function Kent Overstreet
2023-02-18 3:21 ` [PATCH 2/2] bcache: Convert to lock_cmp_fn Kent Overstreet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230509195847.1745548-2-kent.overstreet@linux.dev \
--to=kent.overstreet@linux.dev \
--cc=colyli@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox