From: hotforest <hotforest@gmail.com> hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/10302 -------------------------------- Add ARCH_WANT_OPTIMIZE_P2PDMA_VMEMMAP so architectures can enable vmemmap deduplication for P2PDMA independently of device DAX. Let either the DAX or P2PDMA architecture capability enable the generic vmemmap optimization check. The implementation and its minimum metadata page requirement are shared. No architecture selects the new capability yet, so this change alone does not change runtime behavior. Signed-off-by: hotforest <hotforest@gmail.com> Signed-off-by: Zizhi Wo <wozizhi@huawei.com> --- include/linux/mm.h | 7 ++++--- mm/Kconfig | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 8784c13db3d0..28eda1d3e5c8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4152,11 +4152,12 @@ void vmemmap_populate_print_last(void); void vmemmap_free(unsigned long start, unsigned long end, struct vmem_altmap *altmap); #endif #define VMEMMAP_RESERVE_NR 2 -#ifdef CONFIG_ARCH_WANT_OPTIMIZE_DAX_VMEMMAP +#if defined(CONFIG_ARCH_WANT_OPTIMIZE_DAX_VMEMMAP) || \ + defined(CONFIG_ARCH_WANT_OPTIMIZE_P2PDMA_VMEMMAP) static inline bool __vmemmap_can_optimize(struct vmem_altmap *altmap, struct dev_pagemap *pgmap) { unsigned long nr_pages; unsigned long nr_vmemmap_pages; @@ -4165,12 +4166,12 @@ static inline bool __vmemmap_can_optimize(struct vmem_altmap *altmap, return false; nr_pages = pgmap_vmemmap_nr(pgmap); nr_vmemmap_pages = ((nr_pages * sizeof(struct page)) >> PAGE_SHIFT); /* - * For vmemmap optimization with DAX we need minimum 2 vmemmap - * pages. See layout diagram in Documentation/mm/vmemmap_dedup.rst + * Vmemmap optimization needs a minimum of 2 vmemmap pages. See the + * layout diagram in Documentation/mm/vmemmap_dedup.rst. */ return !altmap && (nr_vmemmap_pages > VMEMMAP_RESERVE_NR); } /* * If we don't have an architecture override, use the generic rule diff --git a/mm/Kconfig b/mm/Kconfig index 89b15236b874..7c69ffb52e24 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -533,16 +533,19 @@ config SPARSEMEM_VMEMMAP help SPARSEMEM_VMEMMAP uses a virtually mapped memmap to optimise pfn_to_page and page_to_pfn operations. This is the most efficient option when sufficient kernel resources are available. # -# Select this config option from the architecture Kconfig, if it is preferred -# to enable the feature of HugeTLB/dev_dax vmemmap optimization. +# Select these config options from the architecture Kconfig, if it is preferred +# to enable the feature of HugeTLB/dev_dax/P2PDMA vmemmap optimization. # config ARCH_WANT_OPTIMIZE_DAX_VMEMMAP bool +config ARCH_WANT_OPTIMIZE_P2PDMA_VMEMMAP + bool + config ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP bool config HAVE_MEMBLOCK_PHYS_MAP bool -- 2.52.0