[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0737acaa-ba88-764c-d8ad-376b28b988e3@huaweicloud.com>
Date: Tue, 17 Dec 2024 19:41:36 +0800
From: yangerkun <yangerkun@...weicloud.com>
To: "Liam R. Howlett" <Liam.Howlett@...cle.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: maple-tree@...ts.infradead.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, chuck.lever@...cle.com, brauner@...nel.org
Subject: Re: [PATCH 2/2] test_maple_tree: Test exhausted upper limit of
mtree_alloc_cyclic()
在 2024/12/17 3:01, Liam R. Howlett 写道:
> From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
>
> When the upper bound of the search is exhausted, the maple state may be
> returned in an error state of -EBUSY. This means maple state needs to
> be reset before the second search in mas_alloc_cylic() to ensure the
> search happens. This test ensures the issue is not recreated.
>
> Cc: Yang Erkun <yangerkun@...weicloud.com>
> Cc: chuck.lever@...cle.com
> Cc: brauner@...nel.org
> Signed-off-by: Liam R. Howlett <Liam.Howlett@...cle.com>
> ---
> lib/test_maple_tree.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
Thanks for the testcase!
Reviewed-by: Yang Erkun <yangerkun@...wei.com>
> diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c
> index 72bda304b5952..13e2a10d7554d 100644
> --- a/lib/test_maple_tree.c
> +++ b/lib/test_maple_tree.c
> @@ -3738,6 +3738,34 @@ static noinline void __init alloc_cyclic_testing(struct maple_tree *mt)
> }
>
> mtree_destroy(mt);
> +
> + /*
> + * Issue with reverse search was discovered
> + * https://lore.kernel.org/all/20241216060600.287B4C4CED0@smtp.kernel.org/
> + * Exhausting the allocation area and forcing the search to wrap needs a
> + * mas_reset() in mas_alloc_cyclic().
> + */
> + next = 0;
> + mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE);
> + for (int i = 0; i < 1023; i++) {
> + mtree_alloc_cyclic(mt, &location, mt, 2, 1024, &next, GFP_KERNEL);
> + MT_BUG_ON(mt, i != location - 2);
> + MT_BUG_ON(mt, i != next - 3);
> + MT_BUG_ON(mt, mtree_load(mt, location) != mt);
> + }
> + mtree_erase(mt, 123);
> + MT_BUG_ON(mt, mtree_load(mt, 123) != NULL);
> + mtree_alloc_cyclic(mt, &location, mt, 2, 1024, &next, GFP_KERNEL);
> + MT_BUG_ON(mt, 123 != location);
> + MT_BUG_ON(mt, 124 != next);
> + MT_BUG_ON(mt, mtree_load(mt, location) != mt);
> + mtree_erase(mt, 100);
> + mtree_alloc_cyclic(mt, &location, mt, 2, 1024, &next, GFP_KERNEL);
> + MT_BUG_ON(mt, 100 != location);
> + MT_BUG_ON(mt, 101 != next);
> + MT_BUG_ON(mt, mtree_load(mt, location) != mt);
> + mtree_destroy(mt);
> +
> /* Overflow test */
> next = ULONG_MAX - 1;
> ret = mtree_alloc_cyclic(mt, &location, mt, 2, ULONG_MAX, &next, GFP_KERNEL);
Powered by blists - more mailing lists