Re: [PATCH] fixup! mm/sparse-vmemmap: introduce CONFIG_VMEMMAP_OPTIMIZATION
From: Muchun Song <muchun.song@linux.dev>
Date: 2026-09-16 08:46:21
Also in:
linux-doc, linux-mm, lkml
On Sep 16, 2026, at 16:36, Muchun Song [off-list ref] wrote: The section-based vmemmap optimization infrastructure is guarded by CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP, but it can also be used by ZONE_DEVICE users that set dev_pagemap::vmemmap_shift. Introduce CONFIG_VMEMMAP_OPTIMIZATION as a common config for the shared infrastructure. Select the new option from HUGETLB_PAGE_OPTIMIZE_VMEMMAP and from ZONE_DEVICE when the architecture opts in to DAX vmemmap optimization, and use it to guard the generic sparse-vmemmap state and helpers. Signed-off-by: Muchun Song <redacted> Acked-by: Qi Zheng <qi.zheng@linux.dev> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- Note: When folding this fix into "mm/sparse-vmemmap: introduce CONFIG_VMEMMAP_OPTIMIZATION", please use this commit message for the resulting patch.
Hi Andrew, Sashiko found a configuration issue in patch 1 [1]. MSHV_VTL sets a non-zero dev_pagemap::vmemmap_shift for VTL0 memory. However, VMEMMAP_OPTIMIZATION is currently selected only by DEV_DAX or HUGETLB_PAGE_OPTIMIZE_VMEMMAP. With ZONE_DEVICE=y and MSHV_VTL=y, but DEV_DAX=n and HUGETLB_PAGE=n, VMEMMAP_OPTIMIZATION is therefore disabled. __vmemmap_can_optimize() always returns false in this configuration, so VTL0 memory uses an unoptimized vmemmap despite its non-zero vmemmap_shift. On common x86-64 configurations, this can consume up to about 1.5% of the mapped VTL0 memory for vmemmap metadata. The report is correct. The fixup in the parent message moves the conditional selection of VMEMMAP_OPTIMIZATION from DEV_DAX to ZONE_DEVICE. This covers every ZONE_DEVICE user that sets dev_pagemap::vmemmap_shift while retaining the architecture opt-in through ARCH_WANT_OPTIMIZE_DAX_VMEMMAP. It also removes the DEV_DAX dependency on ZONE_DEVICE that patch 1 added solely to satisfy the Kconfig dependency of VMEMMAP_OPTIMIZATION. Andrew, could you please fold this fixup into patch 1, "mm/sparse-vmemmap: introduce CONFIG_VMEMMAP_OPTIMIZATION"? [1] https://sashiko.dev/#/patchset/20260916064341.1825793-1-songmuchun%40bytedance.com Thanks, Muchun