]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
test_maple_tree: Add check_forking()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 22 Oct 2020 19:38:31 +0000 (15:38 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:13:26 +0000 (15:13 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/test_maple_tree.c

index b4d6d6ba28affa18fa8a23c0272bf68a4a8d6ae1..7b169fbcc35eac120fe9b262203eb4f012ae4fbf 100644 (file)
@@ -35160,7 +35160,8 @@ static void check_dfs_preorder(struct maple_tree *mt)
 
 
 }
-static noinline void check_node_store(struct maple_tree *mt)
+
+static noinline void bench_node_store(struct maple_tree *mt)
 {
        int i, overwrite = 76, max = 240, count = 20000000;
 
@@ -35176,7 +35177,51 @@ static noinline void check_node_store(struct maple_tree *mt)
                        overwrite = 76;
        }
 }
+
 static noinline void check_forking(struct maple_tree *mt)
+{
+
+       struct maple_tree newmt;
+       int i, max = 3000;
+       void *val;
+       MA_STATE(mas, mt, 0, 0);
+       MA_STATE(newmas, mt, 0, 0);
+
+       for (i = 0; i < max; i+=10)
+               mtree_store_range(mt, i, i + 5, xa_mk_value(i), GFP_KERNEL);
+
+       mt_set_non_kernel(99999);
+       mtree_init(&newmt, MAPLE_ALLOC_RANGE);
+       newmas.tree = &newmt;
+       mas_reset(&newmas);
+       mas_reset(&mas);
+       mas.index = 0;
+       mas.last = 0;
+       if (mas_entry_count(&newmas, max/10)) {
+               printk("OOM!");
+               BUG_ON(1);
+       }
+
+       mas_for_each(&mas, val, ULONG_MAX) {
+               newmas.index = mas.index;
+               newmas.last = mas.last;
+               mas_store(&newmas, val);
+       }
+       mas_empty_alloc(&newmas);
+       mt_validate(&newmt);
+       mas_reset(&mas);
+       mas_reset(&newmas);
+       mas_for_each(&mas, val, ULONG_MAX) {
+               void *val2 = mas_find(&newmas, mas.last);
+               MT_BUG_ON(&newmt, mas.index != newmas.index);
+               MT_BUG_ON(&newmt, mas.last != newmas.last);
+               MT_BUG_ON(&newmt, val != val2);
+       }
+       mt_set_non_kernel(0);
+       mtree_destroy(&newmt);
+}
+
+static noinline void bench_forking(struct maple_tree *mt)
 {
 
        struct maple_tree newmt;
@@ -35224,13 +35269,13 @@ static int maple_tree_seed(void)
        pr_info("\nTEST STARTING\n\n");
 #if 0
        mtree_init(&tree, MAPLE_ALLOC_RANGE);
-       check_node_store(&tree);
+       bench_node_store(&tree);
        mtree_destroy(&tree);
        goto skip;
 #endif
 #if 0
        mtree_init(&tree, MAPLE_ALLOC_RANGE);
-       check_forking(&tree);
+       bench_forking(&tree);
        mtree_destroy(&tree);
        goto skip;
 #endif
@@ -35243,6 +35288,10 @@ static int maple_tree_seed(void)
        check_dfs_preorder(&tree);
        mtree_destroy(&tree);
 
+       mtree_init(&tree, MAPLE_ALLOC_RANGE);
+       check_forking(&tree);
+       mtree_destroy(&tree);
+
        /* Test ranges (store and insert) */
        mtree_init(&tree, 0);
        check_ranges(&tree);