From: Ioannis Angelakopoulos <iangelak@fb.com>
To: <linux-btrfs@vger.kernel.org>, <kernel-team@fb.com>
Subject: [PATCH 1/1] btrfs: Macros for multilevel annotations of wait events with lockdep
Date: Thu, 11 Aug 2022 17:17:36 -0700 [thread overview]
Message-ID: <20220812001734.1587514-2-iangelak@fb.com> (raw)
In-Reply-To: <20220812001734.1587514-1-iangelak@fb.com>
The new macros are similar to the generic lockdep annotation macros used to
annotate wait events in btrfs in fs/btrfs/ctree.h. However, the new macros
take as a parameter the subclass of the lockdep map, which can be used for
a multilevel annotation of a wait event.
The new macros introduced are:
1) btrfs_might_wait_for_event_nested()
2) btrfs_lockdep_acquire_nested()
Signed-off-by: Ioannis Angelakopoulos <iangelak@fb.com>
---
fs/btrfs/ctree.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 51c480439263..44837545eef8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1211,6 +1211,16 @@ enum btrfs_lockdep_trans_states {
rwsem_release(&owner->lock##_map, _THIS_IP_); \
} while (0)
+/*
+ * Same as the btrfs_wait_for_event() macro but used for multilevel lockdep
+ * annotations.
+ */
+#define btrfs_might_wait_for_event_nested(owner, lock, subclass) \
+ do { \
+ rwsem_acquire(&owner->lock##_map, subclass, 0, _THIS_IP_); \
+ rwsem_release(&owner->lock##_map, _THIS_IP_); \
+ } while (0)
+
/*
* Protection for the resource/condition of a wait event.
*
@@ -1225,6 +1235,13 @@ enum btrfs_lockdep_trans_states {
#define btrfs_lockdep_acquire(owner, lock) \
rwsem_acquire_read(&owner->lock##_map, 0, 0, _THIS_IP_)
+/*
+ * Same as the btrfs_lockdep_acquire() macro but used for multilevel lockdep
+ * annotations.
+ */
+#define btrfs_lockdep_acquire_nested(owner, lock, subclass) \
+ rwsem_acquire_read(&owner->lock##_map, subclass, 0, _THIS_IP_)
+
/*
* Used after signaling the condition for a wait event to release the lockdep
* map held by a reader thread.
--
2.30.2
prev parent reply other threads:[~2022-08-12 0:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 0:17 [PATCH 0/1] btrfs: Add macros for multilevel wait event annotations with lockdep Ioannis Angelakopoulos
2022-08-12 0:17 ` Ioannis Angelakopoulos [this message]
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=20220812001734.1587514-2-iangelak@fb.com \
--to=iangelak@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.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