diff mbox series

[21/23] testing: Introduce xa_erase_order() and use it

Message ID 20200422150256.23473-22-jack@suse.cz (mailing list archive)
State New, archived
Headers show
Series mm: Speedup page cache truncation | expand

Commit Message

Jan Kara April 22, 2020, 3:02 p.m. UTC
Introduce helper xa_erase_order() and call it from places that want to
erase entries from xarray instead of using xa_store_order(). This also
explicitely takes care of clearing possibly existing xarray marks
(although no current test seems to need it).

Signed-off-by: Jan Kara <jack@suse.cz>
---
 lib/test_xarray.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/test_xarray.c b/lib/test_xarray.c
index 2cf3ef5d5014..fc16eac1cbb9 100644
--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -83,6 +83,16 @@  static void *xa_store_order(struct xarray *xa, unsigned long index,
 	return curr;
 }
 
+static void xa_erase_order(struct xarray *xa, unsigned long index,
+		unsigned order)
+{
+	XA_STATE_ORDER(xas, xa, index, order);
+
+	xas_lock(&xas);
+	xas_erase(&xas);
+	xas_unlock(&xas);
+}
+
 static noinline void check_xa_err(struct xarray *xa)
 {
 	XA_BUG_ON(xa, xa_err(xa_store_index(xa, 0, GFP_NOWAIT)) != 0);
@@ -608,13 +618,13 @@  static noinline void check_multi_store(struct xarray *xa)
 	rcu_read_unlock();
 
 	/* We can erase multiple values with a single store */
-	xa_store_order(xa, 0, BITS_PER_LONG - 1, NULL, GFP_KERNEL);
+	xa_erase_order(xa, 0, BITS_PER_LONG - 1);
 	XA_BUG_ON(xa, !xa_empty(xa));
 
 	/* Even when the first slot is empty but the others aren't */
 	xa_store_index(xa, 1, GFP_KERNEL);
 	xa_store_index(xa, 2, GFP_KERNEL);
-	xa_store_order(xa, 0, 2, NULL, GFP_KERNEL);
+	xa_erase_order(xa, 0, 2);
 	XA_BUG_ON(xa, !xa_empty(xa));
 
 	for (i = 0; i < max_order; i++) {