diff options
| author | Kemeng Shi <[email protected]> | 2024-12-13 12:25:20 +0000 |
|---|---|---|
| committer | Andrew Morton <[email protected]> | 2025-01-25 06:47:27 +0000 |
| commit | c9ba5249ef8b080c6779d3da14a061f6d4d6d5fa (patch) | |
| tree | 7b09aa3fa002ad701eda1287aec53d8b2dc4bd2f /lib/xarray.c | |
| parent | Xarray: do not return sibling entries from xas_find_marked() (diff) | |
| download | kernel-c9ba5249ef8b080c6779d3da14a061f6d4d6d5fa.tar.gz kernel-c9ba5249ef8b080c6779d3da14a061f6d4d6d5fa.zip | |
Xarray: move forward index correctly in xas_pause()
After xas_load(), xas->index could point to mid of found multi-index entry
and xas->index's bits under node->shift maybe non-zero. The afterward
xas_pause() will move forward xas->index with xa->node->shift with bits
under node->shift un-masked and thus skip some index unexpectedly.
Consider following case:
Assume XA_CHUNK_SHIFT is 4.
xa_store_range(xa, 16, 31, ...)
xa_store(xa, 32, ...)
XA_STATE(xas, xa, 17);
xas_for_each(&xas,...)
xas_load(&xas)
/* xas->index = 17, xas->xa_offset = 1, xas->xa_node->xa_shift = 4 */
xas_pause()
/* xas->index = 33, xas->xa_offset = 2, xas->xa_node->xa_shift = 4 */
As we can see, index of 32 is skipped unexpectedly.
Fix this by mask bit under node->xa_shift when move forward index in
xas_pause().
For now, this will not cause serious problems. Only minor problem like
cachestat return less number of page status could happen.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Kemeng Shi <[email protected]>
Cc: Mattew Wilcox <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'lib/xarray.c')
| -rw-r--r-- | lib/xarray.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/xarray.c b/lib/xarray.c index 19a9ea183c2d..091e2c927915 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -1152,6 +1152,7 @@ void xas_pause(struct xa_state *xas) if (!xa_is_sibling(xa_entry(xas->xa, node, offset))) break; } + xas->xa_index &= ~0UL << node->shift; xas->xa_index += (offset - xas->xa_offset) << node->shift; if (xas->xa_index == 0) xas->xa_node = XAS_BOUNDS; |
