Skip to content

Commit 8abddd9

Browse files
npigginmpe
authored andcommitted
powerpc/64s/radix: Enable huge vmalloc mappings
This reduces TLB misses by nearly 30x on a `git diff` workload on a 2-node POWER9 (59,800 -> 2,100) and reduces CPU cycles by 0.54%, due to vfs hashes being allocated with 2MB pages. Signed-off-by: Nicholas Piggin <[email protected]> Reviewed-by: Christophe Leroy <[email protected]> Acked-by: Michael Ellerman <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 562d1e2 commit 8abddd9

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,6 +3251,8 @@
32513251

32523252
nohugeiomap [KNL,X86,PPC,ARM64] Disable kernel huge I/O mappings.
32533253

3254+
nohugevmalloc [PPC] Disable kernel huge vmalloc mappings.
3255+
32543256
nosmt [KNL,S390] Disable symmetric multithreading (SMT).
32553257
Equivalent to smt=1.
32563258

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ config PPC
185185
select GENERIC_VDSO_TIME_NS
186186
select HAVE_ARCH_AUDITSYSCALL
187187
select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU
188+
select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP
188189
select HAVE_ARCH_JUMP_LABEL
189190
select HAVE_ARCH_JUMP_LABEL_RELATIVE
190191
select HAVE_ARCH_KASAN if PPC32 && PPC_PAGE_SHIFT <= 14

arch/powerpc/kernel/module.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/moduleloader.h>
99
#include <linux/err.h>
1010
#include <linux/vmalloc.h>
11+
#include <linux/mm.h>
1112
#include <linux/bug.h>
1213
#include <asm/module.h>
1314
#include <linux/uaccess.h>
@@ -88,17 +89,22 @@ int module_finalize(const Elf_Ehdr *hdr,
8889
return 0;
8990
}
9091

91-
#ifdef MODULES_VADDR
9292
static __always_inline void *
9393
__module_alloc(unsigned long size, unsigned long start, unsigned long end)
9494
{
95-
return __vmalloc_node_range(size, 1, start, end, GFP_KERNEL,
96-
PAGE_KERNEL_EXEC, VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
97-
__builtin_return_address(0));
95+
/*
96+
* Don't do huge page allocations for modules yet until more testing
97+
* is done. STRICT_MODULE_RWX may require extra work to support this
98+
* too.
99+
*/
100+
return __vmalloc_node_range(size, 1, start, end, GFP_KERNEL, PAGE_KERNEL_EXEC,
101+
VM_FLUSH_RESET_PERMS | VM_NO_HUGE_VMAP,
102+
NUMA_NO_NODE, __builtin_return_address(0));
98103
}
99104

100105
void *module_alloc(unsigned long size)
101106
{
107+
#ifdef MODULES_VADDR
102108
unsigned long limit = (unsigned long)_etext - SZ_32M;
103109
void *ptr = NULL;
104110

@@ -112,5 +118,7 @@ void *module_alloc(unsigned long size)
112118
ptr = __module_alloc(size, MODULES_VADDR, MODULES_END);
113119

114120
return ptr;
115-
}
121+
#else
122+
return __module_alloc(size, VMALLOC_START, VMALLOC_END);
116123
#endif
124+
}

0 commit comments

Comments
 (0)