[PATCH] maple_tree: fix alloc node fail issue
Liam R. Howlett
Liam.Howlett at oracle.com
Mon Jun 24 08:38:34 PDT 2024
* Jiazi Li <jqqlijiazi at gmail.com> [240624 08:01]:
> In the following code, the second call to the mas_node_count will
> return -ENOMEM:
>
> mas_node_count(&maple_tree, 31);
> mas_node_count(&maple_tree, 62);
This implies mas_node_count() takes a maple tree, but it takes a maple
state.
>
> This is because get a node with node_count is MAPLE_ALLOC_SLOTS in
> while loop of mas_alloc_nodes. And this will result in max_req
> is zero in next loop.
This description could use some work on clarity.
Please provide a testcase that reproduces the issue that will go into
tools/testing/radix-tree/maple.c It looks like it should go around line
460.
> Signed-off-by: Jiazi Li <jiazi.li at transsion.com>
Your Signed-off-by does not match the from address.
Please add a Fixes tag.
> ---
> lib/maple_tree.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index aa3a5df15b8e..82c236972115 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -1272,7 +1272,9 @@ static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp)
>
> node->node_count += count;
> allocated += count;
> - node = node->slot[0];
> + do {
> + node = node->slot[0];
> + } while (unlikely(node->node_count == MAPLE_ALLOC_SLOTS));
Please change this to an 'if' statement as it would be more clear what's
going on.
> requested -= count;
> }
> mas->alloc->total = allocated;
> --
> 2.17.1
>
More information about the maple-tree
mailing list