]> www.infradead.org Git - users/willy/xarray.git/commitdiff
radix tree test suite: Convert regression4 to XArray
authorMatthew Wilcox <willy@infradead.org>
Fri, 14 Dec 2018 19:36:47 +0000 (14:36 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 9 Aug 2019 01:38:13 +0000 (21:38 -0400)
Signed-off-by: Matthew Wilcox <willy@infradead.org>
tools/testing/radix-tree/regression4.c

index cf4e5aba6b082a1766de7612cbfa68bb7b9d3b6d..7d05909fd28faec699d52e69c65e7fa7daee8e60 100644 (file)
@@ -13,7 +13,7 @@
 
 static pthread_barrier_t worker_barrier;
 static int obj0, obj1;
-static RADIX_TREE(mt_tree, GFP_KERNEL);
+static DEFINE_XARRAY(xa);
 
 static void *reader_fn(void *arg)
 {
@@ -25,7 +25,7 @@ static void *reader_fn(void *arg)
 
        for (i = 0; i < 1000000; i++) {
                rcu_read_lock();
-               entry = radix_tree_lookup(&mt_tree, 0);
+               entry = xa_load(&xa, 0);
                rcu_read_unlock();
                if (entry != &obj0) {
                        printf("iteration %d bad entry = %p\n", i, entry);
@@ -46,8 +46,8 @@ static void *writer_fn(void *arg)
        pthread_barrier_wait(&worker_barrier);
 
        for (i = 0; i < 1000000; i++) {
-               radix_tree_insert(&mt_tree, 1, &obj1);
-               radix_tree_delete(&mt_tree, 1);
+               xa_store(&xa, 1, &obj1, GFP_KERNEL);
+               xa_erase(&xa, 1);
        }
 
        rcu_unregister_thread();
@@ -61,7 +61,7 @@ void regression4_test(void)
 
        printv(1, "regression test 4 starting\n");
 
-       radix_tree_insert(&mt_tree, 0, &obj0);
+       xa_store(&xa, 0, &obj0, GFP_KERNEL);
        pthread_barrier_init(&worker_barrier, NULL, 2);
 
        if (pthread_create(&reader, NULL, reader_fn, NULL) ||