Skip to content

Commit 282e06c

Browse files
paulmckrcuurezki
authored andcommitted
rcutorture: Add parameters to control polled/conditional wait interval
This commit adds rcutorture module parameters gp_cond_wi, gp_cond_wi_exp, gp_poll_wi, and gp_poll_wi_exp to control the wait interval for conditional, conditional expedited, polled, and polled expedited grace periods, respectively. When rcu_torture_writer() is testing these types of grace periods, hrtimers are used to randomly wait up to the specified number of microseconds, but with nanosecond granularity. In the case of conditional grace periods (get_state_synchronize_rcu() and cond_synchronize_rcu(), for example) there is just one wait. For polled grace periods (start_poll_synchronize_rcu() and poll_state_synchronize_rcu(), for example), there is a repeated series of waits until the grace period ends. For normal grace periods, the default is 16 jiffies (for example, 16,000 microseconds on a HZ=1000 system) and for expedited grace periods the default is 128 microseconds. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
1 parent cae7f63 commit 282e06c

File tree

2 files changed

+63
-12
lines changed

2 files changed

+63
-12
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5380,6 +5380,25 @@
53805380
concurrent normal grace periods into account,
53815381
if available.
53825382

5383+
rcutorture.gp_cond_wi= [KNL]
5384+
Nominal wait interval for normal conditional
5385+
grace periods (specified by rcutorture's
5386+
gp_cond and gp_cond_full module parameters),
5387+
in microseconds. The actual wait interval will
5388+
be randomly selected to nanosecond granularity up
5389+
to this wait interval. Defaults to 16 jiffies,
5390+
for example, 16,000 microseconds on a system
5391+
with HZ=1000.
5392+
5393+
rcutorture.gp_cond_wi_exp= [KNL]
5394+
Nominal wait interval for expedited conditional
5395+
grace periods (specified by rcutorture's
5396+
gp_cond_exp and gp_cond_exp_full module
5397+
parameters), in microseconds. The actual wait
5398+
interval will be randomly selected to nanosecond
5399+
granularity up to this wait interval. Defaults to
5400+
128 microseconds.
5401+
53835402
rcutorture.gp_exp= [KNL]
53845403
Use expedited update-side primitives, if available.
53855404

@@ -5405,6 +5424,25 @@
54055424
primitives that also take concurrent normal
54065425
grace periods into account, if available.
54075426

5427+
rcutorture.gp_poll_wi= [KNL]
5428+
Nominal wait interval for normal conditional
5429+
grace periods (specified by rcutorture's
5430+
gp_poll and gp_poll_full module parameters),
5431+
in microseconds. The actual wait interval will
5432+
be randomly selected to nanosecond granularity up
5433+
to this wait interval. Defaults to 16 jiffies,
5434+
for example, 16,000 microseconds on a system
5435+
with HZ=1000.
5436+
5437+
rcutorture.gp_poll_wi_exp= [KNL]
5438+
Nominal wait interval for expedited conditional
5439+
grace periods (specified by rcutorture's
5440+
gp_poll_exp and gp_poll_exp_full module
5441+
parameters), in microseconds. The actual wait
5442+
interval will be randomly selected to nanosecond
5443+
granularity up to this wait interval. Defaults to
5444+
128 microseconds.
5445+
54085446
rcutorture.gp_sync= [KNL]
54095447
Use normal (non-expedited) synchronous
54105448
update-side primitives, if available. If all

kernel/rcu/rcutorture.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,20 @@ torture_param(bool, gp_cond_exp, false, "Use conditional/async expedited GP wait
9292
torture_param(bool, gp_cond_full, false, "Use conditional/async full-state GP wait primitives");
9393
torture_param(bool, gp_cond_exp_full, false,
9494
"Use conditional/async full-stateexpedited GP wait primitives");
95+
torture_param(int, gp_cond_wi, 16 * USEC_PER_SEC / HZ,
96+
"Wait interval for normal conditional grace periods, us (default 16 jiffies)");
97+
torture_param(int, gp_cond_wi_exp, 128,
98+
"Wait interval for expedited conditional grace periods, us (default 128 us)");
9599
torture_param(bool, gp_exp, false, "Use expedited GP wait primitives");
96100
torture_param(bool, gp_normal, false, "Use normal (non-expedited) GP wait primitives");
97101
torture_param(bool, gp_poll, false, "Use polling GP wait primitives");
98102
torture_param(bool, gp_poll_exp, false, "Use polling expedited GP wait primitives");
99103
torture_param(bool, gp_poll_full, false, "Use polling full-state GP wait primitives");
100104
torture_param(bool, gp_poll_exp_full, false, "Use polling full-state expedited GP wait primitives");
105+
torture_param(int, gp_poll_wi, 16 * USEC_PER_SEC / HZ,
106+
"Wait interval for normal polled grace periods, us (default 16 jiffies)");
107+
torture_param(int, gp_poll_wi_exp, 128,
108+
"Wait interval for expedited polled grace periods, us (default 128 us)");
101109
torture_param(bool, gp_sync, false, "Use synchronous GP wait primitives");
102110
torture_param(int, irqreader, 1, "Allow RCU readers from irq handlers");
103111
torture_param(int, leakpointer, 0, "Leak pointer dereferences from readers");
@@ -1370,6 +1378,7 @@ static void rcu_torture_write_types(void)
13701378
pr_alert("%s: gp_sync without primitives.\n", __func__);
13711379
}
13721380
pr_alert("%s: Testing %d update types.\n", __func__, nsynctypes);
1381+
pr_info("%s: gp_cond_wi %d gp_cond_wi_exp %d gp_poll_wi %d gp_poll_wi_exp %d\n", __func__, gp_cond_wi, gp_cond_wi_exp, gp_poll_wi, gp_poll_wi_exp);
13731382
}
13741383

13751384
/*
@@ -1536,31 +1545,35 @@ rcu_torture_writer(void *arg)
15361545
case RTWS_COND_GET:
15371546
rcu_torture_writer_state = RTWS_COND_GET;
15381547
gp_snap = cur_ops->get_gp_state();
1539-
torture_hrtimeout_jiffies(torture_random(&rand) % 16, &rand);
1548+
torture_hrtimeout_us(torture_random(&rand) % gp_cond_wi,
1549+
1000, &rand);
15401550
rcu_torture_writer_state = RTWS_COND_SYNC;
15411551
cur_ops->cond_sync(gp_snap);
15421552
rcu_torture_pipe_update(old_rp);
15431553
break;
15441554
case RTWS_COND_GET_EXP:
15451555
rcu_torture_writer_state = RTWS_COND_GET_EXP;
15461556
gp_snap = cur_ops->get_gp_state_exp();
1547-
torture_hrtimeout_jiffies(torture_random(&rand) % 16, &rand);
1557+
torture_hrtimeout_us(torture_random(&rand) % gp_cond_wi_exp,
1558+
1000, &rand);
15481559
rcu_torture_writer_state = RTWS_COND_SYNC_EXP;
15491560
cur_ops->cond_sync_exp(gp_snap);
15501561
rcu_torture_pipe_update(old_rp);
15511562
break;
15521563
case RTWS_COND_GET_FULL:
15531564
rcu_torture_writer_state = RTWS_COND_GET_FULL;
15541565
cur_ops->get_gp_state_full(&gp_snap_full);
1555-
torture_hrtimeout_jiffies(torture_random(&rand) % 16, &rand);
1566+
torture_hrtimeout_us(torture_random(&rand) % gp_cond_wi,
1567+
1000, &rand);
15561568
rcu_torture_writer_state = RTWS_COND_SYNC_FULL;
15571569
cur_ops->cond_sync_full(&gp_snap_full);
15581570
rcu_torture_pipe_update(old_rp);
15591571
break;
15601572
case RTWS_COND_GET_EXP_FULL:
15611573
rcu_torture_writer_state = RTWS_COND_GET_EXP_FULL;
15621574
cur_ops->get_gp_state_full(&gp_snap_full);
1563-
torture_hrtimeout_jiffies(torture_random(&rand) % 16, &rand);
1575+
torture_hrtimeout_us(torture_random(&rand) % gp_cond_wi_exp,
1576+
1000, &rand);
15641577
rcu_torture_writer_state = RTWS_COND_SYNC_EXP_FULL;
15651578
cur_ops->cond_sync_exp_full(&gp_snap_full);
15661579
rcu_torture_pipe_update(old_rp);
@@ -1580,8 +1593,8 @@ rcu_torture_writer(void *arg)
15801593
break;
15811594
}
15821595
WARN_ON_ONCE(ulo_size > 0 && i >= ulo_size);
1583-
torture_hrtimeout_us(torture_random(&rand) % 128, 1000,
1584-
&rand);
1596+
torture_hrtimeout_us(torture_random(&rand) % gp_poll_wi,
1597+
1000, &rand);
15851598
}
15861599
rcu_torture_pipe_update(old_rp);
15871600
break;
@@ -1601,8 +1614,8 @@ rcu_torture_writer(void *arg)
16011614
break;
16021615
}
16031616
WARN_ON_ONCE(rgo_size > 0 && i >= rgo_size);
1604-
torture_hrtimeout_us(torture_random(&rand) % 128, 1000,
1605-
&rand);
1617+
torture_hrtimeout_us(torture_random(&rand) % gp_poll_wi,
1618+
1000, &rand);
16061619
}
16071620
rcu_torture_pipe_update(old_rp);
16081621
break;
@@ -1611,17 +1624,17 @@ rcu_torture_writer(void *arg)
16111624
gp_snap = cur_ops->start_gp_poll_exp();
16121625
rcu_torture_writer_state = RTWS_POLL_WAIT_EXP;
16131626
while (!cur_ops->poll_gp_state_exp(gp_snap))
1614-
torture_hrtimeout_us(torture_random(&rand) % 128, 1000,
1615-
&rand);
1627+
torture_hrtimeout_us(torture_random(&rand) % gp_poll_wi_exp,
1628+
1000, &rand);
16161629
rcu_torture_pipe_update(old_rp);
16171630
break;
16181631
case RTWS_POLL_GET_EXP_FULL:
16191632
rcu_torture_writer_state = RTWS_POLL_GET_EXP_FULL;
16201633
cur_ops->start_gp_poll_exp_full(&gp_snap_full);
16211634
rcu_torture_writer_state = RTWS_POLL_WAIT_EXP_FULL;
16221635
while (!cur_ops->poll_gp_state_full(&gp_snap_full))
1623-
torture_hrtimeout_us(torture_random(&rand) % 128, 1000,
1624-
&rand);
1636+
torture_hrtimeout_us(torture_random(&rand) % gp_poll_wi_exp,
1637+
1000, &rand);
16251638
rcu_torture_pipe_update(old_rp);
16261639
break;
16271640
case RTWS_SYNC:

0 commit comments

Comments
 (0)