From 5b3bfd9dc3ca405d49a9f4b6948b4e1aa420ee86 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 6 Oct 2020 15:20:27 -0400 Subject: [PATCH] maple_tree: Change hard-coded 127 to MAPLE_NODE_MASK Signed-off-by: Liam R. Howlett --- include/linux/maple_tree.h | 3 ++- lib/maple_tree.c | 16 ++++++++-------- lib/test_maple_tree.c | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 25348e7c17bb..ca6678621971 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -32,13 +32,14 @@ #define MAPLE_NODE_SLOTS 31 /* 256 bytes including ->parent */ #define MAPLE_RANGE64_SLOTS 16 /* 256 bytes */ #define MAPLE_ARANGE64_SLOTS 10 /* 240 bytes */ +#define MAPLE_NODE_MASK 255UL #else #define MAPLE_NODE_SLOTS 15 /* 128 bytes including ->parent */ #define MAPLE_RANGE64_SLOTS 8 /* 128 bytes */ #define MAPLE_ARANGE64_SLOTS 5 /* 120 bytes */ +#define MAPLE_NODE_MASK 127UL #endif // End NODE256 -#define MA_MAX_ALLOC 127 #else /* Need to do corresponding calculations for 32-bit kernels */ #endif diff --git a/lib/maple_tree.c b/lib/maple_tree.c index edb548f9d4fa..f8953d3cb1ca 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -352,9 +352,8 @@ static inline unsigned int mte_parent_slot(const struct maple_enode *enode) */ static inline struct maple_node *mte_parent(const struct maple_enode *enode) { - unsigned long bitmask = 0x7F; - - return (void *)((unsigned long)(mte_to_node(enode)->parent) & ~bitmask); + return (void *)((unsigned long) + (mte_to_node(enode)->parent) & ~MAPLE_NODE_MASK); } /* @@ -381,7 +380,8 @@ static inline bool mte_dead_node(const struct maple_enode *enode) */ static inline struct maple_node *mas_get_alloc(const struct ma_state *mas) { - return (struct maple_node *)((unsigned long)mas->alloc & ~0x7F); + return (struct maple_node *) + ((unsigned long)mas->alloc & ~MAPLE_NODE_MASK); } /* @@ -440,8 +440,8 @@ static inline int mas_alloc_cnt(const struct ma_state *mas) */ static inline void mas_set_alloc_req(struct ma_state *mas, int count) { - mas->alloc = (struct maple_node *)((unsigned long)mas->alloc & ~0x7F); - mas->alloc = (struct maple_node *)((unsigned long)mas->alloc | count); + mas->alloc = (struct maple_node *) + (((unsigned long)mas->alloc & ~MAPLE_NODE_MASK) | count); } /* @@ -450,7 +450,7 @@ static inline void mas_set_alloc_req(struct ma_state *mas, int count) */ static inline int mas_alloc_req(const struct ma_state *mas) { - return (int)(((unsigned long)mas->alloc & 0x7F)); + return (int)(((unsigned long)mas->alloc & MAPLE_NODE_MASK)); } /* @@ -985,7 +985,7 @@ static inline struct maple_node *mas_node_cnt(struct ma_state *mas, int count) { int allocated = mas_alloc_cnt(mas); - BUG_ON(count > 127); + //BUG_ON(count > 127); if (allocated < count) { mas_set_alloc_req(mas, count - allocated); mas_node_node(mas, GFP_NOWAIT | __GFP_NOWARN); diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index 74039ae4195c..7fbc66be6a8e 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -291,7 +291,7 @@ static noinline void check_new_node(struct maple_tree *mt) MT_BUG_ON(mt, mas_alloc_cnt(&mas) != 0); } - for (i = 1; i < 128; i++) { + for (i = 1; i < MAPLE_NODE_MASK + 1; i++) { MA_STATE(mas2, mt, 0, 0); mas_node_cnt(&mas, i); // Request mas_nomem(&mas, GFP_KERNEL); // Fill request -- 2.50.1