]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
xarray: Move multiorder account test in-kernel
authorMatthew Wilcox <willy@infradead.org>
Tue, 28 Aug 2018 20:13:16 +0000 (16:13 -0400)
committerMatthew Wilcox <willy@infradead.org>
Sun, 21 Oct 2018 14:46:46 +0000 (10:46 -0400)
Move this test to the in-kernel test suite, and enhance it to test
several different orders.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
lib/test_xarray.c
tools/testing/radix-tree/multiorder.c

index ca86141641cb0b08ec953d77789d44e80a751e76..38cab4ccb24e88bc03e17ed50375922545a446ee 100644 (file)
@@ -1019,6 +1019,37 @@ static noinline void check_workingset(struct xarray *xa, unsigned long index)
        XA_BUG_ON(xa, !xa_empty(xa));
 }
 
+/*
+ * Check that the pointer / value / sibling entries are accounted the
+ * way we expect them to be.
+ */
+static noinline void check_account(struct xarray *xa)
+{
+#ifdef CONFIG_XARRAY_MULTI
+       unsigned int order;
+
+       for (order = 1; order < 12; order++) {
+               XA_STATE(xas, xa, 1 << order);
+
+               xa_store_order(xa, 0, order, xa, GFP_KERNEL);
+               xas_load(&xas);
+               XA_BUG_ON(xa, xas.xa_node->count == 0);
+               XA_BUG_ON(xa, xas.xa_node->count > (1 << order));
+               XA_BUG_ON(xa, xas.xa_node->nr_values != 0);
+
+               xa_store_order(xa, 1 << order, order, xa_mk_value(1 << order),
+                               GFP_KERNEL);
+               XA_BUG_ON(xa, xas.xa_node->count != xas.xa_node->nr_values * 2);
+
+               xa_erase(xa, 1 << order);
+               XA_BUG_ON(xa, xas.xa_node->nr_values != 0);
+
+               xa_erase(xa, 0);
+               XA_BUG_ON(xa, !xa_empty(xa));
+       }
+#endif
+}
+
 static noinline void check_destroy(struct xarray *xa)
 {
        unsigned long index;
@@ -1068,6 +1099,7 @@ static int xarray_checks(void)
        check_xa_alloc();
        check_find(&array);
        check_find_entry(&array);
+       check_account(&array);
        check_destroy(&array);
        check_move(&array);
        check_create_range(&array);
index 0436554a099a6cc052ea7eabff18153bbaed88fd..dc27a3da210ae07b1856509709e162e490b83973 100644 (file)
@@ -356,29 +356,6 @@ void multiorder_tagged_iteration(void)
        item_kill_tree(&tree);
 }
 
-static void multiorder_account(void)
-{
-       RADIX_TREE(tree, GFP_KERNEL);
-       struct radix_tree_node *node;
-       void **slot;
-
-       item_insert_order(&tree, 0, 5);
-
-       __radix_tree_insert(&tree, 1 << 5, 5, xa_mk_value(5));
-       __radix_tree_lookup(&tree, 0, &node, NULL);
-       assert(node->count == node->nr_values * 2);
-       radix_tree_delete(&tree, 1 << 5);
-       assert(node->nr_values == 0);
-
-       __radix_tree_insert(&tree, 1 << 5, 5, xa_mk_value(5));
-       __radix_tree_lookup(&tree, 1 << 5, &node, &slot);
-       assert(node->count == node->nr_values * 2);
-       __radix_tree_replace(&tree, node, slot, NULL);
-       assert(node->nr_values == 0);
-
-       item_kill_tree(&tree);
-}
-
 bool stop_iteration = false;
 
 static void *creator_func(void *ptr)
@@ -457,7 +434,6 @@ void multiorder_checks(void)
        multiorder_tag_tests();
        multiorder_iteration();
        multiorder_tagged_iteration();
-       multiorder_account();
        multiorder_iteration_race();
 
        radix_tree_cpu_dead(0);