powerpc/64s/radix: Enable huge vmalloc mappings
Subsystems (2)
Nicholas Piggin
reviewerPATCH 1/1 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.
---
This was in the -mm tree but was dropped at the last minute after clashing with a patch in powerpc next.
Now all prerequisites are upstream, this can be merged as is. Probably makes sense now to go via powerpc tree.
This is rebased and retested on upstream.
Documentation/admin-guide/kernel-parameters.txt | 2 ++ arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/pgtable.h | 5 +++++ arch/powerpc/kernel/module.c | 16 +++++++++++++--- 4 files changed, 21 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +2 -0
@@ -3250,6 +3250,8 @@ nohugeiomap [KNL,X86,PPC,ARM64] Disable kernel huge I/O mappings. + nohugevmalloc [PPC] Disable kernel huge vmalloc mappings. + nosmt [KNL,S390] Disable symmetric multithreading (SMT). Equivalent to smt=1.
arch/powerpc/Kconfig +1 -0
@@ -185,6 +185,7 @@ config PPC select GENERIC_VDSO_TIME_NS select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU + select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_JUMP_LABEL_RELATIVE select HAVE_ARCH_KASAN if PPC32 && PPC_PAGE_SHIFT <= 14
arch/powerpc/include/asm/pgtable.h +5 -0
@@ -39,6 +39,11 @@ struct mm_struct;#define __S110 PAGE_SHARED_X#define __S111 PAGE_SHARED_X +#ifndef MODULES_VADDR +#define MODULES_VADDR VMALLOC_START +#define MODULES_END VMALLOC_END +#endif +#ifndef __ASSEMBLY__/* Keep these as a macros to avoid include dependency mess */
arch/powerpc/kernel/module.c +13 -3
@@ -8,6 +8,7 @@#include <linux/moduleloader.h> #include <linux/err.h> #include <linux/vmalloc.h> +#include <linux/mm.h> #include <linux/bug.h> #include <asm/module.h> #include <linux/uaccess.h>
@@ -88,17 +89,24 @@ int module_finalize(const Elf_Ehdr *hdr,return 0 ; } -#ifdef MODULES_VADDR static __always_inline void *__module_alloc (unsigned long size,unsigned long start,unsigned long end) { +/* +* Don't do huge page allocations for modules yet until more testing +* is done. STRICT_MODULE_RWX may require extra work to support this +* too. +*/ return __vmalloc_node_range (size,1 , start, end,GFP_KERNEL , -PAGE_KERNEL_EXEC ,VM_FLUSH_RESET_PERMS ,NUMA_NO_NODE , +PAGE_KERNEL_EXEC , +VM_FLUSH_RESET_PERMS |VM_NO_HUGE_VMAP , +NUMA_NO_NODE ,__builtin_return_address (0 )); }void *module_alloc (unsigned long size) { +#ifdef CONFIG_PPC32 unsigned long limit = (unsigned long )_etext -SZ_32M ;void *ptr =NULL ;
@@ -112,5 +120,7 @@ void *module_alloc(unsigned long size) ptr =__module_alloc (size,MODULES_VADDR ,MODULES_END );return ptr; -} +#else +return __module_alloc (size,MODULES_VADDR ,MODULES_END );#endif +}
Signature · 1 line
2.23.0
Le 02/05/2021 à 06:56, Nicholas Piggin a écrit :
Quoted 51 lines
This reduces TLB misses by nearly 30x on a
git diffworkload 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.Acked-by Michael Ellerman <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>---
This was in the -mm tree but was dropped at the last minute after clashing with a patch in powerpc next.Now all prerequisites are upstream, this can be merged as is. Probably makes sense now to go via powerpc tree.
This is rebased and retested on upstream.
Documentation/admin-guide/kernel-parameters.txt | 2 ++ arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/pgtable.h | 5 +++++ arch/powerpc/kernel/module.c | 16 +++++++++++++--- 4 files changed, 21 insertions(+), 3 deletions(-)Documentation/admin-guide/kernel-parameters.txt +2
-0@@ -3250,6 +3250,8 @@ nohugeiomap [KNL,X86,PPC,ARM64] Disable kernel huge I/O mappings. + nohugevmalloc [PPC] Disable kernel huge vmalloc mappings. + nosmt [KNL,S390] Disable symmetric multithreading (SMT). Equivalent to smt=1.arch/powerpc/Kconfig +1
-0@@ -185,6 +185,7 @@ config PPC select GENERIC_VDSO_TIME_NS select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU + select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_JUMP_LABEL_RELATIVE select HAVE_ARCH_KASAN if PPC32 && PPC_PAGE_SHIFT <= 14arch/powerpc/include/asm/pgtable.h +0
-0
arch/powerpc/include/asm/pgtable.h struct mm_struct; · line 45
Quoted 7 lines
arch/powerpc/include/asm/pgtable.h +4
-0@@ -39,6 +39,11 @@ struct mm_struct;#define __S110 PAGE_SHARED_X#define __S111 PAGE_SHARED_X +#ifndef MODULES_VADDR +#define MODULES_VADDR VMALLOC_START +#define MODULES_END VMALLOC_END +#endif
This will also require some changes in a few places, see https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/
Quoted 25 lines
arch/powerpc/include/asm/pgtable.h +1
-0+#ifndef __ASSEMBLY__/* Keep these as a macros to avoid include dependency mess */ arch/powerpc/kernel/module.c +2
-1@@ -8,6 +8,7 @@#include <linux/moduleloader.h> #include <linux/err.h> #include <linux/vmalloc.h> +#include <linux/mm.h> #include <linux/bug.h> #include <asm/module.h> #include <linux/uaccess.h> @@ -88,17 +89,24 @@ int module_finalize(const Elf_Ehdr *hdr,return 0 ; } -#ifdef MODULES_VADDR static __always_inline void *__module_alloc (unsigned long size,unsigned long start,unsigned long end) { +/*
arch/powerpc/kernel/module.c int module_finalize(const Elf_Ehdr *hdr, · line 104
Quoted 10 lines
arch/powerpc/kernel/module.c +7
-1+* Don't do huge page allocations for modules yet until more testing +* is done. STRICT_MODULE_RWX may require extra work to support this +* too. +*/ return __vmalloc_node_range (size,1 , start, end,GFP_KERNEL , -PAGE_KERNEL_EXEC ,VM_FLUSH_RESET_PERMS ,NUMA_NO_NODE , +PAGE_KERNEL_EXEC , +VM_FLUSH_RESET_PERMS |VM_NO_HUGE_VMAP , +NUMA_NO_NODE ,__builtin_return_address (0 ));
Can we avoid so many lines ? Doesn't it fit on 3 lines now that 100 chars per line are tolerated ?
arch/powerpc/kernel/module.c int module_finalize(const Elf_Ehdr *hdr, · line 109
Quoted 5 lines
arch/powerpc/kernel/module.c +1
-0}void *module_alloc (unsigned long size) { +#ifdef CONFIG_PPC32
Can we just add an IS_ENABLED(CONFIG_PPC32) in the 'if' instead of this #ifdef/#else ?
Quoted 13 lines
arch/powerpc/kernel/module.c +3
-1unsigned long limit = (unsigned long )_etext -SZ_32M ;void *ptr =NULL ;@@ -112,5 +120,7 @@ void *module_alloc(unsigned long size) ptr =__module_alloc (size,MODULES_VADDR ,MODULES_END );return ptr; -} +#else +return __module_alloc (size,MODULES_VADDR ,MODULES_END );#endif +}
Nicholas Piggin
reviewerExcerpts from Christophe Leroy's message of May 2, 2021 5:34 pm:
Quoted 57 lines
Le 02/05/2021 à 06:56, Nicholas Piggin a écrit :
Quoted 54 lines
This reduces TLB misses by nearly 30x on a
git diffworkload 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.Acked-by Michael Ellerman <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>---
This was in the -mm tree but was dropped at the last minute after clashing with a patch in powerpc next.Now all prerequisites are upstream, this can be merged as is. Probably makes sense now to go via powerpc tree.
This is rebased and retested on upstream.
Documentation/admin-guide/kernel-parameters.txt | 2 ++ arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/pgtable.h | 5 +++++ arch/powerpc/kernel/module.c | 16 +++++++++++++--- 4 files changed, 21 insertions(+), 3 deletions(-)Documentation/admin-guide/kernel-parameters.txt +2
-0@@ -3250,6 +3250,8 @@ nohugeiomap [KNL,X86,PPC,ARM64] Disable kernel huge I/O mappings. + nohugevmalloc [PPC] Disable kernel huge vmalloc mappings. + nosmt [KNL,S390] Disable symmetric multithreading (SMT). Equivalent to smt=1.arch/powerpc/Kconfig +1
-0@@ -185,6 +185,7 @@ config PPC select GENERIC_VDSO_TIME_NS select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU + select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_JUMP_LABEL_RELATIVE select HAVE_ARCH_KASAN if PPC32 && PPC_PAGE_SHIFT <= 14arch/powerpc/include/asm/pgtable.h +0
-0@@ -39,6 +39,11 @@ struct mm_struct;#define __S110 PAGE_SHARED_X#define __S111 PAGE_SHARED_X
Quoted 7 lines
arch/powerpc/include/asm/pgtable.h struct mm_struct; · line 45
Quoted 4 lines
arch/powerpc/include/asm/pgtable.h +4
-0+#ifndef MODULES_VADDR +#define MODULES_VADDR VMALLOC_START +#define MODULES_END VMALLOC_END +#endif This will also require some changes in a few places, see
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/
I see.
I'll just make the PPC64 version use VMALLOC_START/VMALLOC_END, which avoids that stupid compiler warning found by kbuild robot as well.
Quoted 30 lines
Quoted 30 lines
arch/powerpc/include/asm/pgtable.h +1
-0+#ifndef __ASSEMBLY__/* Keep these as a macros to avoid include dependency mess */ arch/powerpc/kernel/module.c +6
-1@@ -8,6 +8,7 @@#include <linux/moduleloader.h> #include <linux/err.h> #include <linux/vmalloc.h> +#include <linux/mm.h> #include <linux/bug.h> #include <asm/module.h> #include <linux/uaccess.h> @@ -88,17 +89,24 @@ int module_finalize(const Elf_Ehdr *hdr,return 0 ; } -#ifdef MODULES_VADDR static __always_inline void *__module_alloc (unsigned long size,unsigned long start,unsigned long end) { +/* +* Don't do huge page allocations for modules yet until more testing +* is done. STRICT_MODULE_RWX may require extra work to support this +* too. +*/
Quoted 8 lines
arch/powerpc/kernel/module.c int module_finalize(const Elf_Ehdr *hdr, · line 104
Quoted 6 lines
arch/powerpc/kernel/module.c +3
-1return __vmalloc_node_range (size,1 , start, end,GFP_KERNEL , -PAGE_KERNEL_EXEC ,VM_FLUSH_RESET_PERMS ,NUMA_NO_NODE , +PAGE_KERNEL_EXEC , +VM_FLUSH_RESET_PERMS |VM_NO_HUGE_VMAP , +NUMA_NO_NODE ,__builtin_return_address (0 ));Can we avoid so many lines ? Doesn't it fit on 3 lines now that 100 chars per line are tolerated ?
It could be squashed onto fewer lines. Is it better?
Quoted 8 lines
arch/powerpc/kernel/module.c int module_finalize(const Elf_Ehdr *hdr, · line 109
Quoted 6 lines
arch/powerpc/kernel/module.c +1
-0}void *module_alloc (unsigned long size) { +#ifdef CONFIG_PPC32 Can we just add an
IS_ENABLED(CONFIG_PPC32)in the 'if' instead of this #ifdef/#else ?
I guess not if I don't define MODULES_VADDR. Jordan's clenup patch could change it to IS_ENABLED.
Thanks,
Nick
Quoted 15 lines
Quoted 14 lines
arch/powerpc/kernel/module.c +3
-1unsigned long limit = (unsigned long )_etext -SZ_32M ;void *ptr =NULL ;@@ -112,5 +120,7 @@ void *module_alloc(unsigned long size) ptr =__module_alloc (size,MODULES_VADDR ,MODULES_END );return ptr; -} +#else +return __module_alloc (size,MODULES_VADDR ,MODULES_END );#endif +}
kernel test robot
build botI love your patch! Perhaps something to improve:
Hi Nicholas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on powerpc/next]
[also build test WARNING on linus/master next-20210430] [cannot apply to v5.12]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Nicholas-Piggin/powerpc-64s-radix-Enable-huge-vmalloc-mappings/20210502-125808 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc-randconfig-r013-20210502 (attached as .config) compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/1c8b90cff6679d7690891101efc07a1edd98e9a7
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nicholas-Piggin/powerpc-64s-radix-Enable-huge-vmalloc-mappings/20210502-125808 git checkout 1c8b90cff6679d7690891101efc07a1edd98e9a7
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=powerpc
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from arch/powerpc/include/asm/nohash/mmu.h:16,
from arch/powerpc/include/asm/mmu.h:423,
from arch/powerpc/kernel/head_8xx.S:23:
>> arch/powerpc/include/asm/nohash/32/mmu-8xx.h:175: warning: "MODULES_VADDR" redefined
175 | #define MODULES_VADDR (PAGE_OFFSET - SZ_256M)
|
In file included from include/linux/pgtable.h:6,
from arch/powerpc/kernel/head_8xx.S:19:
arch/powerpc/include/asm/pgtable.h:43: note: this is the location of the previous definition
43 | #define MODULES_VADDR VMALLOC_START
|
In file included from arch/powerpc/include/asm/nohash/mmu.h:16,
from arch/powerpc/include/asm/mmu.h:423,
from arch/powerpc/kernel/head_8xx.S:23:
>> arch/powerpc/include/asm/nohash/32/mmu-8xx.h:176: warning: "MODULES_END" redefined
176 | #define MODULES_END PAGE_OFFSET
|
In file included from include/linux/pgtable.h:6,
from arch/powerpc/kernel/head_8xx.S:19: arch/powerpc/include/asm/pgtable.h:44: note: this is the location of the previous definition
44 | #define MODULES_END VMALLOC_END
|
vim +/MODULES_VADDR +175 arch/powerpc/include/asm/nohash/32/mmu-8xx.h
fca5c1e9eb5e26 Christophe Leroy 2019-04-25 1749132a2e82adc6e Christophe Leroy 2021-04-01 @175 #define MODULES_VADDR (PAGE_OFFSET - SZ_256M)9132a2e82adc6e Christophe Leroy 2021-04-01 @176 #define MODULES_END PAGE_OFFSET9132a2e82adc6e Christophe Leroy 2021-04-01 177
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botI love your patch! Perhaps something to improve:
Hi Nicholas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on powerpc/next]
[also build test WARNING on linus/master next-20210430] [cannot apply to scottwood/next v5.12]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Nicholas-Piggin/powerpc-64s-radix-Enable-huge-vmalloc-mappings/20210502-125808 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc64-defconfig (attached as .config) compiler: powerpc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/1c8b90cff6679d7690891101efc07a1edd98e9a7
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nicholas-Piggin/powerpc-64s-radix-Enable-huge-vmalloc-mappings/20210502-125808 git checkout 1c8b90cff6679d7690891101efc07a1edd98e9a7
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=powerpc64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
fs/proc/kcore.c: In function 'add_modules_range':
>> fs/proc/kcore.c:626:20: warning: self-comparison always evaluates to false [-Wtautological-compare]
626 | if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) {
| ^~
fs/proc/kcore.c:626:52: warning: self-comparison always evaluates to false [-Wtautological-compare]
626 | if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) {
| ^~vim +626 fs/proc/kcore.c
9492587cf35d37 KAMEZAWA Hiroyuki 2009-09-22 618
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 619 #if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 620 /*
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 621 * MODULES_VADDR has no intersection with VMALLOC_ADDR.
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 622 */
eebf36480678f9 YueHaibing 2019-03-28 623 static struct kcore_list kcore_modules;
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 624 static void __init add_modules_range(void)
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 625 {
bf3e2692468fe4 Baoquan He 2014-10-09 @626 if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) {
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 627 kclist_add(&kcore_modules, (void *)MODULES_VADDR,
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 628 MODULES_END - MODULES_VADDR, KCORE_VMALLOC);
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 629 }
bf3e2692468fe4 Baoquan He 2014-10-09 630 }
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 631 #else
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 632 static void __init add_modules_range(void)
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 633 {
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 634 }
81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 635 #endif81ac3ad9061dd9 KAMEZAWA Hiroyuki 2009-09-22 636
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org