Skip to content

Commit 8344017

Browse files
Kemeng Shiakpm00
Kemeng Shi
authored andcommitted
test_xarray: fix failure in check_pause when CONFIG_XARRAY_MULTI is not defined
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. Link: https://lkml.kernel.org/r/[email protected] Fixes: c9ba524 ("Xarray: move forward index correctly in xas_pause()") Signed-off-by: Kemeng Shi <[email protected]> Reported-by: Geert Uytterhoeven <[email protected]> Closes: https://lore.kernel.org/r/CAMuHMdU_bfadUO=0OZ=AoQ9EAmQPA4wsLCBqohXR+QCeCKRn4A@mail.gmail.com Tested-by: Geert Uytterhoeven <[email protected]> Cc: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ac7af1f commit 8344017

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/test_xarray.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ static noinline void check_pause(struct xarray *xa)
14181418
{
14191419
XA_STATE(xas, xa, 0);
14201420
void *entry;
1421-
unsigned int order;
1421+
int order;
14221422
unsigned long index = 1;
14231423
unsigned int count = 0;
14241424

@@ -1450,7 +1450,7 @@ static noinline void check_pause(struct xarray *xa)
14501450
xa_destroy(xa);
14511451

14521452
index = 0;
1453-
for (order = XA_CHUNK_SHIFT; order > 0; order--) {
1453+
for (order = order_limit - 1; order >= 0; order--) {
14541454
XA_BUG_ON(xa, xa_store_order(xa, index, order,
14551455
xa_mk_index(index), GFP_KERNEL));
14561456
index += 1UL << order;
@@ -1462,24 +1462,25 @@ static noinline void check_pause(struct xarray *xa)
14621462
rcu_read_lock();
14631463
xas_for_each(&xas, entry, ULONG_MAX) {
14641464
XA_BUG_ON(xa, entry != xa_mk_index(index));
1465-
index += 1UL << (XA_CHUNK_SHIFT - count);
1465+
index += 1UL << (order_limit - count - 1);
14661466
count++;
14671467
}
14681468
rcu_read_unlock();
1469-
XA_BUG_ON(xa, count != XA_CHUNK_SHIFT);
1469+
XA_BUG_ON(xa, count != order_limit);
14701470

14711471
index = 0;
14721472
count = 0;
1473-
xas_set(&xas, XA_CHUNK_SIZE / 2 + 1);
1473+
/* test unaligned index */
1474+
xas_set(&xas, 1 % (1UL << (order_limit - 1)));
14741475
rcu_read_lock();
14751476
xas_for_each(&xas, entry, ULONG_MAX) {
14761477
XA_BUG_ON(xa, entry != xa_mk_index(index));
1477-
index += 1UL << (XA_CHUNK_SHIFT - count);
1478+
index += 1UL << (order_limit - count - 1);
14781479
count++;
14791480
xas_pause(&xas);
14801481
}
14811482
rcu_read_unlock();
1482-
XA_BUG_ON(xa, count != XA_CHUNK_SHIFT);
1483+
XA_BUG_ON(xa, count != order_limit);
14831484

14841485
xa_destroy(xa);
14851486

0 commit comments

Comments
 (0)