]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Remove unnecessary coalescing.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 5 Aug 2019 19:53:28 +0000 (15:53 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 5 Aug 2019 19:53:28 +0000 (15:53 -0400)
Coalescing is only needed between nodes now.  Skip any identical entries when copying the node data in ma_add

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

index 4cd6c3ce1022426fee53b7bece4c8357a0720253..fc1aba97fd479b13566971638ebddfcf165b2c7a 100644 (file)
@@ -2001,7 +2001,11 @@ static inline int _ma_add(struct ma_state *mas, void *entry, bool overwrite,
 
        /* Skip possible duplicate entry that contains a NULL */
        if (!append) {
-               if (ma_get_pivot(prev_enode, old_end) <= mas->last)
+               if (mas->last >= last_piv)
+                       goto complete;
+
+               while (ma_get_pivot(prev_enode, old_end) <= mas->last &&
+                               old_end < slot_cnt)
                        old_end++;
 
                /* Copy remainder of node if this isn't an append */
@@ -3098,16 +3102,8 @@ static inline int ma_add(struct ma_state *mas, void *entry, bool overwrite,
        if (ret)
                return ret;
 
-retry:
        leaf = _mas_walk(mas);
        slot = ma_get_slot(mas);
-       // Clean this node
-       if (mas_coalesce(mas)) {
-               if (mas_is_err(mas))
-                       return 0;
-               goto retry;
-       }
-
        if (leaf == true && slot != MAPLE_NODE_SLOTS) {
                if (!overwrite) {
                        void *entry = ma_get_rcu_slot(mas->node, slot);
@@ -3181,13 +3177,6 @@ static inline int ma_alloc(struct ma_state *mas, void *entry,
 
        // At this point, mas->node points to the right node and we have a
        // slot that has a sufficient gap.
-#if 0
-       //FIXME: coalesce is an odd beast
-       mas_coalesce(mas);
-       if (mas_is_err(mas))
-               return xa_err(mas->node);
-#endif
-
        min = mas->min;
        if (slot)
                min = ma_get_pivot(mas->node, slot - 1) + 1;
@@ -3232,12 +3221,6 @@ static inline int ma_rev_alloc(struct ma_state *mas, void *entry,
 
        // At this point, mas->node points to the right node and we have a
        // slot that has a sufficient gap.
-#if 0
-       //FIXME: coalesce is an odd beast
-       mas_coalesce(mas);
-       if (mas_is_err(mas))
-               return xa_err(mas->node);
-#endif
        // If the maximum is outside the window we are searching, then use the
        // last location in the search.
        if (mas->max > mas->last)
index eaf00485cee7e5b4b3d7243cb01b9272b0e94591..48e39e148680b947ce8cd18e3fee1ea215fc6158 100644 (file)
@@ -489,6 +489,7 @@ static noinline void check_erase_testset(struct maple_tree *mt)
 
        check_insert(mt, set[1], mt);
        // Check erase and load without an allocation.
+
        check_erase(mt, set[1]);
        check_load(mt, set[0], ptr);
        check_load(mt, set[1], NULL);
@@ -536,7 +537,6 @@ static noinline void check_erase_testset(struct maple_tree *mt)
        check_erase(mt, set[2]); // erase 5017 to check append
        check_erase(mt, set[0]); // erase 5015 to check append
        check_insert(mt, set[4], ptr); // 1000 < Should NOT split
-
        check_load(mt, set[0], NULL);
        check_load(mt, 5016, NULL);
        check_load(mt, set[1], mt);