summaryrefslogtreecommitdiffstats
path: root/tools/testing/radix-tree
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2018-09-12 23:29:32 -0400
committerMatthew Wilcox <willy@infradead.org>2018-10-21 10:46:47 -0400
commit4bb53bdda0d1e061035774ed4868bdeb4d889044 (patch)
tree105026e609420e18c861295044b0f5f6ffdafe08 /tools/testing/radix-tree
parent879a9ae7b5bc046f195a725d62bbc96258e5d0c8 (diff)
downloadlinux-4bb53bdda0d1e061035774ed4868bdeb4d889044.tar.bz2
radix tree tests: Move item_insert_order
The remaining tests are not suitable for moving in-kernel, so move item_insert_order() into multiorder.c, make it static and make it use the XArray. Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'tools/testing/radix-tree')
-rw-r--r--tools/testing/radix-tree/multiorder.c19
-rw-r--r--tools/testing/radix-tree/test.c12
-rw-r--r--tools/testing/radix-tree/test.h2
3 files changed, 22 insertions, 11 deletions
diff --git a/tools/testing/radix-tree/multiorder.c b/tools/testing/radix-tree/multiorder.c
index 6e8d66c2aa89..8c41dca272b1 100644
--- a/tools/testing/radix-tree/multiorder.c
+++ b/tools/testing/radix-tree/multiorder.c
@@ -20,6 +20,25 @@
#include "test.h"
+static int item_insert_order(struct xarray *xa, unsigned long index,
+ unsigned order)
+{
+ XA_STATE_ORDER(xas, xa, index, order);
+ struct item *item = item_create(index, order);
+
+ do {
+ xas_lock(&xas);
+ xas_store(&xas, item);
+ xas_unlock(&xas);
+ } while (xas_nomem(&xas, GFP_KERNEL));
+
+ if (!xas_error(&xas))
+ return 0;
+
+ free(item);
+ return xas_error(&xas);
+}
+
void multiorder_iteration(void)
{
RADIX_TREE(tree, GFP_KERNEL);
diff --git a/tools/testing/radix-tree/test.c b/tools/testing/radix-tree/test.c
index 5991cfd34f2b..5376b8c5d8d6 100644
--- a/tools/testing/radix-tree/test.c
+++ b/tools/testing/radix-tree/test.c
@@ -34,21 +34,15 @@ struct item *item_create(unsigned long index, unsigned int order)
return ret;
}
-int item_insert_order(struct radix_tree_root *root, unsigned long index,
- unsigned order)
+int item_insert(struct radix_tree_root *root, unsigned long index)
{
- struct item *item = item_create(index, order);
- int err = __radix_tree_insert(root, item->index, item->order, item);
+ struct item *item = item_create(index, 0);
+ int err = radix_tree_insert(root, item->index, item);
if (err)
free(item);
return err;
}
-int item_insert(struct radix_tree_root *root, unsigned long index)
-{
- return item_insert_order(root, index, 0);
-}
-
void item_sanity(struct item *item, unsigned long index)
{
unsigned long mask;
diff --git a/tools/testing/radix-tree/test.h b/tools/testing/radix-tree/test.h
index 28961a08828e..e259c0839d5d 100644
--- a/tools/testing/radix-tree/test.h
+++ b/tools/testing/radix-tree/test.h
@@ -14,8 +14,6 @@ struct item *item_create(unsigned long index, unsigned int order);
int item_insert(struct radix_tree_root *root, unsigned long index);
void item_sanity(struct item *item, unsigned long index);
void item_free(struct item *item, unsigned long index);
-int item_insert_order(struct radix_tree_root *root, unsigned long index,
- unsigned order);
int item_delete(struct radix_tree_root *root, unsigned long index);
int item_delete_rcu(struct radix_tree_root *root, unsigned long index);
struct item *item_lookup(struct radix_tree_root *root, unsigned long index);