]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mas_wr_split cleanup and some comments
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 8 Apr 2025 15:07:39 +0000 (11:07 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 8 Apr 2025 15:07:39 +0000 (11:07 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c
tools/testing/radix-tree/maple.c

index 65fbb23faac4e8841ac6f749e36d9bae447f305a..edc2ebcb2eb274798d2b806a061db8645a347260 100644 (file)
@@ -3821,6 +3821,21 @@ static inline void mas_wr_converged(struct ma_node_info *src,
        mni_finalise(dst);
 }
 
+/*
+ *
+ * @src: The node information of the source
+ * @left: The node information of the left destination
+ * @right: The node information of the right destination
+ * @ma_part: The node part being inserted
+ * @split: The split location referenced by the destination size
+ * @insert: The location of the insert start for @ma_part
+ * @size: The targeted size of the left node
+ * @offset: The starting offset into the destination
+ * @node_ins_end: The offset in the source the insert ends
+ * @total_data: The total size of the data being stored
+ * @state: The maple node state array
+ * @i: The number of existing states
+ */
 static int mt_wr_split_data(struct ma_node_info *src,
                struct ma_node_info *left, struct ma_node_info *right,
                struct ma_node_part *ma_part, unsigned char split,
@@ -4019,6 +4034,17 @@ try_right:
 }
 
 #if 0
+static void mas_wr_rebalance(struct ma_wr_state *wr_mas)
+{
+       struct ma_node_info src_info, parent, left, right;
+       struct ma_node_state src;
+       struct ma_node_part ma_part;
+
+       mni_node_init(&left, mas_pop_node(mas), wr_mas->type);
+       if (mt_is_alloc(mas->tree))
+               right.alloc = left.alloc = true;
+}
+
 /*
  * There is insufficient data in the node after a store.
  * This rebalance will succeed, not like the split variant that will attempt
@@ -4188,8 +4214,7 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
        struct ma_state *mas = wr_mas->mas;
        struct ma_node_state state[4];
        unsigned char i = 0;
-       struct ma_node_info src_info, parent, left, right;
-       struct ma_node_state src;
+       struct ma_node_info src, parent, left, right;
        struct ma_node_part ma_part;
        int height;
        unsigned char split, total;
@@ -4202,24 +4227,21 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
        /* First split the leaves */
        mni_node_init(&left, mas_pop_node(mas), wr_mas->type);
        mni_node_init(&right, mas_pop_node(mas), wr_mas->type);
-       mns_mas_init(&src, &src_info, mas);
-       mns_node_part_leaf_init(&ma_part, wr_mas, &src_info);
+       mni_mas_init(&src, mas);
+       mns_node_part_leaf_init(&ma_part, wr_mas, &src);
        total = mas->end + ma_part.size;
 
-       if (mt_is_alloc(mas->tree)) {
+       if (mt_is_alloc(mas->tree))
                right.alloc = left.alloc = true;
-       }
 
-       if (height > 1 &&
-                       mas_wr_try_rebalance(mas, &src_info, total, &left,
-                                            &right, &ma_part, wr_mas->offset_end))
+       if (height > 1 && mas_wr_try_rebalance(mas, &src, total, &left,
+                                       &right, &ma_part, wr_mas->offset_end))
                goto rebalanced;
 
        split = (total + 1) / 2;
        left.min = mas->min;
        right.max = mas->max;
-
-       i = mt_wr_split_data(&src_info, &left, &right, &ma_part, split,
+       i = mt_wr_split_data(&src, &left, &right, &ma_part, split,
                             mas->offset, split, 0, wr_mas->offset_end,
                             total, state, 0);
        mns_assemble(state, i);
@@ -4233,24 +4255,24 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
 
        //printk("%d height is %d\n", __LINE__, height);
        while (--height) {
-               mas_wr_ascend_init(mas, &src_info);
-               mas->end = src_info.end;
+               mas_wr_ascend_init(mas, &src);
+               mas->end = src.end;
                total = mas->end + 1;
-               if (mas->end + 1 < mt_slots[src_info.type])
+               if (mas->end + 1 < mt_slots[src.type])
                        goto converged;
 
-               mni_node_init(&left, mas_pop_node(mas), src_info.type);
-               mni_node_init(&right, mas_pop_node(mas), src_info.type);
+               mni_node_init(&left, mas_pop_node(mas), src.type);
+               mni_node_init(&right, mas_pop_node(mas), src.type);
                if ((height > 1) &&
-                   (mas_wr_try_rebalance(mas, &src_info, mas->end + 1, &left,
-                                         &right, &ma_part, src_info.insert_off)))
+                   (mas_wr_try_rebalance(mas, &src, mas->end + 1, &left,
+                                         &right, &ma_part, src.insert_off)))
                        goto rebalanced;
 
-               left.min = src_info.min;
-               right.max = src_info.max;
+               left.min = src.min;
+               right.max = src.max;
                split = (total + 1) / 2;
 
-               i = mt_wr_split_data(&src_info, &left, &right, &ma_part, split,
+               i = mt_wr_split_data(&src, &left, &right, &ma_part, split,
                                     mas->offset, split, 0, mas->offset,
                                     total, state, 0);
                mns_assemble(state, i);
@@ -4262,24 +4284,24 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
 new_root:
        /* Converged on new root */
        mas->depth++;
-       src_info.insert_off = mas->offset = 0;
+       src.insert_off = mas->offset = 0;
        mas->end = 0;
        mas_set_height(mas);
        if (mt_is_alloc(mas->tree))
-               src_info.type = maple_arange_64;
+               src.type = maple_arange_64;
        else
-               src_info.type = maple_range_64;
-       src_info.end = 0; /* Empty node */
+               src.type = maple_range_64;
+       src.end = 0; /* Empty node */
 
        /*
         * src can only really provide the parent
         * set the skip to high enough to avoid using any data
         */
 converged:
-       mas_wr_converged(&src_info, &parent, &ma_part, mas);
+       mas_wr_converged(&src, &parent, &ma_part, mas);
        mas->node = parent.enode;
 rebalanced:
-       mas_wmb_replace(mas, src_info.enode);
+       mas_wmb_replace(mas, src.enode);
        mtree_range_walk(mas);
 }
 
index 213f028a1eabc6e8a98149ce340a5d4d1232b382..10212d27ea57305cbcb4acc01a7e522677684af8 100644 (file)
@@ -35300,9 +35300,9 @@ static noinline void __init check_rcu_threaded(struct maple_tree *mt)
        vals.mt = mt;
        vals.index = 4390;
        vals.last = 4398;
-       vals.entry1 = xa_mk_value(4390);
-       vals.entry2 = xa_mk_value(439);
-       vals.entry3 = xa_mk_value(439);
+       vals.entry1 = xa_mk_value(439);
+       vals.entry2 = xa_mk_value(4390);
+       vals.entry3 = xa_mk_value(4390);
        vals.seen_entry2 = 0;
        vals.range_start = 4316;
        vals.range_end = 5035;
@@ -35337,8 +35337,8 @@ static noinline void __init check_rcu_threaded(struct maple_tree *mt)
        vals.mt = mt;
        vals.index = 4390;
        vals.last = 4398;
-       vals.entry1 = xa_mk_value(4390);
-       vals.entry2 = xa_mk_value(439);
+       vals.entry1 = xa_mk_value(439);
+       vals.entry2 = xa_mk_value(4390);
        vals.entry3 = xa_mk_value(4391);
        vals.seen_toggle = 0;
        vals.seen_added = 0;