]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
test_maple_tree: port nomem thread race test.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 28 Jan 2019 19:08:29 +0000 (14:08 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 18:55:26 +0000 (14:55 -0400)
Test to see that allocations work when two threads are racing.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/test_maple_tree.c

index 22d912ddce5dfa19d0890a21b0c131cb302332a1..b77d8d78ec935782d8bdb16ee16893ee589aa6f9 100644 (file)
@@ -106,15 +106,14 @@ void check_index_load(struct maple_tree *mt, unsigned long index)
 
 static noinline void check_nomem(struct maple_tree *mt)
 {
-#if 0
        MA_STATE(ms, mt, 1, 1);
 
        MT_BUG_ON(mt, !mtree_empty(mt));
 
        /* Storing something at 1 requires memory allocation */
-       MT_BUG_ON(mt, mtree_insert_index(mt, 1, GFP_ATOMIC) != -ENOMEM);
+       MT_BUG_ON(mt, mtree_insert(mt, 1, &ms, GFP_ATOMIC) != -ENOMEM);
        /* Storing something at 0 does not */
-       MT_BUG_ON(mt, mtree_insert_index(mt, 0, GFP_ATOMIC) != 0);
+       MT_BUG_ON(mt, mtree_insert(mt, 0, &ms, GFP_ATOMIC) != 0);
 
        /*
         * Simulate two threads racing; the first one fails to allocate
@@ -125,20 +124,16 @@ static noinline void check_nomem(struct maple_tree *mt)
         * userspace test suite.
         */
        mtree_lock(mt);
-       _maple_setup_insert(&ms);
+       ma_insert(&ms, &ms); // insert 1 -> &ms, fails.
        MT_BUG_ON(mt, ms.node != MA_ERROR(-ENOMEM));
-       _maple_insert(&ms, xa_mk_value(1));
-       mas_nomem(&ms, GFP_KERNEL);
+       mas_nomem(&ms, GFP_KERNEL); // Node allocated in here.
        MT_BUG_ON(mt, ms.node != MAS_START);
        mtree_unlock(mt);
-       MT_BUG_ON(mt, mtree_insert_index(mt, 2, GFP_KERNEL) != 0);
+       MT_BUG_ON(mt, mtree_insert(mt, 2, mt, GFP_KERNEL) != 0);
        mtree_lock(mt);
-       _maple_setup_insert(&ms);
-       _maple_insert(&ms, xa_mk_value(1));
-       mas_nomem(&ms, GFP_KERNEL);
+       ma_insert(&ms, &ms); // insert 1 -> &ms
+       mas_nomem(&ms, GFP_KERNEL); // Node allocated in here.
        mtree_unlock(mt);
-#endif
-
        mtree_destroy(mt);
 }