Skip to contentSkip to conversation

powerpc/64s/hash: add torture_segments kernel boot option to increase SLB faults

PATCH New Nicholas Piggin 2 participants 2 messages Mar 20, 2020

Subsystems (2)
lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 1/1 powerpc/64s/hash: add torture_segments kernel boot option to increase SLB faults

This option increases the number of SLB misses by limiting the number of kernel SLB entries, and increased flushing of cached lookaside information. This helps stress test difficult to hit paths in the kernel.

---
 .../admin-guide/kernel-parameters.txt         |   4 +
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |   7 +
 arch/powerpc/mm/book3s64/hash_utils.c         |  13 ++
 arch/powerpc/mm/book3s64/slb.c                | 145 ++++++++++++------
 4 files changed, 124 insertions(+), 45 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +4 -0
index dbc22d684627..cd3ea9f0c6b1 100644
@@ -861,6 +861,10 @@
 			can be useful when debugging issues that require an SLB
 			miss to occur.
 
+	torture_segments [PPC]
+			Limits the number of SLB entries used, and flushes
+			them frequently to stress SLB faults.
+
 	disable=	[IPV6]
 			See Documentation/networking/ipv6.txt.
 
arch/powerpc/include/asm/book3s/64/mmu-hash.h +7 -0
index 3fa1b962dc27..de34bf94f38c 100644
@@ -317,6 +317,13 @@ extern unsigned long tce_alloc_start, tce_alloc_end;
  */
 extern int mmu_ci_restrictions;
 
+extern bool torture_segments_enabled;
+DECLARE_STATIC_KEY_FALSE(torture_segments_key);
+static inline bool torture_segments(void)
+{
+	return static_branch_unlikely(&torture_segments_key);
+}
+
 /*
  * This computes the AVPN and B fields of the first dword of a HPTE,
  * for use when we want to match an existing PTE.  The bottom 7 bits
arch/powerpc/mm/book3s64/hash_utils.c +13 -0
index 523d4d39d11e..1e5028e22aae 100644
@@ -354,6 +354,7 @@ int htab_remove_mapping(unsigned long vstart, unsigned long vend,
 }
 
 static bool disable_1tb_segments = false;
+bool torture_segments_enabled __read_mostly = false;
 
 static int __init parse_disable_1tb_segments(char *p)
 {
@@ -362,6 +363,13 @@ static int __init parse_disable_1tb_segments(char *p)
 }
 early_param("disable_1tb_segments", parse_disable_1tb_segments);
 
+static int __init parse_torture_segments(char *p)
+{
+	torture_segments_enabled = true;
+	return 0;
+}
+early_param("torture_segments", parse_torture_segments);
+
 static int __init htab_dt_scan_seg_sizes(unsigned long node,
 					 const char *uname, int depth,
 					 void *data)
@@ -853,6 +861,8 @@ static void __init hash_init_partition_table(phys_addr_t hash_table,
 	pr_info("Partition table %p\n", partition_tb);
 }
 
+DEFINE_STATIC_KEY_FALSE(torture_segments_key);
+
 static void __init htab_initialize(void)
 {
 	unsigned long table;
@@ -869,6 +879,9 @@ static void __init htab_initialize(void)
 		printk(KERN_INFO "Using 1TB segments\n");
 	}
 
+	if (torture_segments_enabled)
+		static_branch_enable(&torture_segments_key);
+
 	/*
 	 * Calculate the required size of the htab.  We want the number of
 	 * PTEGs to equal one half the number of real pages.
arch/powerpc/mm/book3s64/slb.c +100 -45

221 lines not on this page · raw message

Signature · 1 line
2.23.0
#1 lore raw
I love your patch! Yet something to improve:

Hi Nicholas,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on linus/master scottwood/next v5.6-rc6 next-20200320] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Nicholas-Piggin/powerpc-64s-hash-add-torture_segments-kernel-boot-option-to-increase-SLB-faults/20200321-033721
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-cell_defconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=powerpc

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

In file included from arch/powerpc/include/asm/book3s/64/mmu.h:46,
from arch/powerpc/include/asm/mmu.h:356, from arch/powerpc/include/asm/lppaca.h:47, from arch/powerpc/include/asm/paca.h:17, from arch/powerpc/include/asm/current.h:13, from include/linux/thread_info.h:21,
from include/asm-generic/preempt.h:5,
from ./arch/powerpc/include/generated/asm/preempt.h:1, from include/linux/preempt.h:78,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from include/linux/compat.h:10,
from arch/powerpc/kernel/asm-offsets.c:14:

>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:321:1: warning: data definition has no type or storage class
     321 | DECLARE_STATIC_KEY_FALSE(torture_segments_key);
         | ^~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:321:1: error: type defaults to 'int' in declaration of 'DECLARE_STATIC_KEY_FALSE' [-Werror=implicit-int]
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:321:1: warning: parameter names (without types) in function declaration
   arch/powerpc/include/asm/book3s/64/mmu-hash.h: In function 'torture_segments':
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:324:9: error: implicit declaration of function 'static_branch_unlikely' [-Werror=implicit-function-declaration]
     324 |  return static_branch_unlikely(&torture_segments_key);
         |         ^~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/book3s/64/mmu-hash.h:324:33: error: 'torture_segments_key' undeclared (first use in this function); did you mean 'torture_segments'?
     324 |  return static_branch_unlikely(&torture_segments_key);
         |                                 ^~~~~~~~~~~~~~~~~~~~
         |                                 torture_segments

arch/powerpc/include/asm/book3s/64/mmu-hash.h:324:33: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:101: arch/powerpc/kernel/asm-offsets.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1112: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:179: sub-make] Error 2
43 real 6 user 10 sys 37.29% cpu make prepare

vim +321 arch/powerpc/include/asm/book3s/64/mmu-hash.h

319
320 extern bool torture_segments_enabled;

 > 321	DECLARE_STATIC_KEY_FALSE(torture_segments_key);
   322	static inline bool torture_segments(void)
   323	{
 > 324		return static_branch_unlikely(&torture_segments_key);

325 }
326

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org