Skip to content

Commit 7c1b3e0

Browse files
paulmckrcuFrederic Weisbecker
authored andcommitted
rcutorture: Add test of RCU CPU stall notifiers
This commit registers an RCU CPU stall notifier when testing RCU CPU stalls. The notifier logs a message similar to the following: rcu_torture_stall_nf: v=1, duration=21001. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
1 parent 5b404fd commit 7c1b3e0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

kernel/rcu/rcutorture.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/spinlock.h>
2222
#include <linux/smp.h>
2323
#include <linux/rcupdate_wait.h>
24+
#include <linux/rcu_notifier.h>
2425
#include <linux/interrupt.h>
2526
#include <linux/sched/signal.h>
2627
#include <uapi/linux/sched/types.h>
@@ -2428,16 +2429,31 @@ static int rcutorture_booster_init(unsigned int cpu)
24282429
return 0;
24292430
}
24302431

2432+
static int rcu_torture_stall_nf(struct notifier_block *nb, unsigned long v, void *ptr)
2433+
{
2434+
pr_info("%s: v=%lu, duration=%lu.\n", __func__, v, (unsigned long)ptr);
2435+
return NOTIFY_OK;
2436+
}
2437+
2438+
static struct notifier_block rcu_torture_stall_block = {
2439+
.notifier_call = rcu_torture_stall_nf,
2440+
};
2441+
24312442
/*
24322443
* CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then
24332444
* induces a CPU stall for the time specified by stall_cpu.
24342445
*/
24352446
static int rcu_torture_stall(void *args)
24362447
{
24372448
int idx;
2449+
int ret;
24382450
unsigned long stop_at;
24392451

24402452
VERBOSE_TOROUT_STRING("rcu_torture_stall task started");
2453+
ret = rcu_stall_chain_notifier_register(&rcu_torture_stall_block);
2454+
if (ret)
2455+
pr_info("%s: rcu_stall_chain_notifier_register() returned %d, %sexpected.\n",
2456+
__func__, ret, !IS_ENABLED(CONFIG_RCU_STALL_COMMON) ? "un" : "");
24412457
if (stall_cpu_holdoff > 0) {
24422458
VERBOSE_TOROUT_STRING("rcu_torture_stall begin holdoff");
24432459
schedule_timeout_interruptible(stall_cpu_holdoff * HZ);
@@ -2481,6 +2497,11 @@ static int rcu_torture_stall(void *args)
24812497
cur_ops->readunlock(idx);
24822498
}
24832499
pr_alert("%s end.\n", __func__);
2500+
if (!ret) {
2501+
ret = rcu_stall_chain_notifier_unregister(&rcu_torture_stall_block);
2502+
if (ret)
2503+
pr_info("%s: rcu_stall_chain_notifier_unregister() returned %d.\n", __func__, ret);
2504+
}
24842505
torture_shutdown_absorb("rcu_torture_stall");
24852506
while (!kthread_should_stop())
24862507
schedule_timeout_interruptible(10 * HZ);

0 commit comments

Comments
 (0)