public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	 Matthew Wilcox <willy@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, maple-tree@lists.infradead.org,
	 Christian Brauner <brauner@kernel.org>
Subject: [PATCH RFC v2 1/2] maple_tree: make MT_FLAGS_LOCK_IRQ do something
Date: Mon, 09 Dec 2024 14:46:57 +0100	[thread overview]
Message-ID: <20241209-work-pidfs-maple_tree-v2-1-003dbf3bd96b@kernel.org> (raw)
In-Reply-To: <20241209-work-pidfs-maple_tree-v2-0-003dbf3bd96b@kernel.org>

I'm not sure what the original intention was but I take it that it wsas
to indicate that the lock to be taken must be irq safe. I need this for
pidfs as it's called from alloc_pid() which expects irq safe locking.
Make mtree_{un}lock() check MT_FLAGS_LOCK_IRQ and if present call
spin_{un}lock_irq().

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 include/linux/maple_tree.h | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h
index cbbcd18d418684c36a61a1439c3eb04cd17480b0..5cb9a48731f97e56b2fe43228808043e2f7e98bc 100644
--- a/include/linux/maple_tree.h
+++ b/include/linux/maple_tree.h
@@ -268,10 +268,22 @@ struct maple_tree {
 #define DEFINE_MTREE(name)						\
 	struct maple_tree name = MTREE_INIT(name, 0)
 
-#define mtree_lock(mt)		spin_lock((&(mt)->ma_lock))
+static __always_inline void mtree_lock(struct maple_tree *mt)
+{
+	if (mt->ma_flags & MT_FLAGS_LOCK_IRQ)
+		spin_lock_irq(&mt->ma_lock);
+	else
+		spin_lock(&mt->ma_lock);
+}
+static __always_inline void mtree_unlock(struct maple_tree *mt)
+{
+	if (mt->ma_flags & MT_FLAGS_LOCK_IRQ)
+		spin_unlock_irq(&mt->ma_lock);
+	else
+		spin_unlock(&mt->ma_lock);
+}
 #define mtree_lock_nested(mas, subclass) \
 		spin_lock_nested((&(mt)->ma_lock), subclass)
-#define mtree_unlock(mt)	spin_unlock((&(mt)->ma_lock))
 
 /*
  * The Maple Tree squeezes various bits in at various points which aren't

-- 
2.45.2


  reply	other threads:[~2024-12-09 13:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09 13:46 [PATCH RFC v2 0/2] pidfs: use maple tree Christian Brauner
2024-12-09 13:46 ` Christian Brauner [this message]
2024-12-09 13:46 ` [PATCH RFC v2 2/2] " Christian Brauner
2024-12-13 10:35   ` Marek Szyprowski
2024-12-13 13:07     ` Christian Brauner
2024-12-13 14:16       ` Marek Szyprowski
2024-12-13 14:40 ` [PATCH RFC v2 0/2] " Liam R. Howlett
2024-12-13 18:51   ` Christian Brauner
2024-12-13 18:53     ` Matthew Wilcox
2024-12-13 19:01       ` Christian Brauner
2024-12-13 19:25         ` Christian Brauner
2024-12-13 20:11           ` Christian Brauner
2024-12-13 20:50             ` Christian Brauner
2024-12-13 21:07               ` Christian Brauner
2024-12-13 21:16                 ` Liam R. Howlett
2024-12-13 21:13               ` Liam R. Howlett
2024-12-13 21:04             ` Liam R. Howlett
2024-12-14 11:48               ` Christian Brauner
2024-12-17 17:41                 ` Liam R. Howlett

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=20241209-work-pidfs-maple_tree-v2-1-003dbf3bd96b@kernel.org \
    --to=brauner@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=maple-tree@lists.infradead.org \
    --cc=willy@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