[PATCH RFC] rcu: torture: shorten the time between forward-progress tests

2023-05-02 Thread zhouzhouyi
From: Zhouyi Zhou 

Currently, default time between rcu torture forward-progress tests is 60HZ,
Under this configuration, false positive caused by __stack_chk_fail [1] is
difficult to reproduce (needs average 5*420 seconds for SRCU-P),
which means one has to invoke [2] 5 times in average to make [1] appear.

With time between rcu torture forward-progress tests be 1 HZ, above
phenomenon will be reproduced within 3 minutes, which means we can
reproduce [1] everytime we invoke [2].

Although [1] is a false positive, this change will make possible future
true bugs easier to be discovered.
   
[1] Link: 
https://lore.kernel.org/lkml/CAABZP2yS5=zuwezq7ihkv0wdm_hgo8k-teahyjrzhavzkda...@mail.gmail.com/T/
[2] tools/testing/selftests/rcutorture/bin/torture.sh

Tested in PPC VM of Opensource Lab of Oregon State Univerisity.

Signed-off-by: Zhouyi Zhou 
---
 tools/testing/selftests/rcutorture/configs/rcu/SRCU-N.boot  | 1 +
 tools/testing/selftests/rcutorture/configs/rcu/SRCU-P.boot  | 1 +
 tools/testing/selftests/rcutorture/configs/rcu/TRACE02.boot | 1 +
 tools/testing/selftests/rcutorture/configs/rcu/TREE02.boot  | 1 +
 tools/testing/selftests/rcutorture/configs/rcu/TREE10.boot  | 1 +
 5 files changed, 5 insertions(+)

diff --git a/tools/testing/selftests/rcutorture/configs/rcu/SRCU-N.boot 
b/tools/testing/selftests/rcutorture/configs/rcu/SRCU-N.boot
index ce0694fd9b92..982582bff041 100644
--- a/tools/testing/selftests/rcutorture/configs/rcu/SRCU-N.boot
+++ b/tools/testing/selftests/rcutorture/configs/rcu/SRCU-N.boot
@@ -1,2 +1,3 @@
 rcutorture.torture_type=srcu
 rcutorture.fwd_progress=3
+rcutorture.fwd_progress_holdoff=1
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/SRCU-P.boot 
b/tools/testing/selftests/rcutorture/configs/rcu/SRCU-P.boot
index 2db39f298d18..18f5d7361d8a 100644
--- a/tools/testing/selftests/rcutorture/configs/rcu/SRCU-P.boot
+++ b/tools/testing/selftests/rcutorture/configs/rcu/SRCU-P.boot
@@ -1,4 +1,5 @@
 rcutorture.torture_type=srcud
 rcupdate.rcu_self_test=1
 rcutorture.fwd_progress=3
+rcutorture.fwd_progress_holdoff=1
 srcutree.big_cpu_lim=5
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/TRACE02.boot 
b/tools/testing/selftests/rcutorture/configs/rcu/TRACE02.boot
index c70b5db6c2ae..b86bc7df7603 100644
--- a/tools/testing/selftests/rcutorture/configs/rcu/TRACE02.boot
+++ b/tools/testing/selftests/rcutorture/configs/rcu/TRACE02.boot
@@ -1,2 +1,3 @@
 rcutorture.torture_type=tasks-tracing
 rcutorture.fwd_progress=2
+rcutorture.fwd_progress_holdoff=1
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/TREE02.boot 
b/tools/testing/selftests/rcutorture/configs/rcu/TREE02.boot
index dd914fa8f690..933302f885df 100644
--- a/tools/testing/selftests/rcutorture/configs/rcu/TREE02.boot
+++ b/tools/testing/selftests/rcutorture/configs/rcu/TREE02.boot
@@ -1 +1,2 @@
 rcutorture.fwd_progress=2
+rcutorture.fwd_progress_holdoff=1
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/TREE10.boot 
b/tools/testing/selftests/rcutorture/configs/rcu/TREE10.boot
index dd914fa8f690..933302f885df 100644
--- a/tools/testing/selftests/rcutorture/configs/rcu/TREE10.boot
+++ b/tools/testing/selftests/rcutorture/configs/rcu/TREE10.boot
@@ -1 +1,2 @@
 rcutorture.fwd_progress=2
+rcutorture.fwd_progress_holdoff=1
-- 
2.34.1



[PATCH] rcu: torture: ppc: Remove duplicated argument --enable-kvm

2023-03-25 Thread zhouzhouyi
From: Zhouyi Zhou 

The argument --enable-kvm is duplicated because qemu_args
in kvm-test-1-run.sh has already give this.
  
Signed-off-by: Zhouyi Zhou 
---
Dear RCU and PPC developers

I discover this possible minor flaw when I am performing RCU torture
test in PPC VM of of Open Source Lab of Oregon State University.

But I can't test my patch because I am in a VM.

Thanks for your time

Cheers ;-)
Zhouyi   
--
 tools/testing/selftests/rcutorture/bin/functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rcutorture/bin/functions.sh 
b/tools/testing/selftests/rcutorture/bin/functions.sh
index b52d5069563c..48b9147e8c91 100644
--- a/tools/testing/selftests/rcutorture/bin/functions.sh
+++ b/tools/testing/selftests/rcutorture/bin/functions.sh
@@ -250,7 +250,7 @@ identify_qemu_args () {
echo -machine virt,gic-version=host -cpu host
;;
qemu-system-ppc64)
-   echo -enable-kvm -M pseries -nodefaults
+   echo -M pseries -nodefaults
echo -device spapr-vscsi
if test -n "$TORTURE_QEMU_INTERACTIVE" -a -n "$TORTURE_QEMU_MAC"
then
-- 
2.34.1



[PATCH linux-next v2] powerpc: init jump label early in ppc 64

2022-07-25 Thread zhouzhouyi
From: Zhouyi Zhou 

In ppc 64, invoke jump_label_init in setup_feature_keys is too late
because static key will be used in subroutine of parse_early_param
which is again subroutine of early_init_devtree.

So we invoke jump_label_init just before parse_early_param in
early_init_devtree. 

Suggested-by: Michael Ellerman 
Signed-off-by: Zhouyi Zhou 
---
Dear PPC developers

I found this bug when trying to do rcutorture tests in ppc VM of
Open Source Lab of Oregon State University.

qemu-system-ppc64 -nographic -smp cores=8,threads=1 -net none -M pseries 
-nodefaults -device spapr-vscsi -serial 
file:/home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/console.log
 -m 512 -kernel 
/home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/vmlinux
 -append "debug_boot_weak_hash panic=-1 console=ttyS0 
rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot 
rcupdate.rcu_task_stall_timeout=3 rcutorture.onoff_interval=200 
rcutorture.onoff_holdoff=30 rcutree.gp_preinit_delay=12 rcutree.gp_init_delay=3 
rcutree.gp_cleanup_delay=3 rcutree.kthread_prio=2 threadirqs tree.use_softirq=0 
rcutorture.n_barrier_cbs=4 rcutorture.stat_interval=15 
rcutorture.shutdown_secs=420 rcutorture.test_no_idle_hz=1 rcutorture.verbose=1"

console.log report following WARN:
[0.00][T0] static_key_enable_cpuslocked(): static key 
'0xc2953260' used before call to jump_label_init()^M
[0.00][T0] WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:166 
static_key_enable_cpuslocked+0xfc/0x120^M
[0.00][T0] Modules linked in:^M
[0.00][T0] CPU: 0 PID: 0 Comm: swapper Not tainted 
5.19.0-rc5-next-20220708-dirty #131^M
[0.00][T0] NIP:  c038068c LR: c0380688 CTR: 
c0186ac0^M
[0.00][T0] REGS: c2867930 TRAP: 0700   Not tainted  
(5.19.0-rc5-next-20220708-dirty)^M
[0.00][T0] MSR:  80022003   CR: 24282224  XER: 
2004^M
[0.00][T0] CFAR: 0730 IRQMASK: 1 ^M
[0.00][T0] GPR00: c0380688 c2867bd0 
c2868d00 0065 ^M
[0.00][T0] GPR04: 0001  
0080 000d ^M
[0.00][T0] GPR08:   
c27fd000 000f ^M
[0.00][T0] GPR12: c0186ac0 c2082280 
0003 000d ^M
[0.00][T0] GPR16: 02cc00d0  
c2082280 0001 ^M
[0.00][T0] GPR20: c2080942  
  ^M
[0.00][T0] GPR24:  c10d6168 
 c20034c8 ^M
[0.00][T0] GPR28: 0028  
c2080942 c2953260 ^M
[0.00][T0] NIP [c038068c] 
static_key_enable_cpuslocked+0xfc/0x120^M
[0.00][T0] LR [c0380688] 
static_key_enable_cpuslocked+0xf8/0x120^M
[0.00][T0] Call Trace:^M
[0.00][T0] [c2867bd0] [c0380688] 
static_key_enable_cpuslocked+0xf8/0x120 (unreliable)^M
[0.00][T0] [c2867c40] [c0380810] 
static_key_enable+0x30/0x50^M
[0.00][T0] [c2867c70] [c2030314] 
setup_forced_irqthreads+0x28/0x40^M
[0.00][T0] [c2867c90] [c2003568] 
do_early_param+0xa0/0x108^M
[0.00][T0] [c2867d10] [c0175340] 
parse_args+0x290/0x4e0^M
[0.00][T0] [c2867e10] [c2003c74] 
parse_early_options+0x48/0x5c^M
[0.00][T0] [c2867e30] [c2003ce0] 
parse_early_param+0x58/0x84^M
[0.00][T0] [c2867e60] [c2009878] 
early_init_devtree+0xd4/0x518^M
[0.00][T0] [c2867f10] [c200aee0] 
early_setup+0xb4/0x214^M

After this fix, the WARN does not show again.

Kind Regards
Zhouyi
--
 arch/powerpc/kernel/prom.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 1066b072db35..bfe170ed6b12 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -751,7 +751,13 @@ void __init early_init_devtree(void *params)
early_init_dt_scan_root();
early_init_dt_scan_memory_ppc();
 
+   /*
+* As generic code authors expect to be able to use static keys
+* in early_param() handlers, we initialize the static keys just
+* before parsing early params (it's fine to call jump_label_init
+* more than once).
+*/
+   jump_label_init();
parse_early_param();
 
/* make sure we've parsed cmdline for mem= before this */
-- 
2.25.1



[PATCH linux-next] powerpc: init jump label early in ppc 64

2022-07-23 Thread zhouzhouyi
From: Zhouyi Zhou 

In ppc 64, invoke jump_label_init in setup_feature_keys is too late
because static key will be used in subroutine of early_init_devtree.

So we can invoke jump_label_init earlier in early_setup.
We can not move setup_feature_keys backward because its subroutine
cpu_feature_keys_init depend on data structures initialized in
early_init_devtree.

Signed-off-by: Zhouyi Zhou 
---
Dear PPC developers

I found this bug when trying to do rcutorture tests in ppc VM of
Open Source Lab of Oregon State University.

qemu-system-ppc64 -nographic -smp cores=8,threads=1 -net none -M pseries 
-nodefaults -device spapr-vscsi -serial 
file:/home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/console.log
 -m 512 -kernel 
/home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/vmlinux
 -append "debug_boot_weak_hash panic=-1 console=ttyS0 
rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot 
rcupdate.rcu_task_stall_timeout=3 rcutorture.onoff_interval=200 
rcutorture.onoff_holdoff=30 rcutree.gp_preinit_delay=12 rcutree.gp_init_delay=3 
rcutree.gp_cleanup_delay=3 rcutree.kthread_prio=2 threadirqs tree.use_softirq=0 
rcutorture.n_barrier_cbs=4 rcutorture.stat_interval=15 
rcutorture.shutdown_secs=420 rcutorture.test_no_idle_hz=1 rcutorture.verbose=1"

console.log report following WARN:
[0.00][T0] static_key_enable_cpuslocked(): static key 
'0xc2953260' used before call to jump_label_init()^M
[0.00][T0] WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:166 
static_key_enable_cpuslocked+0xfc/0x120^M
[0.00][T0] Modules linked in:^M
[0.00][T0] CPU: 0 PID: 0 Comm: swapper Not tainted 
5.19.0-rc5-next-20220708-dirty #131^M
[0.00][T0] NIP:  c038068c LR: c0380688 CTR: 
c0186ac0^M
[0.00][T0] REGS: c2867930 TRAP: 0700   Not tainted  
(5.19.0-rc5-next-20220708-dirty)^M
[0.00][T0] MSR:  80022003   CR: 24282224  XER: 
2004^M
[0.00][T0] CFAR: 0730 IRQMASK: 1 ^M
[0.00][T0] GPR00: c0380688 c2867bd0 
c2868d00 0065 ^M
[0.00][T0] GPR04: 0001  
0080 000d ^M
[0.00][T0] GPR08:   
c27fd000 000f ^M
[0.00][T0] GPR12: c0186ac0 c2082280 
0003 000d ^M
[0.00][T0] GPR16: 02cc00d0  
c2082280 0001 ^M
[0.00][T0] GPR20: c2080942  
  ^M
[0.00][T0] GPR24:  c10d6168 
 c20034c8 ^M
[0.00][T0] GPR28: 0028  
c2080942 c2953260 ^M
[0.00][T0] NIP [c038068c] 
static_key_enable_cpuslocked+0xfc/0x120^M
[0.00][T0] LR [c0380688] 
static_key_enable_cpuslocked+0xf8/0x120^M
[0.00][T0] Call Trace:^M
[0.00][T0] [c2867bd0] [c0380688] 
static_key_enable_cpuslocked+0xf8/0x120 (unreliable)^M
[0.00][T0] [c2867c40] [c0380810] 
static_key_enable+0x30/0x50^M
[0.00][T0] [c2867c70] [c2030314] 
setup_forced_irqthreads+0x28/0x40^M
[0.00][T0] [c2867c90] [c2003568] 
do_early_param+0xa0/0x108^M
[0.00][T0] [c2867d10] [c0175340] 
parse_args+0x290/0x4e0^M
[0.00][T0] [c2867e10] [c2003c74] 
parse_early_options+0x48/0x5c^M
[0.00][T0] [c2867e30] [c2003ce0] 
parse_early_param+0x58/0x84^M
[0.00][T0] [c2867e60] [c2009878] 
early_init_devtree+0xd4/0x518^M
[0.00][T0] [c2867f10] [c200aee0] 
early_setup+0xb4/0x214^M

After this fix, the WARN does not show again.

Kind Regards
Zhouyi
--
 arch/powerpc/kernel/setup_64.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 2b2d0b0fbb30..bf2fb76221da 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -365,6 +365,9 @@ void __init early_setup(unsigned long dt_ptr)
 
udbg_printf(" -> %s(), dt_ptr: 0x%lx\n", __func__, dt_ptr);
 
+   /* Initialise jump label because subsequent calls need it */
+   jump_label_init();
+
/*
 * Do early initialization using the flattened device
 * tree, such as retrieving the physical memory map or
@@ -394,8 +397,15 @@ void __init early_setup(unsigned long dt_ptr)
 
/* Apply all the dynamic patching */
apply_feature_fixups();
-   setup_feature_keys();
+
+   /*
+* 

re: ping: re:[PATCH 1/1] kernel code that do not handle NULL return of kmem_cache_zalloc

2013-12-01 Thread zhouzhouyi
From: Zhouyi Zhou zhouzho...@gmail.com

the text of previous ping message maybe garbled sorry for the trouble

 I do a grep for kmem_cache_zalloc and kmem_cache_alloc
 in kernel tree, and find some code do not handle NULL
 return of kmem_cache_zalloc correctly


 Signed-off-by: Zhouyi Zhou yizhouz...@ict.ac.cn
---
 arch/powerpc/kvm/book3s_32_mmu_host.c |5 +
 drivers/iommu/omap-iommu.c|3 ++-
 fs/jffs2/malloc.c |4 
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c 
b/arch/powerpc/kvm/book3s_32_mmu_host.c
index 3a0abd2..5fac89d 100644
--- a/arch/powerpc/kvm/book3s_32_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_32_mmu_host.c
@@ -243,6 +243,11 @@ next_pteg:
/* Now tell our Shadow PTE code about the new page */
 
pte = kvmppc_mmu_hpte_cache_next(vcpu);
+   if (!pte) {
+   kvm_release_pfn_clean(hpaddr  PAGE_SHIFT);
+   r = -EAGAIN;
+   goto out;
+   }
 
dprintk_mmu(KVM: %c%c Map 0x%llx: [%lx] 0x%llx (0x%llx) - %lx\n,
orig_pte-may_write ? 'w' : '-',
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index bcd78a7..5155714 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -551,7 +551,8 @@ static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, 
u32 da)
dev_vdbg(obj-dev, %s: a new pte:%p\n, __func__, iopte);
} else {
/* We raced, free the reduniovant table */
-   iopte_free(iopte);
+   if (iopte)
+   iopte_free(iopte);
}
 
 pte_ready:
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c
index 4f47aa2..58e2336 100644
--- a/fs/jffs2/malloc.c
+++ b/fs/jffs2/malloc.c
@@ -287,6 +287,8 @@ struct jffs2_xattr_datum *jffs2_alloc_xattr_datum(void)
 {
struct jffs2_xattr_datum *xd;
xd = kmem_cache_zalloc(xattr_datum_cache, GFP_KERNEL);
+   if (!xd)
+   return NULL;
dbg_memalloc(%p\n, xd);
 
xd-class = RAWNODE_CLASS_XATTR_DATUM;
@@ -305,6 +307,8 @@ struct jffs2_xattr_ref *jffs2_alloc_xattr_ref(void)
 {
struct jffs2_xattr_ref *ref;
ref = kmem_cache_zalloc(xattr_ref_cache, GFP_KERNEL);
+   if (!ref)
+   return NULL;
dbg_memalloc(%p\n, ref);
 
ref-class = RAWNODE_CLASS_XATTR_REF;
-- 
1.7.10.4

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev