summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorLi Zhe <lizhe.67@bytedance.com>2026-08-31 19:16:34 +0800
committerAndrew Morton <akpm@linux-foundation.org>2026-10-06 17:39:17 -0700
commit72dcfdc2ce47c84d248ab43490ec91a0d5098253 (patch)
treee4f741978b03d45b64b9ed25dbec5cdb47d261d8 /include/linux
parenta5d43b7cd64235cc12d8563889f393894589f12f (diff)
downloadlinux-next-72dcfdc2ce47c84d248ab43490ec91a0d5098253.tar.gz
linux-next-72dcfdc2ce47c84d248ab43490ec91a0d5098253.zip
mm: add a template-based fast path for zone-device page init
memmap_init_zone_device() repeats nearly identical head-page initialization for each PFN. Initialize the first real ZONE_DEVICE head page through the existing path, copy that final state into a reusable template, refresh the PFN-dependent fields in that template before each copy, and copy it into the remaining destination pages. Use the template path unconditionally. The page_ref_set tracepoint is primarily a debugging aid, while this code is still initializing struct pages before they are handed out. From the perspective of users of those pages, the initialization-time refcount transitions are not part of the observable page lifetime. This means page_ref_set will no longer observe every initialization-time refcount assignment for copied ZONE_DEVICE head pages. The impact is controlled because the final initialized struct page state is unchanged, and keeping a separate non-template path only for this local tracepoint observability would add complexity to the common path. This patch accelerates head-page initialization. The pfns_per_compound == 1 case gets the full benefit here, compound tails are handled in the next patch. Tested in a VM with a 100 GB fsdax namespace device configured with map=dev on Intel Ice Lake server. This test exercises the nd_pmem rebind path (pfns_per_compound == 1). Test procedure: Rebind the nd_pmem driver 30 times and collect the memmap initialization time from the pr_debug() output of memmap_init_zone_device(). Base(v7.3-rc1): Average of rebinds for nd_pmem driver: 221.07 ms With this patch and its prerequisites applied: Average of rebinds for nd_pmem driver: 155.00 ms This reduces the average memmap initialization time measured during rebind from 221.07 ms to 155.00 ms, or about 29.9%. [lizhe.67@bytedance.com: whitespace fix, per Mike] Link: https://lore.kernel.org/20260903025806.70825-1-lizhe.67@bytedance.com Link: https://lore.kernel.org/20260831111638.76012-4-lizhe.67@bytedance.com Signed-off-by: Li Zhe <lizhe.67@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Cc: Alistair Popple <apopple@nvidia.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Balbir Singh <balbirs@nvidia.com> Cc: "Borislav Petkov (AMD)" <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David Hildenbrand (Arm) <david@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Kees Cook <kees@kernel.org> Cc: Muchun Song <muchun.song@linux.dev>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions