* [PATCH] idr test suite: Remove usage of the deprecated ida_simple_xx() API
@ 2024-01-19 16:54 Christophe JAILLET
2024-01-19 17:04 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2024-01-19 16:54 UTC (permalink / raw)
To: Matthew Wilcox
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-fsdevel
ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().
Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_range()/ida_alloc_max() is inclusive. But because of the ranges
used for the tests, there is no need to adjust them.
While at it remove some useless {}.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
It should be a question of weeks now before being able to remove the
ida_simple_*() API.
So it is time to convert the testing framework.
---
tools/testing/radix-tree/idr-test.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c
index ca24f6839d50..bb41e93e2acd 100644
--- a/tools/testing/radix-tree/idr-test.c
+++ b/tools/testing/radix-tree/idr-test.c
@@ -503,14 +503,12 @@ void ida_simple_get_remove_test(void)
DEFINE_IDA(ida);
unsigned long i;
- for (i = 0; i < 10000; i++) {
- assert(ida_simple_get(&ida, 0, 20000, GFP_KERNEL) == i);
- }
- assert(ida_simple_get(&ida, 5, 30, GFP_KERNEL) < 0);
+ for (i = 0; i < 10000; i++)
+ assert(ida_alloc_max(&ida, 20000, GFP_KERNEL) == i);
+ assert(ida_alloc_range(&ida, 5, 30, GFP_KERNEL) < 0);
- for (i = 0; i < 10000; i++) {
- ida_simple_remove(&ida, i);
- }
+ for (i = 0; i < 10000; i++)
+ ida_free(&ida, i);
assert(ida_is_empty(&ida));
ida_destroy(&ida);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] idr test suite: Remove usage of the deprecated ida_simple_xx() API
2024-01-19 16:54 [PATCH] idr test suite: Remove usage of the deprecated ida_simple_xx() API Christophe JAILLET
@ 2024-01-19 17:04 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2024-01-19 17:04 UTC (permalink / raw)
To: Christophe JAILLET; +Cc: linux-kernel, kernel-janitors, linux-fsdevel
On Fri, Jan 19, 2024 at 05:54:44PM +0100, Christophe JAILLET wrote:
> ida_alloc() and ida_free() should be preferred to the deprecated
> ida_simple_get() and ida_simple_remove().
>
> Note that the upper limit of ida_simple_get() is exclusive, but the one of
> ida_alloc_range()/ida_alloc_max() is inclusive. But because of the ranges
> used for the tests, there is no need to adjust them.
>
> While at it remove some useless {}.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> It should be a question of weeks now before being able to remove the
> ida_simple_*() API.
> So it is time to convert the testing framework.
Oh, that's fantastic news! Thank you for finishing off this conversion!
I don't have anything pending for the IDA/IDR/XArray right now. Either
Andrew can grab this as a misc patch, or we can leave it for a cycle and
I'll put it in along with the removal of the rest of the simple API. If
the former,
Acked-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> tools/testing/radix-tree/idr-test.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c
> index ca24f6839d50..bb41e93e2acd 100644
> --- a/tools/testing/radix-tree/idr-test.c
> +++ b/tools/testing/radix-tree/idr-test.c
> @@ -503,14 +503,12 @@ void ida_simple_get_remove_test(void)
> DEFINE_IDA(ida);
> unsigned long i;
>
> - for (i = 0; i < 10000; i++) {
> - assert(ida_simple_get(&ida, 0, 20000, GFP_KERNEL) == i);
> - }
> - assert(ida_simple_get(&ida, 5, 30, GFP_KERNEL) < 0);
> + for (i = 0; i < 10000; i++)
> + assert(ida_alloc_max(&ida, 20000, GFP_KERNEL) == i);
> + assert(ida_alloc_range(&ida, 5, 30, GFP_KERNEL) < 0);
>
> - for (i = 0; i < 10000; i++) {
> - ida_simple_remove(&ida, i);
> - }
> + for (i = 0; i < 10000; i++)
> + ida_free(&ida, i);
> assert(ida_is_empty(&ida));
>
> ida_destroy(&ida);
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-19 17:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-19 16:54 [PATCH] idr test suite: Remove usage of the deprecated ida_simple_xx() API Christophe JAILLET
2024-01-19 17:04 ` Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).