Skip to content

Split huge pages to any lower order pages and selftests.

Zi Yan linux-kselftest linux-mm lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7XArray: Fix splitting to non-zero orderslib/test_xarray.c lib/xarray.c+16 -140 replies
2/7mm: huge_memory: add new debugfs interface to trigger split huge page on any page range.mm/huge_memory.c mm/internal.h mm/migrate.c +3 more+415 -10 replies
3/7mm: memcg: make memcg huge page split support any order split.include/linux/memcontrol.h mm/huge_memory.c mm/memcontrol.c+7 -60 replies
4/7mm: page_owner: add support for splitting to any order in split page_owner.include/linux/page_owner.h mm/huge_memory.c mm/page_alloc.c +1 more+16 -120 replies
5/7mm: thp: split huge page to any lower order pages.include/linux/huge_mm.h mm/huge_memory.c mm/swap.c+96 -320 replies
6/7mm: truncate: split thp to a non-zero order if possible.mm/truncate.c+27 -20 replies
7/7mm: huge_memory: enable debugfs to split huge pages to any order.mm/huge_memory.c tools/testing/selftests/vm/split_huge_page_test.c+186 -190 replies

Reviews trailers per patch

1 of 7 patches has a Reviewed-by or Acked-by.

PatchRalph CampbellRoman Gushchin
1/7
2/7
3/7R-b A-b
4/7
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/7] Split huge pages to any lower order pages and selftests.

From: Zi Yan <[email protected]>

Hi all,

With Matthew's THP in pagecache patches[1], we will be able to handle any size pagecache THPs, but currently split_huge_page can only split a THP to order-0 pages. This can easily erase the benefit of having pagecache THPs, when operations like truncate might want to keep pages larger than order-0. In response, here is the patches to add support for splitting a THP to any lower order pages. In addition, this patchset prepares for my PUD THP patchset[2], since splitting a PUD THP to multiple PMD THPs can be handled by split_huge_page_to_list_to_order function added by this patchset, which reduces a lot of redundant code without just replicating split_huge_page for PUD THP.

To help the tests of splitting huge pages, I added a new debugfs interface at <debugfs>/split_huge_pages_in_range_pid, so developers can split THPs in a given range from a process with the given pid by writing "<pid>,<vaddr_start>,<vaddr_end>,<to_order>" to the interface. I also added a new test program to test 1) splitting PMD THPs, 2) splitting PTE-mapped THPs,
3) splitting pagecache THPs to any lower order, 4) truncating a pagecache THP to a page with a lower order, and 5) punching holes in a pagecache THP to cause splitting THPs to lower order THPs.

The patchset is on top of Matthew's pagecache/next tree[3].

* Patch 1 is cherry-picked from Matthew's recent xarray fix [4] just to make sure Patch 3 to 7 can run without problem. I let Matthew decide how it should get picked up.
* Patch 2 is self-contained and can be merged if it looks OK.

Comments and/or suggestions are welcome.

ChangeLog
===
From RFC:
1. Fixed debugfs to handle splitting PTE-mapped THPs properly and added stats for split THPs.
2. Added a new test case for splitting PTE-mapped THPs. Each of the four PTEs points to a different subpage from four THPs and used kpageflags to check whether a PTE points to a THP or not (AnonHugePages from smap does not show PTE-mapped THPs).
3. mem_cgroup_split_huge_fixup() takes order instead of nr.
4. split_page_owner takes old_order and new_order instead of nr and new_order.
5. Corrected __split_page_owner declaration and fixed its implementation when splitting a THP to a new order.
6. Renamed left to remaining in truncate_inode_partial_page().
7. Use VM_BUG_ON instead of WARN_ONCE when splitting a THP to the unsupported order-0 and splitting anonymous THPs to non-zero orders.
8. Added punching holes in a file as a new pagecache THP split test case, which uncovered an xarray bug.

[1] https://lore.kernel.org/linux-mm/[email protected]/
[2] https://lore.kernel.org/linux-mm/[email protected]/
[3] https://git.infradead.org/users/willy/pagecache.git/shortlog/refs/heads/next
[4] https://git.infradead.org/users/willy/xarray.git

Matthew Wilcox (Oracle) (1):
XArray: Fix splitting to non-zero orders

Zi Yan (6):
mm: huge_memory: add new debugfs interface to trigger split huge page
on any page range.
mm: memcg: make memcg huge page split support any order split.
mm: page_owner: add support for splitting to any order in split
page_owner.
mm: thp: split huge page to any lower order pages.
mm: truncate: split thp to a non-zero order if possible.
mm: huge_memory: enable debugfs to split huge pages to any order.

 include/linux/huge_mm.h                       |   8 +
 include/linux/memcontrol.h                    |   5 +-
 include/linux/page_owner.h                    |  10 +-
 lib/test_xarray.c                             |  26 +-
 lib/xarray.c                                  |   4 +-
 mm/huge_memory.c                              | 219 ++++++--
 mm/internal.h                                 |   1 +
 mm/memcontrol.c                               |   6 +-
 mm/migrate.c                                  |   2 +-
 mm/page_alloc.c                               |   2 +-
 mm/page_owner.c                               |  13 +-
 mm/swap.c                                     |   1 -
 mm/truncate.c                                 |  29 +-
 tools/testing/selftests/vm/.gitignore         |   1 +
 tools/testing/selftests/vm/Makefile           |   1 +
 .../selftests/vm/split_huge_page_test.c       | 479 ++++++++++++++++++
 16 files changed, 742 insertions(+), 65 deletions(-)
 create mode 100644 tools/testing/selftests/vm/split_huge_page_test.c

--
2.28.0