summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2018-08-28 16:13:16 -0400
committerMatthew Wilcox <willy@infradead.org>2018-10-21 10:46:46 -0400
commitd6427f8179b5dd65eb468c61fc8cc24657c336c9 (patch)
treebe783289bf2c41109ad5386fc62cc7973a0e770e /lib
parent47e0fab2b15155e33fdff777c791bebfd5855bbc (diff)
downloadlinux-stable-d6427f8179b5dd65eb468c61fc8cc24657c336c9.tar.gz
linux-stable-d6427f8179b5dd65eb468c61fc8cc24657c336c9.tar.bz2
linux-stable-d6427f8179b5dd65eb468c61fc8cc24657c336c9.zip
xarray: Move multiorder account test in-kernel
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/test_xarray.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/test_xarray.c b/lib/test_xarray.c
index ca86141641cb..38cab4ccb24e 100644
--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -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);