Skip to contentSkip to conversation

rcutorture: Convert schedule_timeout_uninterruptible() to mdelay() in rcu_torture_stall()

PATCH Superseded Zqiang 2 participants 2 messages Mar 20, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zqiang

author
#0 lore raw

PATCH 1/1 rcutorture: Convert schedule_timeout_uninterruptible() to mdelay() in rcu_torture_stall()

For kernels built with enable PREEMPT_NONE and CONFIG_DEBUG_ATOMIC_SLEEP, running the RCU stall tests.

runqemu kvm slirp nographic qemuparams="-m 1024 -smp 4" bootparams="nokaslr console=ttyS0 rcutorture.stall_cpu=30 rcutorture.stall_no_softlockup=1 rcutorture.stall_cpu_irqsoff=1 rcutorture.stall_cpu_block=1" -d

[   10.841071] rcu-torture: rcu_torture_stall begin CPU stall
[   10.841073] rcu_torture_stall start on CPU 3.
[   10.841077] BUG: scheduling while atomic: rcu_torture_sta/66/0x0000000
....
[   10.841108] Call Trace:
[   10.841110]  <TASK>
[   10.841112]  dump_stack_lvl+0x64/0xb0
[   10.841118]  dump_stack+0x10/0x20
[   10.841121]  __schedule_bug+0x8b/0xb0
[   10.841126]  __schedule+0x2172/0x2940
[   10.841157]  schedule+0x9b/0x150
[   10.841160]  schedule_timeout+0x2e8/0x4f0
[   10.841192]  schedule_timeout_uninterruptible+0x47/0x50
[   10.841195]  rcu_torture_stall+0x2e8/0x300
[   10.841199]  kthread+0x175/0x1a0
[   10.841206]  ret_from_fork+0x2c/0x50

The above calltrace occurs in the local_irq_disable/enable() critical section call schedule_timeout(), and invoke schedule_timeout() also implies a quiescent state, of course it also fails to trigger RCU stall, this commit therefore use mdelay() instead of schedule_timeout() to trigger RCU stall.

---
 kernel/rcu/rcutorture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcutorture.c +1 -1
index d06c2da04c34..fe4f5a4074e3 100644
@@ -2472,7 +2472,7 @@ static int rcu_torture_stall(void *args)
 #ifdef CONFIG_PREEMPTION
 				preempt_schedule();
 #else
-				schedule_timeout_uninterruptible(HZ);
+				mdelay(HZ);
 #endif
 			} else if (stall_no_softlockup) {
 				touch_softlockup_watchdog();
Signature · 1 line
2.25.1
#1 lore raw
Quoted 42 lines · Zqiang

For kernels built with enable PREEMPT_NONE and CONFIG_DEBUG_ATOMIC_SLEEP, running the RCU stall tests.

runqemu kvm slirp nographic qemuparams="-m 1024 -smp 4" bootparams="nokaslr console=ttyS0 rcutorture.stall_cpu=30 rcutorture.stall_no_softlockup=1 rcutorture.stall_cpu_irqsoff=1 rcutorture.stall_cpu_block=1" -d

[   10.841071] rcu-torture: rcu_torture_stall begin CPU stall
[   10.841073] rcu_torture_stall start on CPU 3.
[   10.841077] BUG: scheduling while atomic: rcu_torture_sta/66/0x0000000
....
[   10.841108] Call Trace:
[   10.841110]  <TASK>
[   10.841112]  dump_stack_lvl+0x64/0xb0
[   10.841118]  dump_stack+0x10/0x20
[   10.841121]  __schedule_bug+0x8b/0xb0
[   10.841126]  __schedule+0x2172/0x2940
[   10.841157]  schedule+0x9b/0x150
[   10.841160]  schedule_timeout+0x2e8/0x4f0
[   10.841192]  schedule_timeout_uninterruptible+0x47/0x50
[   10.841195]  rcu_torture_stall+0x2e8/0x300
[   10.841199]  kthread+0x175/0x1a0
[   10.841206]  ret_from_fork+0x2c/0x50

The above calltrace occurs in the local_irq_disable/enable() critical section call schedule_timeout(), and invoke schedule_timeout() also implies a quiescent state, of course it also fails to trigger RCU stall, this commit therefore use mdelay() instead of schedule_timeout() to trigger RCU stall.

---
 kernel/rcu/rcutorture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcutorture.c +0 -0
index d06c2da04c34..fe4f5a4074e3 100644

kernel/rcu/rcutorture.c static int rcu_torture_stall(void *args) · line 2475

Quoted 5 lines
kernel/rcu/rcutorture.c +1 -1
@@ -2472,7 +2472,7 @@ static int rcu_torture_stall(void *args)
 #ifdef CONFIG_PREEMPTION
                                preempt_schedule();
 #else
-                               schedule_timeout_uninterruptible(HZ);
+                               mdelay(HZ);

mdelay accepts milliseconds but HZ is jiffies correct? So this is broken for systems with HZ != 1000.

So you need to call mdelay(jiffies_to_msecs(HZ)) instead.

- Joel