maple_tree: Remove slot shift calculations.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 7 Dec 2020 20:55:13 +0000 (15:55 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:33:34 +0000 (12:33 -0500)
Slot shift is always 3 now, so don't calculate it.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index f6cbf8d92fcc01136485b5a7ba71e3b570831b0e..bdc2a1c1b64bed8059ad1649556d5f672f76f2c8 100644 (file)
@@ -259,13 +259,7 @@ static inline bool mt_is_alloc(struct maple_tree *mt)
        return (mt->ma_flags & MAPLE_ALLOC_RANGE);
 }
 
-
-static inline unsigned int mte_parent_shift(unsigned long parent)
-{
-       if (!(parent & 2))
-               return 2; // maple_range_16
-       return 3;
-}
+#define MAPLE_PARENT_SHIFT 3
 
 static inline enum maple_type mte_parent_range_enum(unsigned long parent)
 {
@@ -287,12 +281,10 @@ static inline enum maple_type mas_parent_enum(struct ma_state *mas,
                struct maple_enode *node)
 {
        unsigned long parent = 6;
-       unsigned long slot_shift;
 
-       if (!mte_is_root(mas->node)) {
+       if (likely(!mte_is_root(mas->node))) {
                parent = (unsigned long) mte_to_node(node)->parent;
-               slot_shift = mte_parent_shift(parent);
-               parent &= (1 << slot_shift) - 1;
+               parent &= (1 << MAPLE_PARENT_SHIFT) - 1;
        }
 
        if (mt_is_alloc(mas->tree))
@@ -310,7 +302,7 @@ static inline enum maple_type mas_parent_enum(struct ma_state *mas,
  * Type is encoded in the enode->parent
  * bit 0: 1 = root, 0 otherwise
  * bit 1: Reserved.
- * bit 2: 0 = range 32, 1 = [a]range 64 | lowest bit of range_16's slot.
+ * bit 2: 0 = range 32, 1 = [a]range 64
  *
  * Slot number is encoded in the enode->parent
  * range_32, slot number is encoded in bits 3-6
@@ -321,22 +313,20 @@ static inline void mte_set_parent(struct maple_enode *enode,
                                 unsigned char slot)
 {
        unsigned long bitmask = 0x78;
-       unsigned long slot_shift = 3;
        unsigned long val = (unsigned long) parent;
        unsigned long type = 0;
 
        switch (mte_node_type(parent)) {
        case maple_range_64:
        case maple_arange_64:
-               type |= 4;
-               type |= 2;
+               type = 6;
                break;
        default:
                break;
        }
 
        val &= ~bitmask; // Remove any old slot number.
-       val |= (slot << slot_shift); // Set the slot.
+       val |= (slot << MAPLE_PARENT_SHIFT); // Set the slot.
        val |= type;
        mte_to_node(enode)->parent = ma_parent_ptr(val);
 }
@@ -351,12 +341,11 @@ static inline unsigned int mte_parent_slot(const struct maple_enode *enode)
 {
        unsigned long bitmask = 0x7C;
        unsigned long val = (unsigned long) mte_to_node(enode)->parent;
-       unsigned long slot_shift = mte_parent_shift(val);
 
        if (val & 1)
                return 0; // Root.
 
-       return (val & bitmask) >> slot_shift;
+       return (val & bitmask) >> MAPLE_PARENT_SHIFT;
 }
 
 /*