Re: [PATCH mm-unstable v19 06/14] mm/khugepaged: generalize collapse_huge_page for mTHP collapse
From: Lance Yang <lance.yang@linux.dev>
Date: 2026-06-08 04:54:36
Also in:
linux-doc, linux-mm, lkml
From: Lance Yang <lance.yang@linux.dev>
Date: 2026-06-08 04:54:36
Also in:
linux-doc, linux-mm, lkml
On Fri, Jun 05, 2026 at 10:14:13AM -0600, Nico Pache wrote:
Pass an order to collapse_huge_page to support collapsing anon memory to arbitrary orders within a PMD. order indicates what mTHP size we are attempting to collapse to. For non-PMD collapse we must leave the anon VMA write locked until after we collapse the mTHP-- in the PMD case all the pages are isolated, but in the mTHP case this is not true, and we must keep the lock to prevent access/changes to the page tables. This can happen if the rmap walkers hit a pmd_none while the PMD entry is currently unavailable due to being temporarily removed during the collapse phase. To properly establish the page table hierarchy without violating any expectations from certain architectures (e.g. MIPS), we must make sure to have the PMD reinstalled before the PTEs, and hold both PTE/PMD locks before calling update_mmu_cache_range() (if they are distinct locks). Signed-off-by: Nico Pache <npache@redhat.com> ---
Nothing else jumped out at me. Anything left can be sorted out later, as David and Lorenzo said :) Reviewed-by: Lance Yang <lance.yang@linux.dev>