From 718a4b1cdf6cfcbca3eaf683aa01c8a0f09b53c2 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Thu, 22 Oct 2020 15:38:31 -0400 Subject: [PATCH] test_maple_tree: Add check_forking() Signed-off-by: Liam R. Howlett --- lib/test_maple_tree.c | 55 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index b4d6d6ba28af..7b169fbcc35e 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -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); -- 2.50.1