From: Frederic Weisbecker <>
Date: Tue, 5 Apr 2022 03:07:51 +0200
Subject: [PATCH] rcutorture: Also force sched priority to timersd on
 boosting test.

ksoftirqd is statically boosted to the priority level right above the
one of rcu_torture_boost() so that timers, which torture readers rely on,
get a chance to run while rcu_torture_boost() is polling.

However timers processing got split from ksoftirqd into their own kthread
(timersd) that isn't boosted. It has the same SCHED_FIFO low prio as
rcu_torture_boost() and therefore timers can't preempt it and may

The issue can be triggered in practice on v5.17.1-rt17 using:

	./ --allcpus --configs TREE04 --duration 10m --kconfig "CONFIG_EXPERT=y CONFIG_PREEMPT_RT=y"

Fix this with statically boosting timersd just like is done with
ksoftirqd in commit
   ea6d962e80b61 ("rcutorture: Judge RCU priority boosting on grace periods, not callbacks")

Suggested-by: Mel Gorman <>
Cc: Sebastian Andrzej Siewior <>
Cc: Thomas Gleixner <>
Signed-off-by: Frederic Weisbecker <>
Signed-off-by: Sebastian Andrzej Siewior <>
 include/linux/interrupt.h |    1 +
 kernel/rcu/rcutorture.c   |    6 ++++++
 kernel/softirq.c          |    2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

Index: linux-6.3.0-rt11/include/linux/interrupt.h
@ linux-6.3.0-rt11/include/linux/interrupt.h:609 @ extern void raise_softirq_irqoff(unsigne
 extern void raise_softirq(unsigned int nr);
+DECLARE_PER_CPU(struct task_struct *, timersd);
 extern void raise_timer_softirq(void);
 extern void raise_hrtimer_softirq(void);
Index: linux-6.3.0-rt11/kernel/rcu/rcutorture.c
--- linux-6.3.0-rt11.orig/kernel/rcu/rcutorture.c
+++ linux-6.3.0-rt11/kernel/rcu/rcutorture.c
@ linux-6.3.0-rt11/include/linux/interrupt.h:2410 @ static int rcutorture_booster_init(unsig
 		sp.sched_priority = 2;
 		sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
+		t = per_cpu(timersd, cpu);
+		WARN_ON_ONCE(!t);
+		sp.sched_priority = 2;
+		sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
 	/* Don't allow time recalculation while creating a new task. */
Index: linux-6.3.0-rt11/kernel/softirq.c
--- linux-6.3.0-rt11.orig/kernel/softirq.c
+++ linux-6.3.0-rt11/kernel/softirq.c
@ linux-6.3.0-rt11/include/linux/interrupt.h:623 @ static inline void tick_irq_exit(void)
-static DEFINE_PER_CPU(struct task_struct *, timersd);
+DEFINE_PER_CPU(struct task_struct *, timersd);
 static DEFINE_PER_CPU(unsigned long, pending_timer_softirq);
 static unsigned int local_pending_timers(void)