From 1c191f9eac546a4520055b0f677c7a3cfc62b8c4 Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Tue, 15 Oct 2019 20:50:29 -0400 Subject: [PATCH] maple tree tests: Erase entries individually This should result in the tree being empty. Right now, it doesn't -- the nodes full of deleted entries are not themselves deleted. Also fix the lack of locking around the mas iteration. --- lib/test_maple_tree.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index b9593a94ec08..594d012c8376 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -36,6 +36,12 @@ int mtree_insert_index(struct maple_tree *mt, unsigned long index, gfp_t gfp) return mtree_insert(mt, index, xa_mk_value(index & LONG_MAX), gfp); } +static void mtree_erase_index(struct maple_tree *mt, unsigned long index) +{ + MT_BUG_ON(mt, mtree_erase(mt, index) != xa_mk_value(index & LONG_MAX)); + MT_BUG_ON(mt, mtree_load(mt, index) != NULL); +} + static int mtree_test_insert(struct maple_tree *mt, unsigned long index, void *ptr) { @@ -469,21 +475,29 @@ static noinline void check_find_2(struct maple_tree *mt) void *entry; MA_STATE(mas, mt, 0, 0); + rcu_read_lock(); mas_for_each(&mas, entry, ULONG_MAX) MT_BUG_ON(mt, true); + rcu_read_unlock(); for (i = 0; i < 256; i++) { mtree_insert_index(mt, i, GFP_KERNEL); j = 0; mas_set(&mas, 0); + rcu_read_lock(); mas_for_each(&mas, entry, ULONG_MAX) { MT_BUG_ON(mt, entry != xa_mk_value(j)); j++; } + rcu_read_unlock(); MT_BUG_ON(mt, j != i + 1); } - mtree_destroy(mt); + for (i = 0; i < 256; i++) { + mtree_erase_index(mt, i); + } + + MT_BUG_ON(mt, !mtree_empty(mt)); } #define erase_ptr(i) entry[i%2] -- 2.50.1