]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/vmalloc: enable mapping of huge pages at pte level in vmalloc
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 2 Jun 2021 03:52:46 +0000 (13:52 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 2 Jun 2021 03:52:46 +0000 (13:52 +1000)
On some architectures like powerpc, there are huge pages that are mapped
at pte level.

Enable it in vmalloc.

For that, architectures can provide arch_vmap_pte_supported_shift() that
returns the shift for pages to map at pte level.

Link: https://lkml.kernel.org/r/2c717e3b1fba1894d890feb7669f83025bfa314d.1620795204.git.christophe.leroy@csgroup.eu
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
include/linux/vmalloc.h
mm/vmalloc.c

index 13c9b19ec923f39bff2ea49f5c7e8b5eef38124a..bf0a1b7a824e32dd21ac369aecaa211a40e09325 100644 (file)
@@ -112,6 +112,13 @@ static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, uns
 }
 #endif
 
+#ifndef arch_vmap_pte_supported_shift
+static inline int arch_vmap_pte_supported_shift(unsigned long size)
+{
+       return PAGE_SHIFT;
+}
+#endif
+
 /*
  *     Highlevel APIs for driver use
  */
index e23b67f37a6f7272a2a4369e44c3e12400a37b2b..46d48d2a444fa97a67318d8b9cd6c84cb9905a84 100644 (file)
@@ -2923,8 +2923,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
                return NULL;
        }
 
-       if (vmap_allow_huge && !(vm_flags & VM_NO_HUGE_VMAP) &&
-                       arch_vmap_pmd_supported(prot)) {
+       if (vmap_allow_huge && !(vm_flags & VM_NO_HUGE_VMAP)) {
                unsigned long size_per_node;
 
                /*
@@ -2937,11 +2936,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
                size_per_node = size;
                if (node == NUMA_NO_NODE)
                        size_per_node /= num_online_nodes();
-               if (size_per_node >= PMD_SIZE) {
+               if (arch_vmap_pmd_supported(prot) && size_per_node >= PMD_SIZE)
                        shift = PMD_SHIFT;
-                       align = max(real_align, 1UL << shift);
-                       size = ALIGN(real_size, 1UL << shift);
-               }
+               else
+                       shift = arch_vmap_pte_supported_shift(size_per_node);
+
+               align = max(real_align, 1UL << shift);
+               size = ALIGN(real_size, 1UL << shift);
        }
 
 again: