From: Matthew Wilcox (Oracle) Date: Wed, 16 Oct 2019 00:50:29 +0000 (-0400) Subject: maple tree tests: Erase entries individually X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=aa253653f9b64f8b6501d3435fef993ef08c1850;p=users%2Fjedix%2Flinux-maple.git 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. --- diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index b9593a94ec080..594d012c83767 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]