From: Liam R. Howlett Date: Mon, 5 Aug 2019 19:53:28 +0000 (-0400) Subject: maple_tree: Remove unnecessary coalescing. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9a117ae54edba66c047908f6781a3232c306bac8;p=users%2Fjedix%2Flinux-maple.git maple_tree: Remove unnecessary coalescing. 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 --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4cd6c3ce1022..fc1aba97fd47 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index eaf00485cee7..48e39e148680 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -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);