From: Matthew Wilcox (Oracle) Date: Tue, 19 Oct 2021 18:29:21 +0000 (-0400) Subject: maple_tree: Use MT_FLAGS_ X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c9ad27cdff44e353cec322f46913925ffc39a397;p=users%2Fwilly%2Flinux.git maple_tree: Use MT_FLAGS_ 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) --- diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 319974be5ea1..7fc49ad3b34d 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -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); } diff --git a/lib/maple_tree.c b/lib/maple_tree.c index e46970ecd871..da3d4488821a 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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); } /*