]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: optimize root expand
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 28 Sep 2020 20:27:00 +0000 (16:27 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:30:31 +0000 (12:30 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index c6dd92c9c6c40918b6058fa8ab67ec6111aac515..bc83da3ba676142262c61ad575561d70f3cc665a 100644 (file)
@@ -2698,6 +2698,9 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry)
 {
        void *contents = mas_root_locked(mas);
        enum maple_type type = maple_leaf_64;
+       struct maple_node *node;
+       void **slots;
+       unsigned long *pivots;
        int slot = 0;
 
 
@@ -2705,20 +2708,23 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry)
        if (mas_is_err(mas))
                return 0;
 
-       mas->node = mt_mk_node(mas_next_alloc(mas), type);
+       node = mas_next_alloc(mas);
+       pivots = ma_pivots(node, type);
+       slots = ma_slots(node, type);
+       mas->node = mt_mk_node(node, type);
        mas_mn(mas)->parent = ma_parent_ptr(
                      ((unsigned long)mas->tree | MA_ROOT_PARENT));
 
        if (contents)
-               mte_set_slot(mas->node, slot++, contents);
+               slots[slot++] = contents;
 
        if (!mas->index && slot)
                slot--;
        else if (mas->index > 1)
-               mte_set_pivot(mas->node, slot++, mas->index - 1);
+               pivots[slot++] = mas->index - 1;
 
-       mte_set_slot(mas->node, slot, entry);
-       mte_set_pivot(mas->node, slot++, mas->last);
+       slots[slot] = entry;
+       pivots[slot++] = mas->last;
        /* swap the new root into the tree */
        rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node));
        mas->depth = 1;
@@ -4167,8 +4173,8 @@ static inline void *_mas_next(struct ma_state *mas, unsigned long limit,
                return NULL;
 
        if (mas_is_start(mas)) {// First run.
-               *range_start = 0;
                mas_start(mas);
+               *range_start = 0;
                entry = mas_range_load(mas, range_start, &range_max);
                mas->last = range_max;
                if (entry)