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.
Showing the changes to lib/test_xarray.c (1 of 1 file). Show all
Unified · Split
| @@ -1418,7 +1418,7 @@ static noinline void check_pause(struct xarray *xa) · 1417 unmodified lines | |||
| 1418 | { | 1418 | { |
| 1419 | XA_STATE(xas, xa, 0); | 1419 | XA_STATE(xas, xa, 0); |
| 1420 | void *entry; | 1420 | void *entry; |
| 1421 | unsigned int order; | 1421 | int order; |
| 1422 | unsigned long index = 1; | 1422 | unsigned long index = 1; |
| 1423 | unsigned int count = 0; | 1423 | unsigned int count = 0; |
| 1424 | 1424 | ||
| @@ -1450,7 +1450,7 @@ static noinline void check_pause(struct xarray *xa) · 25 unmodified lines | |||
| 1450 | xa_destroy(xa); | 1450 | xa_destroy(xa); |
| 1451 | 1451 | ||
| 1452 | index = 0; | 1452 | index = 0; |
| 1453 | for (order = XA_CHUNK_SHIFT; order > 0; order--) { | 1453 | for (order = order_limit - 1; order >= 0; order--) { |
| 1454 | XA_BUG_ON(xa, xa_store_order(xa, index, order, | 1454 | XA_BUG_ON(xa, xa_store_order(xa, index, order, |
| 1455 | xa_mk_index(index), GFP_KERNEL)); | 1455 | xa_mk_index(index), GFP_KERNEL)); |
| 1456 | index += 1UL << order; | 1456 | index += 1UL << order; |
| @@ -1462,24 +1462,25 @@ static noinline void check_pause(struct xarray *xa) · 5 unmodified lines | |||
| 1462 | rcu_read_lock(); | 1462 | rcu_read_lock(); |
| 1463 | xas_for_each(&xas, entry, ULONG_MAX) { | 1463 | xas_for_each(&xas, entry, ULONG_MAX) { |
| 1464 | XA_BUG_ON(xa, entry != xa_mk_index(index)); | 1464 | XA_BUG_ON(xa, entry != xa_mk_index(index)); |
| 1465 | index += 1UL << (XA_CHUNK_SHIFT - count); | 1465 | index += 1UL << (order_limit - count - 1); |
| 1466 | count++; | 1466 | count++; |
| 1467 | } | 1467 | } |
| 1468 | rcu_read_unlock(); | 1468 | rcu_read_unlock(); |
| 1469 | XA_BUG_ON(xa, count != XA_CHUNK_SHIFT); | 1469 | XA_BUG_ON(xa, count != order_limit); |
| 1470 | 1470 | ||
| 1471 | index = 0; | 1471 | index = 0; |
| 1472 | count = 0; | 1472 | count = 0; |
| 1473 | xas_set(&xas, XA_CHUNK_SIZE / 2 + 1); | 1473 | /* test unaligned index */ |
| 1474 | xas_set(&xas, 1 % (1UL << (order_limit - 1))); | ||
| 1474 | rcu_read_lock(); | 1475 | rcu_read_lock(); |
| 1475 | xas_for_each(&xas, entry, ULONG_MAX) { | 1476 | xas_for_each(&xas, entry, ULONG_MAX) { |
| 1476 | XA_BUG_ON(xa, entry != xa_mk_index(index)); | 1477 | XA_BUG_ON(xa, entry != xa_mk_index(index)); |
| 1477 | index += 1UL << (XA_CHUNK_SHIFT - count); | 1478 | index += 1UL << (order_limit - count - 1); |
| 1478 | count++; | 1479 | count++; |
| 1479 | xas_pause(&xas); | 1480 | xas_pause(&xas); |
| 1480 | } | 1481 | } |
| 1481 | rcu_read_unlock(); | 1482 | rcu_read_unlock(); |
| 1482 | XA_BUG_ON(xa, count != XA_CHUNK_SHIFT); | 1483 | XA_BUG_ON(xa, count != order_limit); |
| 1483 | 1484 | ||
| 1484 | xa_destroy(xa); | 1485 | xa_destroy(xa); |
| 1485 | 1486 | ||