v1
2026-09-18
shmem 支持 mTHP 折叠 · v1
shmem/file mTHP collapse 跟进:位图跟踪页块并递归选阶,扩展临时位图,仅 PMD 大小走 collapse_pte_mapped_thp。
原始补丁链接
子 Patch(12)
1/12
mm: khugepaged: remove outdated comments and check for shmem
[mm: khugepaged: remove outdated comments and check for shmem] After commit eb92d97f7e6a (“Revert ’tmpfs: don’t enable large folios if not supported’”), all shmem mounts can support large folios uncon
2/12
mm: khugepaged: drop the hugepage_madvise()
[mm: khugepaged: drop the hugepage_madvise()] After commit 2fd4e7693674 (“mm: fix incorrect vm_flags usage when checking allowable orders for tmpfs”), hugepage_madvise() no longer calls any khugepaged
3/12
mm: shmem: don't expose 'deny' and 'force' via the kernel command line
[mm: shmem: don’t expose ‘deny’ and ‘force’ via the kernel command line] Based on the previous discussion with Lorenzo[1], the ‘deny’ and ‘force’ options are testing-only configurations and shouldn’t
4/12
mm: khugepaged: move cc->scan_file and cc->scan_pgoff assignment into collapse_scan_file()
[mm: khugepaged: move cc->scan_file and cc->scan_pgoff assignment into collapse_scan_file()] Move the assignment of cc->scan_file and cc->scan_pgoff into collapse_scan_file(). This simplifies the para
5/12
mm: khugepaged: add max_ptes_none check in collapse_file()
[mm: khugepaged: add max_ptes_none check in collapse_file()] Similar to the anonymous folios collapse, we should also check the ‘max_ptes_none’ when trying to collapse shmem/file folios, which is also
6/12
mm: khugepaged: generalize collapse_file() for shmem mTHP support
[mm: khugepaged: generalize collapse_file() for shmem mTHP support] Generalize the order of the collapse_file() function to support future shmem mTHP collapse. No functional changes in this patch. S
7/12
mm: khugepaged: add an order check for PMD-sized THP statistics
[mm: khugepaged: add an order check for PMD-sized THP statistics] In order to support shmem mTHP collapse in the following patches, add an PMD-sized THP order check to avoid PMD-sized THP statistics e
8/12
mm: khugepaged: add a helper to get the minimal collapse order
[mm: khugepaged: add a helper to get the minimal collapse order] shmem mTHP collapse will need to support order-1 collapse in the future, so add a helper to retrieve the minimal collapse order as a pr
9/12
mm: khugepaged: add shmem mTHP collapse support
[mm: khugepaged: add shmem mTHP collapse support] Khugepaged already supports the anonymous mTHP collapse. Similarly, let khugepaged also support the shmem mTHP collapse. The strategy for shmem mTHP c
10/12
mm: shmem: run khugepaged for all shmem mTHP orders
[mm: shmem: run khugepaged for all shmem mTHP orders] When only non-PMD-sized mTHP is enabled (such as only 64K mTHP enabled), we should also allow kicking khugepaged to attempt scanning and collapsin
11/12
mm: khugepaged: allow khugepaged to check all shmem mTHP-sized orders
[mm: khugepaged: allow khugepaged to check all shmem mTHP-sized orders] We are now ready to enable shmem mTHP collapse, allowing thp_vma_allowable_orders() to check all permissible shmem large orders.
12/12
selftests: mm: add shmem mTHP collapse test cases
[selftests: mm: add shmem mTHP collapse test cases] Add shmem mTHP collapse test cases for ‘collapse_full’, and ‘collapse_single_mthp’ for shmem. All khugepaged test cases passed. Signed-off-by: Baol