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 <[email protected]> Acked-by: Qi Zheng <[email protected]> Acked-by: Mike Rapoport (Microsoft) <[email protected]> --- Note: When folding this fix into "mm/sparse-vmemmap: introduce CONFIG_VMEMMAP_OPTIMIZATION", please use this commit message for the resulting patch. v5: - Select VMEMMAP_OPTIMIZATION from ZONE_DEVICE instead of DEV_DAX, covering all users of dev_pagemap::vmemmap_shift, reported by Sashiko. - Drop the DEV_DAX dependency on ZONE_DEVICE added in v2, as it is no longer needed by this patch. v4: - Rename SPARSEMEM_VMEMMAP_OPTIMIZATION to VMEMMAP_OPTIMIZATION (suggested by Mike Rapoport) - Collect Acked-by from Mike Rapoport v2: - Fix SPARSEMEM_VMEMMAP_OPTIMIZATION being selected without SPARSEMEM_VMEMMAP, reported by Sashiko. - Add an explicit DEV_DAX dependency on ZONE_DEVICE - Collect Acked-by from Qi Zheng --- drivers/dax/Kconfig | 2 -- mm/Kconfig | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index f50c6b32d826..602f9a0839a9 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -8,8 +8,6 @@ if DAX config DEV_DAX tristate "Device DAX: direct access mapping device" depends on TRANSPARENT_HUGEPAGE - depends on ZONE_DEVICE - select VMEMMAP_OPTIMIZATION if ARCH_WANT_OPTIMIZE_DAX_VMEMMAP help Support raw access to differentiated (persistence, bandwidth, latency...) memory via an mmap(2) capable character diff --git a/mm/Kconfig b/mm/Kconfig index 0fa2eb76e4f2..30170a936f1f 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1224,6 +1224,7 @@ config ZONE_DMA32 config ZONE_DEVICE bool "Device memory (pmem, HMM, etc...) hotplug support" depends on MEMORY_HOTREMOVE + select VMEMMAP_OPTIMIZATION if ARCH_WANT_OPTIMIZE_DAX_VMEMMAP select XARRAY_MULTI help -- 2.54.0
