Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/vmalloc: enable mapping of huge pages at pte level in vmalloc

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: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Christophe Leroy and committed by
Linus Torvalds
3382bbee f7ee1f13

+14 -6
+7
include/linux/vmalloc.h
··· 112 112 } 113 113 #endif 114 114 115 + #ifndef arch_vmap_pte_supported_shift 116 + static inline int arch_vmap_pte_supported_shift(unsigned long size) 117 + { 118 + return PAGE_SHIFT; 119 + } 120 + #endif 121 + 115 122 /* 116 123 * Highlevel APIs for driver use 117 124 */
+7 -6
mm/vmalloc.c
··· 2927 2927 return NULL; 2928 2928 } 2929 2929 2930 - if (vmap_allow_huge && !(vm_flags & VM_NO_HUGE_VMAP) && 2931 - arch_vmap_pmd_supported(prot)) { 2930 + if (vmap_allow_huge && !(vm_flags & VM_NO_HUGE_VMAP)) { 2932 2931 unsigned long size_per_node; 2933 2932 2934 2933 /* ··· 2940 2941 size_per_node = size; 2941 2942 if (node == NUMA_NO_NODE) 2942 2943 size_per_node /= num_online_nodes(); 2943 - if (size_per_node >= PMD_SIZE) { 2944 + if (arch_vmap_pmd_supported(prot) && size_per_node >= PMD_SIZE) 2944 2945 shift = PMD_SHIFT; 2945 - align = max(real_align, 1UL << shift); 2946 - size = ALIGN(real_size, 1UL << shift); 2947 - } 2946 + else 2947 + shift = arch_vmap_pte_supported_shift(size_per_node); 2948 + 2949 + align = max(real_align, 1UL << shift); 2950 + size = ALIGN(real_size, 1UL << shift); 2948 2951 } 2949 2952 2950 2953 again: