From 59440ca16bd5df6cfcf9f3ae23ac2d8419c38d35 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Fri, 6 Mar 2020 13:59:43 -0500 Subject: [PATCH] test_maple_tree: Don't count retry entries during entry counting. retries are skipped, so don't count them so the test framework will come up with the correct count. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 8 ++++++-- lib/test_maple_tree.c | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index f2d422c5212b..75cac4a7fe7d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2205,6 +2205,7 @@ static inline enum maple_type mas_determine_type(struct ma_state *mas, * Ensure we cover the scenario where there is an empty node due to allocation * failures - Move the gap wherever it can go and free this node. */ +static inline void mas_rebalance(struct ma_state *mas); static inline void mas_may_move_gap(struct ma_state *mas) { @@ -2213,6 +2214,7 @@ static inline void mas_may_move_gap(struct ma_state *mas) unsigned char end; unsigned char new_end; unsigned char slot = mas_get_slot(mas); + struct maple_enode *mn = NULL; void *entry = NULL; void *next_entry = NULL; bool empty = false; @@ -2332,6 +2334,7 @@ curr_is_empty: mas_ascend(&parent); mte_set_rcu_slot(parent.node, slot, next.node); mas_set_safe_pivot(&parent, slot, next.max); + mn = parent.node; next.min = curr.min; curr.max = curr.min; mas_shift_pivot(&curr, &next, next.max); @@ -2340,13 +2343,14 @@ curr_is_empty: mas_update_gap(&next, false); } - slot = mte_parent_slot(next.node); mas_dup_state(&parent, &next); mas_ascend(&parent); - mte_set_rcu_slot(parent.node, slot, XA_RETRY_ENTRY); + mte_set_rcu_slot(parent.node, slot, XA_SKIP_ENTRY); // relocated. + mte_set_parent(next.node, mn, mte_parent_slot(curr.node)); mte_free(curr.node); + mas_rebalance(&parent); mas_dup_state(mas, &next); } diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index e00bcc9db8bf..d283dffaaca6 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -943,9 +943,11 @@ static noinline void check_erase2_testset(struct maple_tree *mt, set[i+2]); while (!mas_is_none(&mas_start) && (mas_start.last != e_max) ) { - if (s_entry) { + if (mas_retry(&mas, s_entry)) + continue; + if (s_entry) cnt++; - } + s_entry = mas_next(&mas_start, set[i+2]); } @@ -11305,7 +11307,6 @@ static noinline void check_next_entry(struct maple_tree *mt) MT_BUG_ON(mt, entry != NULL); else MT_BUG_ON(mt, xa_mk_value(i) != entry); - mas.index = mas.max = i; } rcu_read_unlock(); mtree_destroy(mt); @@ -11352,7 +11353,7 @@ static noinline void check_gap_combining(struct maple_tree *mt) entry = mas_next(&mas, ULONG_MAX); MT_BUG_ON(mt, entry != xa_mk_value(index + 3)); mn2 = mas.node; - MT_BUG_ON(mt, mn1 == mn2); + MT_BUG_ON(mt, mn1 == mn2); // test the test. // At this point, there is a gap of 2 in either 1 or 2 nodes. Find a // gap of size 2 from 100 down to 50. @@ -11510,6 +11511,7 @@ static int maple_tree_seed(void) /* Clear out the tree */ mtree_destroy(&tree); + mtree_init(&tree, 0); check_erase_testset(&tree); mtree_destroy(&tree); -- 2.50.1