]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Change hard-coded 127 to MAPLE_NODE_MASK
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 6 Oct 2020 19:20:27 +0000 (15:20 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:30:33 +0000 (12:30 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
include/linux/maple_tree.h
lib/maple_tree.c
lib/test_maple_tree.c

index 25348e7c17bb52b544a3fc28a6217a958e25586c..ca66786219713ac0c63afb09422322f2fbc033e4 100644 (file)
 #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
index edb548f9d4fa3576be10f9b8f1774dd30d5f5074..f8953d3cb1cabf3490873cb4b239c088f0c27bf5 100644 (file)
@@ -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);
index 74039ae4195c5743995fde41a5e00572a8898e63..7fbc66be6a8e1def13ee642d1650188b99dad464 100644 (file)
@@ -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