diff mbox series

idr test suite: Remove usage of the deprecated ida_simple_xx() API

Message ID 81f44a41b7ccceb26a802af473f931799445821a.1705683269.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State New, archived
Headers show
Series idr test suite: Remove usage of the deprecated ida_simple_xx() API | expand

Commit Message

Christophe JAILLET Jan. 19, 2024, 4:54 p.m. UTC
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(-)

Comments

Matthew Wilcox Jan. 19, 2024, 5:04 p.m. UTC | #1
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
>
diff mbox series

Patch

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);