io_uring/net: un-indent mshot retry path in io_recv_finish()
[platform/kernel/linux-rpi.git] / lib / test_maple_tree.c
index 0695916..464eeb9 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/maple_tree.h>
 #include <linux/module.h>
+#include <linux/rwsem.h>
 
 #define MTREE_ALLOC_MAX 0x2000000000000Ul
 #define CONFIG_MAPLE_SEARCH
@@ -1841,17 +1842,21 @@ static noinline void __init check_forking(struct maple_tree *mt)
        void *val;
        MA_STATE(mas, mt, 0, 0);
        MA_STATE(newmas, mt, 0, 0);
+       struct rw_semaphore newmt_lock;
+
+       init_rwsem(&newmt_lock);
 
        for (i = 0; i <= nr_entries; i++)
                mtree_store_range(mt, i*10, i*10 + 5,
                                  xa_mk_value(i), GFP_KERNEL);
 
        mt_set_non_kernel(99999);
-       mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE);
+       mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE | MT_FLAGS_LOCK_EXTERN);
+       mt_set_external_lock(&newmt, &newmt_lock);
        newmas.tree = &newmt;
        mas_reset(&newmas);
        mas_reset(&mas);
-       mas_lock(&newmas);
+       down_write(&newmt_lock);
        mas.index = 0;
        mas.last = 0;
        if (mas_expected_entries(&newmas, nr_entries)) {
@@ -1866,10 +1871,10 @@ static noinline void __init check_forking(struct maple_tree *mt)
        }
        rcu_read_unlock();
        mas_destroy(&newmas);
-       mas_unlock(&newmas);
        mt_validate(&newmt);
        mt_set_non_kernel(0);
-       mtree_destroy(&newmt);
+       __mt_destroy(&newmt);
+       up_write(&newmt_lock);
 }
 
 static noinline void __init check_iteration(struct maple_tree *mt)
@@ -1980,6 +1985,10 @@ static noinline void __init bench_forking(struct maple_tree *mt)
        void *val;
        MA_STATE(mas, mt, 0, 0);
        MA_STATE(newmas, mt, 0, 0);
+       struct rw_semaphore newmt_lock;
+
+       init_rwsem(&newmt_lock);
+       mt_set_external_lock(&newmt, &newmt_lock);
 
        for (i = 0; i <= nr_entries; i++)
                mtree_store_range(mt, i*10, i*10 + 5,
@@ -1994,7 +2003,7 @@ static noinline void __init bench_forking(struct maple_tree *mt)
                mas.index = 0;
                mas.last = 0;
                rcu_read_lock();
-               mas_lock(&newmas);
+               down_write(&newmt_lock);
                if (mas_expected_entries(&newmas, nr_entries)) {
                        printk("OOM!");
                        BUG_ON(1);
@@ -2005,11 +2014,11 @@ static noinline void __init bench_forking(struct maple_tree *mt)
                        mas_store(&newmas, val);
                }
                mas_destroy(&newmas);
-               mas_unlock(&newmas);
                rcu_read_unlock();
                mt_validate(&newmt);
                mt_set_non_kernel(0);
-               mtree_destroy(&newmt);
+               __mt_destroy(&newmt);
+               up_write(&newmt_lock);
        }
 }
 #endif
@@ -2616,6 +2625,10 @@ static noinline void __init check_dup_gaps(struct maple_tree *mt,
        void *tmp;
        MA_STATE(mas, mt, 0, 0);
        MA_STATE(newmas, &newmt, 0, 0);
+       struct rw_semaphore newmt_lock;
+
+       init_rwsem(&newmt_lock);
+       mt_set_external_lock(&newmt, &newmt_lock);
 
        if (!zero_start)
                i = 1;
@@ -2625,9 +2638,9 @@ static noinline void __init check_dup_gaps(struct maple_tree *mt,
                mtree_store_range(mt, i*10, (i+1)*10 - gap,
                                  xa_mk_value(i), GFP_KERNEL);
 
-       mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE);
+       mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE | MT_FLAGS_LOCK_EXTERN);
        mt_set_non_kernel(99999);
-       mas_lock(&newmas);
+       down_write(&newmt_lock);
        ret = mas_expected_entries(&newmas, nr_entries);
        mt_set_non_kernel(0);
        MT_BUG_ON(mt, ret != 0);
@@ -2640,9 +2653,9 @@ static noinline void __init check_dup_gaps(struct maple_tree *mt,
        }
        rcu_read_unlock();
        mas_destroy(&newmas);
-       mas_unlock(&newmas);
 
-       mtree_destroy(&newmt);
+       __mt_destroy(&newmt);
+       up_write(&newmt_lock);
 }
 
 /* Duplicate many sizes of trees.  Mainly to test expected entry values */