maple_tree: update mas_preallocate() testing
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 24 Jul 2023 18:31:54 +0000 (14:31 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 18 Aug 2023 17:12:49 +0000 (10:12 -0700)
Since the mas_preallocate() calculation has been updated to be more
precise, the testing must also be updated to check for what is expected.

Link: https://lkml.kernel.org/r/20230724183157.3939892-13-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Peng Zhang <zhangpeng.00@bytedance.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/radix-tree/maple.c

index c6c1c51..e5da1ca 100644 (file)
@@ -35458,6 +35458,8 @@ static noinline void __init check_prealloc(struct maple_tree *mt)
        for (i = 0; i <= max; i++)
                mtree_test_store_range(mt, i * 10, i * 10 + 5, &i);
 
+       /* Spanning store */
+       mas_set_range(&mas, 470, 500);
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
        allocated = mas_allocated(&mas);
        height = mas_mt_height(&mas);
@@ -35481,7 +35483,6 @@ static noinline void __init check_prealloc(struct maple_tree *mt)
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
        allocated = mas_allocated(&mas);
        height = mas_mt_height(&mas);
-       MT_BUG_ON(mt, allocated == 0);
        MT_BUG_ON(mt, allocated != 1 + height * 3);
        mn = mas_pop_node(&mas);
        MT_BUG_ON(mt, mas_allocated(&mas) != allocated - 1);
@@ -35495,7 +35496,6 @@ static noinline void __init check_prealloc(struct maple_tree *mt)
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
        allocated = mas_allocated(&mas);
        height = mas_mt_height(&mas);
-       MT_BUG_ON(mt, allocated == 0);
        MT_BUG_ON(mt, allocated != 1 + height * 3);
        mn = mas_pop_node(&mas);
        MT_BUG_ON(mt, mas_allocated(&mas) != allocated - 1);
@@ -35509,7 +35509,6 @@ static noinline void __init check_prealloc(struct maple_tree *mt)
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
        allocated = mas_allocated(&mas);
        height = mas_mt_height(&mas);
-       MT_BUG_ON(mt, allocated == 0);
        MT_BUG_ON(mt, allocated != 1 + height * 3);
        mn = mas_pop_node(&mas);
        MT_BUG_ON(mt, mas_allocated(&mas) != allocated - 1);
@@ -35523,33 +35522,37 @@ static noinline void __init check_prealloc(struct maple_tree *mt)
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
        allocated = mas_allocated(&mas);
        height = mas_mt_height(&mas);
-       MT_BUG_ON(mt, allocated == 0);
        MT_BUG_ON(mt, allocated != 1 + height * 3);
        mas_store_prealloc(&mas, ptr);
        MT_BUG_ON(mt, mas_allocated(&mas) != 0);
 
+       /* Slot store does not need allocations */
+       mas_set_range(&mas, 6, 9);
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
        allocated = mas_allocated(&mas);
-       height = mas_mt_height(&mas);
-       MT_BUG_ON(mt, allocated == 0);
-       MT_BUG_ON(mt, allocated != 1 + height * 3);
+       MT_BUG_ON(mt, allocated != 0);
        mas_store_prealloc(&mas, ptr);
        MT_BUG_ON(mt, mas_allocated(&mas) != 0);
+
+       mas_set_range(&mas, 6, 10);
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
        allocated = mas_allocated(&mas);
        height = mas_mt_height(&mas);
-       MT_BUG_ON(mt, allocated == 0);
-       MT_BUG_ON(mt, allocated != 1 + height * 3);
+       MT_BUG_ON(mt, allocated != 1);
        mas_store_prealloc(&mas, ptr);
+       MT_BUG_ON(mt, mas_allocated(&mas) != 0);
 
+       /* Split */
+       mas_set_range(&mas, 54, 54);
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
        allocated = mas_allocated(&mas);
        height = mas_mt_height(&mas);
-       MT_BUG_ON(mt, allocated == 0);
-       MT_BUG_ON(mt, allocated != 1 + height * 3);
+       MT_BUG_ON(mt, allocated != 1 + height * 2);
        mas_store_prealloc(&mas, ptr);
        MT_BUG_ON(mt, mas_allocated(&mas) != 0);
        mt_set_non_kernel(1);
+       /* Spanning store */
+       mas_set_range(&mas, 1, 100);
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL & GFP_NOWAIT) == 0);
        allocated = mas_allocated(&mas);
        height = mas_mt_height(&mas);
@@ -35557,6 +35560,7 @@ static noinline void __init check_prealloc(struct maple_tree *mt)
        mas_destroy(&mas);
 
 
+       /* Spanning store */
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
        allocated = mas_allocated(&mas);
        height = mas_mt_height(&mas);
@@ -35564,6 +35568,7 @@ static noinline void __init check_prealloc(struct maple_tree *mt)
        MT_BUG_ON(mt, allocated != 1 + height * 3);
        mas_store_prealloc(&mas, ptr);
        MT_BUG_ON(mt, mas_allocated(&mas) != 0);
+       mas_set_range(&mas, 0, 200);
        mt_set_non_kernel(1);
        MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL & GFP_NOWAIT) == 0);
        allocated = mas_allocated(&mas);