]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
test_maple_tree: Don't count retry entries during entry counting.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 6 Mar 2020 18:59:43 +0000 (13:59 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:28:26 +0000 (12:28 -0500)
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 <Liam.Howlett@Oracle.com>
lib/maple_tree.c
lib/test_maple_tree.c

index f2d422c5212b48fb0156f8007df224c752f38ab7..75cac4a7fe7d5b2a7c05985178e6d0da134c1472 100644 (file)
@@ -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);
 }
 
index e00bcc9db8bf59f81714bdf48de780aa105c41a1..d283dffaaca62d36ff420ede97137822ee43eb4e 100644 (file)
@@ -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);