v8 2026-07-28

优化 ZONE_DEVICE memmap 初始化 · v8

通过模板复用和memcpy_nontemporal减少ZONE_DEVICE memmap初始化开销。

原始补丁链接

子 Patch(9)

1/9
mm: fix stale ZONE_DEVICE refcount comment
修正__init_zone_device_page()注释,说明MEMORY_DEVICE_GENERIC在free时恢复refcount为1,其他ZONE_DEVICE类型从0开始再递增。
2/9
mm: factor zone-device page init helpers out of __init_zone_device_page
将memmap_init_zone_device()中refcount策略和页面初始化逻辑拆分为pagemap_requires_refcount_reset()与__zone_device_page_init()等独立函数。
3/9
mm: add a set_page_section_from_pfn() helper
新增set_page_section_from_pfn()包装页section位更新,基于SECTION_IN_PAGE_FLAGS条件编译,简化ZONE_DEVICE快速路径调用。
4/9
mm: add a template-based fast path for zone-device page init
通过慢路径预制备ZONE_DEVICE头页模板,刷新PFN相关字段后memcpy到各目标页,加速头页初始化,当page_ref_set跟踪点启用时禁用此路径。
5/9
mm: extend the template fast path to zone-device compound tails
扩展模板快速路径至复合尾页,对compound尾页构建独立模板并重用,避免逐个调用zone_device_page_init_slow(),提升devdax场景性能。
6/9
string: introduce memcpy_nontemporal()
引入memcpy_nontemporal()用于一次性写拷贝,x86上封装memcpy_flushcache(),通用回退为memcpy()以保留FORTIFY检查,不隐含内存屏障。
7/9
x86/string: extend memcpy_flushcache() fixed-size fastpaths
扩展memcpy_flushcache()固定大小快速路径,添加32/48/64/80/96字节MOVNTI内联序列,使sizeof(struct page)常量化拷贝避免调用__memcpy_flushcache()。
8/9
mm: use memcpy_nontemporal() in zone-device template copies
ZONE_DEVICE模板拷贝改用memcpy_nontemporal(),减少写分配开销和缓存污染,因初始化后数据很少立即重用,架构无特殊支持时回退memcpy。
9/9
mm: always use the zone-device template init path
始终使用模板初始化路径,移除page_ref_set跟踪点相关的非模板回退,但保留首个种子页逻辑;跟踪点不再观察初始化期refcount赋值。