Re: [PATCH 3/3] tools/testing/radix-tree: Test maple tree chaining mas_preallocate() calls
From: Lorenzo Stoakes
Date: Fri Jun 20 2025 - 11:53:53 EST
On Mon, Jun 16, 2025 at 02:45:21PM -0400, Liam R. Howlett wrote:
> Testing calling multiple mas_preallocate() calls in a row after
> adjusting the maple state. Ensures new calls to mas_preallocate() will
> change the number of allocated nodes.
Really helpful to have a regression test for such a fiddly thing!
>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
Acked-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
> ---
> tools/testing/radix-tree/maple.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c
> index 6a5b0342941c4..49e89dfad950c 100644
> --- a/tools/testing/radix-tree/maple.c
> +++ b/tools/testing/radix-tree/maple.c
> @@ -35693,6 +35693,18 @@ static noinline void __init check_prealloc(struct maple_tree *mt)
> allocated = mas_allocated(&mas);
> height = mas_mt_height(&mas);
> MT_BUG_ON(mt, allocated != 0);
> +
> + /* Chaining multiple preallocations */
> + mt_set_in_rcu(mt);
> + mas_set_range(&mas, 800, 805); /* Slot store, should be 0 allocations */
> + MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
> + allocated = mas_allocated(&mas);
> + MT_BUG_ON(mt, allocated != 0);
> + mas.last = 809; /* Node store */
> + MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL) != 0);
> + allocated = mas_allocated(&mas);
> + MT_BUG_ON(mt, allocated != 1);
> + mas_store_prealloc(&mas, ptr);
> }
> /* End of preallocation testing */
>
> --
> 2.47.2
>