linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] test_xarray: fix failure in check_pause when CONFIG_XARRAY_MULTI is not defined
  2025-02-13 16:36 [PATCH] test_xarray: fix failure in check_pause when CONFIG_XARRAY_MULTI is not defined Kemeng Shi
@ 2025-02-13 11:05 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2025-02-13 11:05 UTC (permalink / raw)
  To: Kemeng Shi; +Cc: willy, akpm, linux-fsdevel, linux-mm, linux-kernel

Hi Kemeng,

On Thu, 13 Feb 2025 at 08:40, Kemeng Shi <shikemeng@huaweicloud.com> wrote:
> In case CONFIG_XARRAY_MULTI is not defined, xa_store_order can store a
> multi-index entry but xas_for_each can't tell sbiling entry from valid
> entry. So the check_pause failed when we store a multi-index entry and
> wish xas_for_each can handle it normally. Avoid to store multi-index
> entry when CONFIG_XARRAY_MULTI is disabled to fix the failure.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>

Thanks, this fixes the selftest on m68k/ARAnyM.

Closes: https://lore.kernel.org/r/CAMuHMdU_bfadUO=0OZ=AoQ9EAmQPA4wsLCBqohXR+QCeCKRn4A@mail.gmail.com
Fixes: c9ba5249ef8b080c ("Xarray: move forward index correctly in xas_pause()")
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] test_xarray: fix failure in check_pause when CONFIG_XARRAY_MULTI is not defined
@ 2025-02-13 16:36 Kemeng Shi
  2025-02-13 11:05 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Kemeng Shi @ 2025-02-13 16:36 UTC (permalink / raw)
  To: willy, akpm, geert, linux-fsdevel, linux-mm, linux-kernel

In case CONFIG_XARRAY_MULTI is not defined, xa_store_order can store a
multi-index entry but xas_for_each can't tell sbiling entry from valid
entry. So the check_pause failed when we store a multi-index entry and
wish xas_for_each can handle it normally. Avoid to store multi-index
entry when CONFIG_XARRAY_MULTI is disabled to fix the failure.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 lib/test_xarray.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/test_xarray.c b/lib/test_xarray.c
index 6932a26f4927..0e865bab4a10 100644
--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -1418,7 +1418,7 @@ static noinline void check_pause(struct xarray *xa)
 {
 	XA_STATE(xas, xa, 0);
 	void *entry;
-	unsigned int order;
+	int order;
 	unsigned long index = 1;
 	unsigned int count = 0;
 
@@ -1450,7 +1450,7 @@ static noinline void check_pause(struct xarray *xa)
 	xa_destroy(xa);
 
 	index = 0;
-	for (order = XA_CHUNK_SHIFT; order > 0; order--) {
+	for (order = order_limit - 1; order >= 0; order--) {
 		XA_BUG_ON(xa, xa_store_order(xa, index, order,
 					xa_mk_index(index), GFP_KERNEL));
 		index += 1UL << order;
@@ -1462,24 +1462,25 @@ static noinline void check_pause(struct xarray *xa)
 	rcu_read_lock();
 	xas_for_each(&xas, entry, ULONG_MAX) {
 		XA_BUG_ON(xa, entry != xa_mk_index(index));
-		index += 1UL << (XA_CHUNK_SHIFT - count);
+		index += 1UL << (order_limit - count - 1);
 		count++;
 	}
 	rcu_read_unlock();
-	XA_BUG_ON(xa, count != XA_CHUNK_SHIFT);
+	XA_BUG_ON(xa, count != order_limit);
 
 	index = 0;
 	count = 0;
-	xas_set(&xas, XA_CHUNK_SIZE / 2 + 1);
+	/* test unaligned index */
+	xas_set(&xas, 1 % (1UL << (order_limit - 1)));
 	rcu_read_lock();
 	xas_for_each(&xas, entry, ULONG_MAX) {
 		XA_BUG_ON(xa, entry != xa_mk_index(index));
-		index += 1UL << (XA_CHUNK_SHIFT - count);
+		index += 1UL << (order_limit - count - 1);
 		count++;
 		xas_pause(&xas);
 	}
 	rcu_read_unlock();
-	XA_BUG_ON(xa, count != XA_CHUNK_SHIFT);
+	XA_BUG_ON(xa, count != order_limit);
 
 	xa_destroy(xa);
 
-- 
2.30.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-13 11:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-13 16:36 [PATCH] test_xarray: fix failure in check_pause when CONFIG_XARRAY_MULTI is not defined Kemeng Shi
2025-02-13 11:05 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox