v2
2026-10-15
重构MADV_COLD/PAGEOUT页表遍历 · v2
把 MADV_COLD/MADV_PAGEOUT 的页表遍历从层层嵌套中拆分重构,并用 selftest 保证行为不变,该函数近期频繁出 bug。
原始补丁链接
子 Patch(10)
1/10
mm/madvise: name the shared LRU PMD callback
把 MADV_COLD/PAGEOUT 共享的 PMD 回调由 PTE 实现名改为 madvise_lru_pmd_entry(),为后续拆分 PMD/PTE 路径做准备,无功能变化。
2/10
mm/madvise: factor shared LRU folio handling
The huge-PMD and PTE paths duplicate folio filtering, reference clearing, deactivation and pageout isolation. Keeping both copies synchronized obscures the page-table-specific control flow. Factor th
3/10
mm/madvise: use the PMD softleaf validity helper
A non-present huge PMD must contain a software leaf type supported at PMD level. The open-coded check names the currently supported migration and device-private entries instead of expressing that inva
4/10
mm/madvise: factor the cold and pageout folio split
Both the huge-PMD and PTE paths of madvise_lru_pmd_entry() split a folio they hold locked and referenced, then drop the lock and the reference, with the same three calls open-coded at each site. Move
5/10
mm/madvise: factor huge-PMD folio processing
The huge-PMD branch of madvise_lru_pmd_entry() decides inline whether the PMD maps a folio worth advising: it checks that the PMD is present, looks up the folio and applies the shared filters, all bet
6/10
mm/madvise: separate huge PMDs from the PTE walk
madvise_lru_pmd_entry() still handles a huge PMD inline, and jumps into its PTE walk with a goto when the huge-PMD folio was split. The PMD lock, the split and the reclaim of the advised folio all sh
7/10
mm/madvise: separate PTE-batch folio processing
Each pass of the PTE loop validates the entry, batches the PTEs that map one large folio, decides whether a partly mapped large folio must be split, and ages or isolates the folio. The split path als
8/10
mm/madvise: separate the PTL-held PTE scan
The PTE loop’s scan is broken up by the two places that drop the PTE lock: the periodic reschedule and the large-folio split. Move the scan into madvise_lru_pte_range_locked(), which runs entirely un
9/10
mm/madvise: make cold and pageout PTE lock ownership explicit
madvise_lru_pmd_entry() maps and unmaps the PTE table through a restart label and an out label, so finding where the PTE lock is held means following every goto. Move the PTE path into madvise_lru_pt
10/10
mm/madvise: share cold and pageout walk setup
madvise_cold() and madvise_pageout() each open-code the same mmu_gather and page-walk sequence, differing only in the pageout flag they pass to the walk. Move that sequence into madvise_lru_vma_range