maple_tree: Drop span_enode to get ma_state to one cacheline
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 6 Oct 2020 19:21:06 +0000 (15:21 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:12:52 +0000 (15:12 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
include/linux/maple_tree.h
lib/maple_tree.c

index ca66786219713ac0c63afb09422322f2fbc033e4..0810c7427cb49e6fc78a554103504a2c8000789d 100644 (file)
@@ -194,7 +194,6 @@ struct ma_state {
        unsigned long min;              /* The minimum index of this node - implied pivot min */
        unsigned long max;              /* The maximum index of this node - implied pivot max */
        struct maple_node *alloc;       /* Allocated nodes for this operation */
-       struct maple_enode *span_enode; /* Pointer to maple parent/slot that set the max */
        unsigned char depth;            /* depth of tree descent during write */
 };
 
index f8953d3cb1cabf3490873cb4b239c088f0c27bf5..e3d2a10e330e701cd51e746050bbe5eb1fdba9ae 100644 (file)
@@ -2764,7 +2764,7 @@ exists:
 
 /*
  *
- * mas_is_span_() - Set span_enode if there is no value already and the
+ * mas_is_span_() - Check if the write spans the node.
  * entry being written spans this nodes slot or touches the end of this slot and
  * is NULL.
  * @piv - the pivot of the slot in this node
@@ -2794,7 +2794,6 @@ bool mas_is_span_wr(struct ma_state *mas, unsigned long piv,
        }
        trace_mas_is_span_wr(mas, piv, entry);
 
-       mas->span_enode = mas->node;
        return true;
 }
 
@@ -2854,19 +2853,16 @@ bool mas_wr_walk(struct ma_state *mas, unsigned long *range_min,
 {
        enum maple_type type;
 
-       mas->span_enode = NULL;
        while (true) {
                type = mte_node_type(mas->node);
                mas->depth++;
 
-               if (unlikely(!mas_node_walk(mas, type, range_min, range_max)))
-                       return false;
-
+               mas_node_walk(mas, type, range_min, range_max);
                if (mas_is_span_wr(mas, *range_max, type, entry))
-                       return ma_is_leaf(type);
+                       return false;
 
                if (ma_is_leaf(type))
-                       return true;
+                       break;
 
                // Traverse.
                mas->max = *range_max;
@@ -2874,7 +2870,7 @@ bool mas_wr_walk(struct ma_state *mas, unsigned long *range_min,
                mas->node = mas_get_slot(mas, mas_offset(mas));
                mas_set_offset(mas, 0);
        }
-       return false;
+       return true;
 }
 
 static inline void mas_extend_null(struct ma_state *l_mas, struct ma_state *r_mas)
@@ -3108,10 +3104,7 @@ static inline void *_mas_store(struct ma_state *mas, void *entry, bool overwrite
                        goto complete_at_root;
        }
 
-       if (!mas_wr_walk(mas, &r_min, &r_max, entry) && !mas->span_enode)
-               return NULL;
-
-       if (mas->span_enode) {
+       if (!mas_wr_walk(mas, &r_min, &r_max, entry)) {
                if (!overwrite) {
                        mas_set_err(mas, -EEXIST);
                        return NULL; // spanning writes always overwrite something.