[PATCH RFC v2 1/2] maple_tree: make MT_FLAGS_LOCK_IRQ do something
Christian Brauner
brauner at kernel.org
Mon Dec 9 05:46:57 PST 2024
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 at 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
More information about the maple-tree
mailing list