[PATCH v2 00/10] mm/madvise: refactor cold and pageout page table walks
From: Gregory Price (Meta)
Date: Wed Oct 14 2026 - 14:30:45 EST
MADV_COLD and MADV_PAGEOUT share one page-walk callback that handles
huge PMDs, PTE-mapped large folios, ordinary PTEs, folio splitting and
deferred PAGEOUT reclaim. Its control flow makes page-table lock
ownership and split retries hard to audit.
This series splits the callback along what each part owns, with no
intended change in behavior:
1-3 rename the callback, share the folio filter and LRU handling,
and use pmd_is_valid_softleaf()
4 factor the folio split and release used by both paths
5-6 separate the huge-PMD path
7-9 separate PTE-batch processing, the scan under the PTE lock, and
PTE lock ownership
10 share the mmu_gather and page-walk setup between madvise_cold()
and madvise_pageout()
Helpers used only by MADV_COLD and MADV_PAGEOUT take the madvise_lru_
prefix.
Testing was done in a virtme-ng guest with 4 CPUs, two NUMA nodes, a 2G
swap disk, 16 hugetlb pages, THP set to always, CONFIG_DEBUG_VM and
CONFIG_PROVE_LOCKING. Each suite ran three times on the base kernel and
with this series applied, with no warnings in dmesg:
Changes since v1:
- Moved the selftests to their own series.
- rebased on top of latest madvise fixes in mm-new
- Split out patch 4 to simplify a few things.
- Reworked patch 5 (Lorenzo)
- split now happens in madvise_lru_huge_pmd()
- patch 5 only factors out the folio lookup and young-bit clears
- Patch 2 has style-only changes:
- madvise_lru_folio() is no longer inline
- madvise_lru_folio_is_filtered() gained a comment
- some minor formatting changes.
v1: https://lore.kernel.org/r/20260922235830.2350770-1-gourry@xxxxxxxxxx/
Tests:
[0] https://lore.kernel.org/linux-mm/20261014175756.2035176-1-gourry@xxxxxxxxxx/
[1] https://lore.kernel.org/linux-mm/20260922235830.2350770-2-gourry@xxxxxxxxxx/
Gregory Price (Meta) (10):
mm/madvise: name the shared LRU PMD callback
mm/madvise: factor shared LRU folio handling
mm/madvise: use the PMD softleaf validity helper
mm/madvise: factor the cold and pageout folio split
mm/madvise: factor huge-PMD folio processing
mm/madvise: separate huge PMDs from the PTE walk
mm/madvise: separate PTE-batch folio processing
mm/madvise: separate the PTL-held PTE scan
mm/madvise: make cold and pageout PTE lock ownership explicit
mm/madvise: share cold and pageout walk setup
mm/madvise.c | 473 ++++++++++++++++++++++++++++-----------------------
1 file changed, 264 insertions(+), 209 deletions(-)
--
2.56.0