Skip to content

RFC Extend xas_split* to support splitting arbitrarily large entries

Ackerley Tng linux-fsdevel linux-mm lkml syzbot 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4XArray: Initialize nodes while splitting instead of while allocatinglib/xarray.c+1 -10 replies
2/4XArray: Update xas_split_alloc() to allocate enough nodes to split large entrieslib/xarray.c+36 -160 replies
3/4XArray: Support splitting for arbitrarily large entrieslib/xarray.c+121 -370 replies
4/4XArray: test: Increase split order test range in check_split()lib/test_xarray.c+5 -12 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/4] Extend xas_split* to support splitting arbitrarily large entries

guest_memfd is planning to store huge pages in the filemap, and guest_memfd's use of huge pages involves splitting of huge pages into individual pages. Splitting of huge pages also involves splitting of the filemap entries for the pages being split.

To summarize the context of how these patches will be used,

+ guest_memfd stores huge pages (up to 1G pages) in the filemap.
+ During folio splitting, guest_memfd needs split the folios, and approaches that by first splitting the filemap (XArray) entries that the folio occupies, and then splitting the struct folios themselves.
+ Splitting from a 1G to 4K folio requires splitting an entry in a shift-18 XArray node to a shift-0 node in the xarray, which goes beyond 2 levels of XArray nodes, and is currently not supported.

This work-in-progress series at [1] shows the context of how these patches for XArray entry splitting will be used.

[1] https://github.com/googleprodkernel/linux-cc/tree/wip-gmem-conversions-hugetlb-restructuring

This patch series extends xas_split_alloc() to allocate enough nodes for splitting an XArray node beyond 2 levels, and extends xas_split() to use the allocated nodes in a split beyond 2 levels.

Merging of XArray entries can be performed with xa_store_order() at the original order, and hence no change to the XArray library is required.

xas_destroy() cleans up any allocated and unused nodes in struct xa_state, and so no further changes are necessary there.

Please let me know

+ If this extension is welcome
+ Your thoughts on the approach: is it too many nodes to allocate at once? Would a recursive implementation be preferred?
+ If there are any bugs, particularly around how xas_split() interacts with LRU

Thank you!

Ackerley Tng (4):
XArray: Initialize nodes while splitting instead of while allocating
XArray: Update xas_split_alloc() to allocate enough nodes to split
large entries
XArray: Support splitting for arbitrarily large entries
XArray: test: Increase split order test range in check_split()

 lib/test_xarray.c |   6 +-
 lib/xarray.c      | 210 ++++++++++++++++++++++++++++++++++------------
 2 files changed, 162 insertions(+), 54 deletions(-)

--
2.52.0.rc1.455.g30608eb744-goog