v5
2026-10-15
拆分 collapse 引擎与调用者 · v5
重构 mm/collapse/khugepaged,拆分 PTE 表扫描与 collapse,移除冗余 mm pin 并统一策略命名。
原始补丁链接
子 Patch(9)
1/9
mm/khugepaged: drop redundant mm_struct pin in madvise_collapse()
madvise_collapse() 中 mmgrab/mmdrop 冗余:madvise、process_madvise、io_uring、DAMON 调用路径已持 mm_users,删除引用固定以简化生命周期。
2/9
mm/khugepaged: count collapses where khugepaged makes them
把 khugepaged_pages_collapsed 计数从 collapse_single_pmd() 移到守护进程扫描路径,按 scan_result 自行统计,避免共享 collapse 路径再测 cc->is_khugepaged。
3/9
mm/khugepaged: rename mthp_present_ptes bitmap to eligible_ptes
将 mthp_present_ptes 位图改名 eligible_ptes:置位表示 PTE 已过 uffd、lazyfree、匿名/共享检查,可作 collapse 源;mthp_collapse 从 PMD order 读取,不限 mTHP。
4/9
mm/collapse: add collapse.h for the collapse interface
新增 mm/collapse.h,集中 enum scan_result、struct collapse_control,并把两个 KHUGEPAGED_* 常量改为 COLLAPSE_*,划清用户与引擎接口。
5/9
mm/collapse: state what a collapse may do in the policy
引入 struct collapse_policy,用调用者填写的策略替代散落的 cc->is_khugepaged 判断,覆盖 VMA 资格、PTE 限额、MADV_FREE、脏页回写等。
6/9
mm/collapse: drop the collapse_possible() wrapper
删除仅转发 collapse_possible_orders() 并把 mask 转 bool 的 collapse_possible(),三个调用者直接测试返回 mask,无功能变化。
7/9
mm/collapse: name the per-table scan reset for what it resets
On Wed, Oct 14, 2026 at 06:11:40PM +0100, Kiryl Shutsemau (Meta) wrote: >collapse_control_init_scan() resets what one scan accumulates: the node >load, the allocation nodemask and the eligible-PTE bit
8/9
mm/collapse: call collapse_file() from collapse_single_pmd()
[Re: [PATCH v5 8/9] mm/collapse: call collapse_file() from collapse_single_pmd()] On Wed, Oct 14, 2026 at 06:11:41PM +0100, Kiryl Shutsemau (Meta) wrote: >collapse_scan_file() reads the page cache to
9/9
mm/collapse: separate scanning a PTE table from collapsing it
On Wed, Oct 14, 2026 at 06:11:42PM +0100, Kiryl Shutsemau (Meta) wrote: >A collapse is two jobs. One reads a PTE table under mmap_lock and decides >whether the range is worth collapsing. The other a