]> www.infradead.org Git - users/willy/linux.git/commitdiff
maple_tree: Use MT_FLAGS_
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 19 Oct 2021 18:29:21 +0000 (14:29 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 19 Oct 2021 18:29:21 +0000 (14:29 -0400)
Move the maple tree flags into their own namespace, instead of jumbling
them with all the other MAPLE_ defines.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/maple_tree.h
lib/maple_tree.c

index 319974be5ea171aa4aaa92983d85d68416782418..7fc49ad3b34da71c86a9c1ca1c955d6fd6ac5b1a 100644 (file)
@@ -48,7 +48,7 @@ typedef struct maple_pnode *maple_pnode; /* parent node */
 
 
 /**
- * maple_tree node explained
+ * DOC: maple_tree node explained
  *
  * Each node type has a number of slots for entries and a number of slots for
  * pivots.  In the case of dense nodes, the pivots are implied by the position
@@ -129,18 +129,27 @@ enum maple_type {
 
 
 /**
- * Flags:
- * MAPLE_ALLOC_RANGE   Use allocation ranges (tracks gaps) in this tree
- * MAPLE_USE_RCU       Operate in read/copy/update mode for multi-readers
- * MAPLE_HEIGHT_OFFSET The position of the tree height in the flags
- * MAPLE_HEIGHT_MASK   The mask for the maple tree height value
+ * DOC: Maple tree flags
+ *
+ * * MT_FLAGS_ALLOC_RANGE      - Track gaps in this tree
+ * * MT_FLAGS_USE_RCU          - Operate in RCU mode
+ * * MT_FLAGS_HEIGHT_OFFSET    - The position of the tree height in the flags
+ * * MT_FLAGS_HEIGHT_MASK      - The mask for the maple tree height value
+ * * MT_FLAGS_LOCK_MASK                - How the mt_lock is used
+ * * MT_FLAGS_LOCK_IRQ         - Acquired irq-safe
+ * * MT_FLAGS_LOCK_BH          - Acquired bh-safe
+ * * MT_FLAGS_LOCK_EXTERN      - mt_lock is not used
  *
  * MAPLE_HEIGHT_MAX    The largest height that can be stored
  */
-#define MAPLE_ALLOC_RANGE      0x01
-#define MAPLE_USE_RCU          0x02
-#define        MAPLE_HEIGHT_OFFSET     0x02
-#define        MAPLE_HEIGHT_MASK       0x7C
+#define MT_FLAGS_ALLOC_RANGE   0x01
+#define MT_FLAGS_USE_RCU               0x02
+#define        MT_FLAGS_HEIGHT_OFFSET  0x02
+#define        MT_FLAGS_HEIGHT_MASK    0x7C
+#define MT_FLAGS_LOCK_MASK     0x300
+#define MT_FLAGS_LOCK_IRQ      0x100
+#define MT_FLAGS_LOCK_BH       0x200
+#define MT_FLAGS_LOCK_EXTERN   0x300
 
 #define MAPLE_HEIGHT_MAX       31
 
@@ -415,7 +424,7 @@ static inline bool mt_in_rcu(struct maple_tree *mt)
 #ifdef CONFIG_MAPLE_RCU_DISABLED
        return false;
 #endif
-       return mt->ma_flags & MAPLE_USE_RCU;
+       return mt->ma_flags & MT_FLAGS_USE_RCU;
 }
 /**
  * mt_clear_in_rcu() - Switch the tree to non-RCU mode.
@@ -426,7 +435,7 @@ static inline void mt_clear_in_rcu(struct maple_tree *mt)
                return;
 
        mtree_lock(mt);
-       mt->ma_flags &= ~MAPLE_USE_RCU;
+       mt->ma_flags &= ~MT_FLAGS_USE_RCU;
        mtree_unlock(mt);
 }
 
@@ -439,7 +448,7 @@ static inline void mt_set_in_rcu(struct maple_tree *mt)
                return;
 
        mtree_lock(mt);
-       mt->ma_flags |= MAPLE_USE_RCU;
+       mt->ma_flags |= MT_FLAGS_USE_RCU;
        mtree_unlock(mt);
 }
 
index e46970ecd871304734655955e3809843eb9627c1..da3d4488821add6ff16a663dce7206ded3f2bff7 100644 (file)
@@ -122,7 +122,7 @@ static void ma_free_rcu(struct maple_node *node)
 
 static unsigned int mt_height(const struct maple_tree *mt)
 {
-       return (mt->ma_flags & MAPLE_HEIGHT_MASK) >> MAPLE_HEIGHT_OFFSET;
+       return (mt->ma_flags & MT_FLAGS_HEIGHT_MASK) >> MT_FLAGS_HEIGHT_OFFSET;
 }
 
 
@@ -130,9 +130,9 @@ static void mas_set_height(struct ma_state *mas)
 {
        unsigned int new_flags = mas->tree->ma_flags;
 
-       new_flags &= ~MAPLE_HEIGHT_MASK;
+       new_flags &= ~MT_FLAGS_HEIGHT_MASK;
        BUG_ON(mas->depth > MAPLE_HEIGHT_MAX);
-       new_flags |= mas->depth << MAPLE_HEIGHT_OFFSET;
+       new_flags |= mas->depth << MT_FLAGS_HEIGHT_OFFSET;
        mas->tree->ma_flags = new_flags;
 }
 
@@ -292,7 +292,7 @@ static inline bool mas_is_root_limits(const struct ma_state *mas)
 
 static inline bool mt_is_alloc(struct maple_tree *mt)
 {
-       return (mt->ma_flags & MAPLE_ALLOC_RANGE);
+       return (mt->ma_flags & MT_FLAGS_ALLOC_RANGE);
 }
 
 /*