Skip to content

Commit c1a76c0

Browse files
committed
rcutorture: Add torture tests for RCU Tasks Trace
This commit adds the definitions required to torture the tracing flavor of RCU tasks. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent d5f177d commit c1a76c0

File tree

6 files changed

+58
-1
lines changed

6 files changed

+58
-1
lines changed

kernel/rcu/Kconfig.debug

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ config RCU_PERF_TEST
3030
select SRCU
3131
select TASKS_RCU
3232
select TASKS_RUDE_RCU
33+
select TASKS_TRACE_RCU
3334
default n
3435
help
3536
This option provides a kernel module that runs performance
@@ -48,6 +49,7 @@ config RCU_TORTURE_TEST
4849
select SRCU
4950
select TASKS_RCU
5051
select TASKS_RUDE_RCU
52+
select TASKS_TRACE_RCU
5153
default n
5254
help
5355
This option provides a kernel module that runs torture tests

kernel/rcu/rcu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ enum rcutorture_type {
442442
RCU_FLAVOR,
443443
RCU_TASKS_FLAVOR,
444444
RCU_TASKS_RUDE_FLAVOR,
445+
RCU_TASKS_TRACING_FLAVOR,
445446
RCU_TRIVIAL_FLAVOR,
446447
SRCU_FLAVOR,
447448
INVALID_RCU_FLAVOR

kernel/rcu/rcutorture.c

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <linux/sched/sysctl.h>
4646
#include <linux/oom.h>
4747
#include <linux/tick.h>
48+
#include <linux/rcupdate_trace.h>
4849

4950
#include "rcu.h"
5051

@@ -757,6 +758,45 @@ static struct rcu_torture_ops tasks_rude_ops = {
757758
.name = "tasks-rude"
758759
};
759760

761+
/*
762+
* Definitions for tracing RCU-tasks torture testing.
763+
*/
764+
765+
static int tasks_tracing_torture_read_lock(void)
766+
{
767+
rcu_read_lock_trace();
768+
return 0;
769+
}
770+
771+
static void tasks_tracing_torture_read_unlock(int idx)
772+
{
773+
rcu_read_unlock_trace();
774+
}
775+
776+
static void rcu_tasks_tracing_torture_deferred_free(struct rcu_torture *p)
777+
{
778+
call_rcu_tasks_trace(&p->rtort_rcu, rcu_torture_cb);
779+
}
780+
781+
static struct rcu_torture_ops tasks_tracing_ops = {
782+
.ttype = RCU_TASKS_TRACING_FLAVOR,
783+
.init = rcu_sync_torture_init,
784+
.readlock = tasks_tracing_torture_read_lock,
785+
.read_delay = srcu_read_delay, /* just reuse srcu's version. */
786+
.readunlock = tasks_tracing_torture_read_unlock,
787+
.get_gp_seq = rcu_no_completed,
788+
.deferred_free = rcu_tasks_tracing_torture_deferred_free,
789+
.sync = synchronize_rcu_tasks_trace,
790+
.exp_sync = synchronize_rcu_tasks_trace,
791+
.call = call_rcu_tasks_trace,
792+
.cb_barrier = rcu_barrier_tasks_trace,
793+
.fqs = NULL,
794+
.stats = NULL,
795+
.irq_capable = 1,
796+
.slow_gps = 1,
797+
.name = "tasks-tracing"
798+
};
799+
760800
static unsigned long rcutorture_seq_diff(unsigned long new, unsigned long old)
761801
{
762802
if (!cur_ops->gp_diff)
@@ -1323,6 +1363,7 @@ static bool rcu_torture_one_read(struct torture_random_state *trsp)
13231363
rcu_read_lock_bh_held() ||
13241364
rcu_read_lock_sched_held() ||
13251365
srcu_read_lock_held(srcu_ctlp) ||
1366+
rcu_read_lock_trace_held() ||
13261367
torturing_tasks());
13271368
if (p == NULL) {
13281369
/* Wait for rcu_torture_writer to get underway */
@@ -2440,7 +2481,8 @@ rcu_torture_init(void)
24402481
int firsterr = 0;
24412482
static struct rcu_torture_ops *torture_ops[] = {
24422483
&rcu_ops, &rcu_busted_ops, &srcu_ops, &srcud_ops,
2443-
&busted_srcud_ops, &tasks_ops, &tasks_rude_ops, &trivial_ops,
2484+
&busted_srcud_ops, &tasks_ops, &tasks_rude_ops,
2485+
&tasks_tracing_ops, &trivial_ops,
24442486
};
24452487

24462488
if (!torture_init_begin(torture_type, verbose))

tools/testing/selftests/rcutorture/configs/rcu/CFLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ TASKS01
1515
TASKS02
1616
TASKS03
1717
RUDE01
18+
TRACE01
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CONFIG_SMP=y
2+
CONFIG_NR_CPUS=4
3+
CONFIG_HOTPLUG_CPU=y
4+
CONFIG_PREEMPT_NONE=y
5+
CONFIG_PREEMPT_VOLUNTARY=n
6+
CONFIG_PREEMPT=n
7+
CONFIG_DEBUG_LOCK_ALLOC=y
8+
CONFIG_PROVE_LOCKING=y
9+
#CHECK#CONFIG_PROVE_RCU=y
10+
CONFIG_RCU_EXPERT=y
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rcutorture.torture_type=tasks-tracing

0 commit comments

Comments
 (0)