History

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.

Kemeng Shi committed 1 year ago

Commit 83440171 parent ac7af1f1 file · +8 −7Browse files

Showing the changes to lib/test_xarray.c (1 of 1 file). Show all

Unified · Split

lib/test_xarray.c+8−7
@@ -1418,7 +1418,7 @@ static noinline void check_pause(struct xarray *xa) · 1417 unmodified lines
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) · 25 unmodified lines
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) · 5 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t