mm/vmemmap optimization: split hugetlb and devdax vmemmap optimization
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Mon, 24 Jul 2023 19:07:53 +0000 (00:37 +0530)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 18 Aug 2023 17:12:54 +0000 (10:12 -0700)
Arm disabled hugetlb vmemmap optimization [1] because hugetlb vmemmap
optimization includes an update of both the permissions (writeable to
read-only) and the output address (pfn) of the vmemmap ptes.  That is not
supported without unmapping of pte(marking it invalid) by some
architectures.

With DAX vmemmap optimization we don't require such pte updates and
architectures can enable DAX vmemmap optimization while having hugetlb
vmemmap optimization disabled.  Hence split DAX optimization support into
a different config.

s390, loongarch and riscv don't have devdax support.  So the DAX config is
not enabled for them.  With this change, arm64 should be able to select
DAX optimization

[1] commit 060a2c92d1b6 ("arm64: mm: hugetlb: Disable HUGETLB_PAGE_OPTIMIZE_VMEMMAP")

Link: https://lkml.kernel.org/r/20230724190759.483013-8-aneesh.kumar@linux.ibm.com
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/loongarch/Kconfig
arch/riscv/Kconfig
arch/s390/Kconfig
arch/x86/Kconfig
fs/Kconfig
include/linux/mm.h
mm/Kconfig

index e71d5bf2cee0fbed025bbbd53e28b37ca6364a50..dc56ddf9ba037427cd04241bdd66b1f9d366073e 100644 (file)
@@ -60,7 +60,7 @@ config LOONGARCH
        select ARCH_USE_QUEUED_SPINLOCKS
        select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
        select ARCH_WANT_LD_ORPHAN_WARN
-       select ARCH_WANT_OPTIMIZE_VMEMMAP
+       select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        select ARCH_WANTS_NO_INSTR
        select BUILDTIME_TABLE_SORT
        select COMMON_CLK
index 4c07b9189c867b715f96ec3beaf1c14a810bb2ae..6943d34c1ec1f67031f2e3e2bd6e535373f6c400 100644 (file)
@@ -53,7 +53,7 @@ config RISCV
        select ARCH_WANT_GENERAL_HUGETLB if !RISCV_ISA_SVNAPOT
        select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
        select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL
-       select ARCH_WANT_OPTIMIZE_VMEMMAP
+       select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE
        select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU
        select BUILDTIME_TABLE_SORT if MMU
index 290b6f93b816288cf08c2d491906fa21095ed7ec..8ff6d1c21e381ca2d7f2e8f6493d5668e38e88b5 100644 (file)
@@ -127,7 +127,7 @@ config S390
        select ARCH_WANTS_NO_INSTR
        select ARCH_WANT_DEFAULT_BPF_JIT
        select ARCH_WANT_IPC_PARSE_VERSION
-       select ARCH_WANT_OPTIMIZE_VMEMMAP
+       select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        select BUILDTIME_TABLE_SORT
        select CLONE_BACKWARDS2
        select DMA_OPS if PCI
index 7422db4097701c96710ce67054a9f0c7edc6ec1b..78224aa7640986c0eeef4c7b9390ea552ab2355a 100644 (file)
@@ -128,7 +128,8 @@ config X86
        select ARCH_WANT_GENERAL_HUGETLB
        select ARCH_WANT_HUGE_PMD_SHARE
        select ARCH_WANT_LD_ORPHAN_WARN
-       select ARCH_WANT_OPTIMIZE_VMEMMAP       if X86_64
+       select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP   if X86_64
+       select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP       if X86_64
        select ARCH_WANTS_THP_SWAP              if X86_64
        select ARCH_HAS_PARANOID_L1D_FLUSH
        select BUILDTIME_TABLE_SORT
index 19975b104bc36d85fedd4fdd17ebbed742b9a45b..f3be721bab6d31ba042f7fa90d19885852375123 100644 (file)
@@ -254,7 +254,7 @@ config HUGETLB_PAGE
 
 config HUGETLB_PAGE_OPTIMIZE_VMEMMAP
        def_bool HUGETLB_PAGE
-       depends on ARCH_WANT_OPTIMIZE_VMEMMAP
+       depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        depends on SPARSEMEM_VMEMMAP
 
 config HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON
index d4ce73c20dcc31b666de510af1cc03061ee827c6..b2520dd555f9116e2f8fae0c1ba81b1594fc76e0 100644 (file)
@@ -3633,7 +3633,7 @@ void vmemmap_free(unsigned long start, unsigned long end,
 #endif
 
 #define VMEMMAP_RESERVE_NR     2
-#ifdef CONFIG_ARCH_WANT_OPTIMIZE_VMEMMAP
+#ifdef CONFIG_ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
 static inline bool __vmemmap_can_optimize(struct vmem_altmap *altmap,
                                          struct dev_pagemap *pgmap)
 {
index 22acffd9009dfd259cf14c6e79fc2f342f2c4493..1959d048bbf560319fa401c098884aed5d6bb6ac 100644 (file)
@@ -487,7 +487,10 @@ config SPARSEMEM_VMEMMAP
 # Select this config option from the architecture Kconfig, if it is preferred
 # to enable the feature of HugeTLB/dev_dax vmemmap optimization.
 #
-config ARCH_WANT_OPTIMIZE_VMEMMAP
+config ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
+       bool
+
+config ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        bool
 
 config HAVE_MEMBLOCK_PHYS_MAP