Re: [PATCH mm-unstable 1/1] mm/khugepaged: fix PMD collapse swap PTE accounting
From: Lance Yang
Date: Tue Jun 09 2026 - 10:02:04 EST
On 2026/6/9 21:20, David Hildenbrand (Arm) wrote:
On 6/9/26 14:04, Lance Yang wrote:
From: Lance Yang <lance.yang@xxxxxxxxx>
mthp_collapse() uses mthp_present_ptes to decide whether a range has
enough occupied PTEs to try collapse. Swap PTEs accepted by
collapse_scan_pmd() are counted in unmapped, but are not represented in
mthp_present_ptes.
When lower orders are enabled, collapse_scan_pmd() relaxes max_ptes_none
so the scan can cover the whole PMD and build the bitmap. mthp_collapse()
then checks the PMD-order candidate using the bitmap.
With max_ptes_none set to 0, a range with 511 present PTEs and one swap
PTE no longer reaches collapse_huge_page(), even though PMD collapse can
handle swap PTEs up to max_ptes_swap.
Account unmapped PTEs only for PMD order. PMD collapse supports swap PTEs
through max_ptes_swap, while lower-order mTHP collapse does not currently
support non-present PTEs. Keep non-present PTEs out of the lower-order
eligibility check.
Signed-off-by: Lance Yang <lance.yang@xxxxxxxxx>
---
Sent separately, as discussed in [1], to spell out the PMD-order swap PTE
case. Patch [2] is still only in mm-unstable, so no Fixes: tag.
Right, probably we just want to add the Fixes: tag once Andrew moves the series
to mm-stable?
Yep, hopefully Andrew can add the Fixes: tag when applying this, once
the series lands in mm-stable. Should be soon, I guess :P