v5
2026-07-23
匿名THP的PMD级swap条目 · v5
提交v5系列,添加PMD swap条目检测、拆分、换入换出及selftests支持。
原始补丁链接
子 Patch(11)
1/11
mm: add PMD swap entry detection support
新增PMD swap entry检测基础设施:pmd_is_swap_entry()识别、softleaf层接受非present类型、各架构添加pmd_swp_exclusive等辅助函数。
2/11
mm: add PMD swap entry splitting support
在__split_huge_pmd_locked()中添加PMD swap entry分裂分支,无需folio引用,将单个PMD swap entry拆为512个PTE swap entry。
3/11
mm: handle PMD swap entries in fork path
fork时copy_huge_pmd()处理PMD swap entry,通过swap_dup_entries_direct()复制swap槽引用计数,保留THP而非分裂。
4/11
mm: zswap: add range lookup for large-folio swapin
zswap_load()增加范围扫描,检测大folio覆盖区是否有zswap条目,返回-EIO阻止部分压缩状态的大folio读取。
5/11
mm: swap in PMD swap entries as whole THPs during swapoff
swapoff时通过unuse_pmd()以PMD粒度换入整个THP,swap_pmd_cache_lookup()分类缓存状态,分裂缓存则回退PTE路径。
6/11
mm: handle PMD swap entries in non-present PMD walkers
教导smaps、madvise_free、zap_huge_pmd等非present PMD遍历器处理PMD swap entry,避免泄漏swap槽或误判。
7/11
mm: handle PMD swap entries in MADV_WILLNEED
MADV_WILLNEED处理PMD swap entry,通过swapin_sync以PMD阶读取folio,避免分裂PMD entry和order-0预读。
8/11
mm: handle PMD swap entries in UFFDIO_MOVE
UFFDIO_MOVE通过move_swap_pmd()整体移动PMD swap entry,拒绝非独占条目,携带deposited page table迁移。
9/11
mm: handle PMD swap entry faults on swap-in
新增do_huge_pmd_swap_page()处理PMD swap entry缺页,以PMD粒度分配folio并读取swap,分裂则回退PTE路径。
10/11
mm: install PMD swap entries on swap-out
swap-out时try_to_unmap_one()通过set_pmd_swap_entry()安装PMD swap entry,避免THP分裂为512个PTE swap entry。
11/11
selftests/mm: add PMD swap entry tests
添加selftest覆盖PMD swap entry的swap-out/in、fork、COW、UFFD、mprotect、mremap、MADV_FREE等路径。