Skip to content

Commit 95a5de2

Browse files
paulmckrcuFrederic Weisbecker
authored andcommitted
rcutorture: Add reader_flavor parameter for SRCU readers
This commit adds an rcutorture.reader_flavor parameter whose bits correspond to reader flavors. For example, SRCU's readers are 0x1 for normal and 0x2 for NMI-safe. Signed-off-by: Paul E. McKenney <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: <[email protected]> Reviewed-by: Neeraj Upadhyay <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 37a1dec commit 95a5de2

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5426,6 +5426,14 @@
54265426
The delay, in seconds, between successive
54275427
read-then-exit testing episodes.
54285428

5429+
rcutorture.reader_flavor= [KNL]
5430+
A bit mask indicating which readers to use.
5431+
If there is more than one bit set, the readers
5432+
are entered from low-order bit up, and are
5433+
exited in the opposite order. For SRCU, the
5434+
0x1 bit is normal readers and the 0x2 bit is
5435+
for NMI-safe readers.
5436+
54295437
rcutorture.shuffle_interval= [KNL]
54305438
Set task-shuffle interval (s). Shuffling tasks
54315439
allows some CPUs to go into dyntick-idle mode

kernel/rcu/rcutorture.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ torture_param(int, nocbs_nthreads, 0, "Number of NOCB toggle threads, 0 to disab
111111
torture_param(int, nocbs_toggle, 1000, "Time between toggling nocb state (ms)");
112112
torture_param(int, read_exit_delay, 13, "Delay between read-then-exit episodes (s)");
113113
torture_param(int, read_exit_burst, 16, "# of read-then-exit bursts per episode, zero to disable");
114+
torture_param(int, reader_flavor, 0x1, "Reader flavors to use, one per bit.");
114115
torture_param(int, shuffle_interval, 3, "Number of seconds between shuffles");
115116
torture_param(int, shutdown_secs, 0, "Shutdown time (s), <= zero to disable.");
116117
torture_param(int, stall_cpu, 0, "Stall duration (s), zero to disable.");
@@ -644,10 +645,20 @@ static void srcu_get_gp_data(int *flags, unsigned long *gp_seq)
644645

645646
static int srcu_torture_read_lock(void)
646647
{
647-
if (cur_ops == &srcud_ops)
648-
return srcu_read_lock_nmisafe(srcu_ctlp);
649-
else
650-
return srcu_read_lock(srcu_ctlp);
648+
int idx;
649+
int ret = 0;
650+
651+
if ((reader_flavor & 0x1) || !(reader_flavor & 0x7)) {
652+
idx = srcu_read_lock(srcu_ctlp);
653+
WARN_ON_ONCE(idx & ~0x1);
654+
ret += idx;
655+
}
656+
if (reader_flavor & 0x2) {
657+
idx = srcu_read_lock_nmisafe(srcu_ctlp);
658+
WARN_ON_ONCE(idx & ~0x1);
659+
ret += idx << 1;
660+
}
661+
return ret;
651662
}
652663

653664
static void
@@ -671,10 +682,11 @@ srcu_read_delay(struct torture_random_state *rrsp, struct rt_read_seg *rtrsp)
671682

672683
static void srcu_torture_read_unlock(int idx)
673684
{
674-
if (cur_ops == &srcud_ops)
675-
srcu_read_unlock_nmisafe(srcu_ctlp, idx);
676-
else
677-
srcu_read_unlock(srcu_ctlp, idx);
685+
WARN_ON_ONCE((reader_flavor && (idx & ~reader_flavor)) || (!reader_flavor && (idx & ~0x1)));
686+
if (reader_flavor & 0x2)
687+
srcu_read_unlock_nmisafe(srcu_ctlp, (idx & 0x2) >> 1);
688+
if ((reader_flavor & 0x1) || !(reader_flavor & 0x7))
689+
srcu_read_unlock(srcu_ctlp, idx & 0x1);
678690
}
679691

680692
static int torture_srcu_read_lock_held(void)
@@ -2389,6 +2401,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)
23892401
"n_barrier_cbs=%d "
23902402
"onoff_interval=%d onoff_holdoff=%d "
23912403
"read_exit_delay=%d read_exit_burst=%d "
2404+
"reader_flavor=%x "
23922405
"nocbs_nthreads=%d nocbs_toggle=%d "
23932406
"test_nmis=%d\n",
23942407
torture_type, tag, nrealreaders, nfakewriters,
@@ -2401,6 +2414,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)
24012414
n_barrier_cbs,
24022415
onoff_interval, onoff_holdoff,
24032416
read_exit_delay, read_exit_burst,
2417+
reader_flavor,
24042418
nocbs_nthreads, nocbs_toggle,
24052419
test_nmis);
24062420
}

0 commit comments

Comments
 (0)