Skip to content

Commit 00c24c9

Browse files
paulmckrcuFrederic Weisbecker
authored andcommitted
locktorture: Add new module parameters to lock_torture_print_module_parms()
This commit adds new module parameters to lock_torture_print_module_parms, and alphabetizes things while in the area. This change makes locktorture test results more useful and self-contained. Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 92776c6 commit 00c24c9

File tree

1 file changed

+23
-41
lines changed

1 file changed

+23
-41
lines changed

kernel/locking/locktorture.c

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ torture_param(int, shuffle_interval, 3, "Number of jiffies between shuffles, 0=d
4747
torture_param(int, shutdown_secs, 0, "Shutdown time (j), <= zero to disable.");
4848
torture_param(int, stat_interval, 60, "Number of seconds between stats printk()s");
4949
torture_param(int, stutter, 5, "Number of jiffies to run/halt test, 0=disable");
50-
torture_param(int, writer_fifo, 0, "Run writers at sched_set_fifo() priority");
5150
torture_param(int, verbose, 1, "Enable verbose debugging printk()s");
51+
torture_param(int, writer_fifo, 0, "Run writers at sched_set_fifo() priority");
5252
/* Going much higher trips "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!" errors */
5353
#define MAX_NESTED_LOCKS 8
5454

@@ -166,12 +166,9 @@ static int torture_lock_busted_write_lock(int tid __maybe_unused)
166166

167167
static void torture_lock_busted_write_delay(struct torture_random_state *trsp)
168168
{
169-
const unsigned long longdelay_ms = long_hold ? long_hold : ULONG_MAX;
170-
171169
/* We want a long delay occasionally to force massive contention. */
172-
if (!(torture_random(trsp) %
173-
(cxt.nrealwriters_stress * 2000 * longdelay_ms)))
174-
mdelay(longdelay_ms);
170+
if (long_hold && !(torture_random(trsp) % (cxt.nrealwriters_stress * 2000 * long_hold)))
171+
mdelay(long_hold);
175172
if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 20000)))
176173
torture_preempt_schedule(); /* Allow test to be preempted. */
177174
}
@@ -244,15 +241,14 @@ __acquires(torture_spinlock)
244241
static void torture_spin_lock_write_delay(struct torture_random_state *trsp)
245242
{
246243
const unsigned long shortdelay_us = 2;
247-
const unsigned long longdelay_ms = long_hold ? long_hold : ULONG_MAX;
248244
unsigned long j;
249245

250246
/* We want a short delay mostly to emulate likely code, and
251247
* we want a long delay occasionally to force massive contention.
252248
*/
253-
if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 2000 * longdelay_ms))) {
249+
if (long_hold && !(torture_random(trsp) % (cxt.nrealwriters_stress * 2000 * long_hold))) {
254250
j = jiffies;
255-
mdelay(longdelay_ms);
251+
mdelay(long_hold);
256252
pr_alert("%s: delay = %lu jiffies.\n", __func__, jiffies - j);
257253
}
258254
if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 200 * shortdelay_us)))
@@ -370,14 +366,12 @@ __acquires(torture_rwlock)
370366
static void torture_rwlock_write_delay(struct torture_random_state *trsp)
371367
{
372368
const unsigned long shortdelay_us = 2;
373-
const unsigned long longdelay_ms = long_hold ? long_hold : ULONG_MAX;
374369

375370
/* We want a short delay mostly to emulate likely code, and
376371
* we want a long delay occasionally to force massive contention.
377372
*/
378-
if (!(torture_random(trsp) %
379-
(cxt.nrealwriters_stress * 2000 * longdelay_ms)))
380-
mdelay(longdelay_ms);
373+
if (long_hold && !(torture_random(trsp) % (cxt.nrealwriters_stress * 2000 * long_hold)))
374+
mdelay(long_hold);
381375
else
382376
udelay(shortdelay_us);
383377
}
@@ -398,14 +392,12 @@ __acquires(torture_rwlock)
398392
static void torture_rwlock_read_delay(struct torture_random_state *trsp)
399393
{
400394
const unsigned long shortdelay_us = 10;
401-
const unsigned long longdelay_ms = 100;
402395

403396
/* We want a short delay mostly to emulate likely code, and
404397
* we want a long delay occasionally to force massive contention.
405398
*/
406-
if (!(torture_random(trsp) %
407-
(cxt.nrealreaders_stress * 2000 * longdelay_ms)))
408-
mdelay(longdelay_ms);
399+
if (long_hold && !(torture_random(trsp) % (cxt.nrealreaders_stress * 2000 * long_hold)))
400+
mdelay(long_hold);
409401
else
410402
udelay(shortdelay_us);
411403
}
@@ -503,12 +495,9 @@ __acquires(torture_mutex)
503495

504496
static void torture_mutex_delay(struct torture_random_state *trsp)
505497
{
506-
const unsigned long longdelay_ms = long_hold ? long_hold : ULONG_MAX;
507-
508498
/* We want a long delay occasionally to force massive contention. */
509-
if (!(torture_random(trsp) %
510-
(cxt.nrealwriters_stress * 2000 * longdelay_ms)))
511-
mdelay(longdelay_ms * 5);
499+
if (long_hold && !(torture_random(trsp) % (cxt.nrealwriters_stress * 2000 * long_hold)))
500+
mdelay(long_hold * 5);
512501
if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 20000)))
513502
torture_preempt_schedule(); /* Allow test to be preempted. */
514503
}
@@ -676,15 +665,13 @@ __acquires(torture_rtmutex)
676665
static void torture_rtmutex_delay(struct torture_random_state *trsp)
677666
{
678667
const unsigned long shortdelay_us = 2;
679-
const unsigned long longdelay_ms = long_hold ? long_hold : ULONG_MAX;
680668

681669
/*
682670
* We want a short delay mostly to emulate likely code, and
683671
* we want a long delay occasionally to force massive contention.
684672
*/
685-
if (!(torture_random(trsp) %
686-
(cxt.nrealwriters_stress * 2000 * longdelay_ms)))
687-
mdelay(longdelay_ms);
673+
if (long_hold && !(torture_random(trsp) % (cxt.nrealwriters_stress * 2000 * long_hold)))
674+
mdelay(long_hold);
688675
if (!(torture_random(trsp) %
689676
(cxt.nrealwriters_stress * 200 * shortdelay_us)))
690677
udelay(shortdelay_us);
@@ -741,12 +728,9 @@ __acquires(torture_rwsem)
741728

742729
static void torture_rwsem_write_delay(struct torture_random_state *trsp)
743730
{
744-
const unsigned long longdelay_ms = long_hold ? long_hold : ULONG_MAX;
745-
746731
/* We want a long delay occasionally to force massive contention. */
747-
if (!(torture_random(trsp) %
748-
(cxt.nrealwriters_stress * 2000 * longdelay_ms)))
749-
mdelay(longdelay_ms * 10);
732+
if (long_hold && !(torture_random(trsp) % (cxt.nrealwriters_stress * 2000 * long_hold)))
733+
mdelay(long_hold * 10);
750734
if (!(torture_random(trsp) % (cxt.nrealwriters_stress * 20000)))
751735
torture_preempt_schedule(); /* Allow test to be preempted. */
752736
}
@@ -766,14 +750,11 @@ __acquires(torture_rwsem)
766750

767751
static void torture_rwsem_read_delay(struct torture_random_state *trsp)
768752
{
769-
const unsigned long longdelay_ms = 100;
770-
771753
/* We want a long delay occasionally to force massive contention. */
772-
if (!(torture_random(trsp) %
773-
(cxt.nrealreaders_stress * 2000 * longdelay_ms)))
774-
mdelay(longdelay_ms * 2);
754+
if (long_hold && !(torture_random(trsp) % (cxt.nrealreaders_stress * 2000 * long_hold)))
755+
mdelay(long_hold * 2);
775756
else
776-
mdelay(longdelay_ms / 2);
757+
mdelay(long_hold / 2);
777758
if (!(torture_random(trsp) % (cxt.nrealreaders_stress * 20000)))
778759
torture_preempt_schedule(); /* Allow test to be preempted. */
779760
}
@@ -1056,11 +1037,12 @@ lock_torture_print_module_parms(struct lock_torture_ops *cur_ops,
10561037

10571038
cpumask_setall(&cpumask_all);
10581039
pr_alert("%s" TORTURE_FLAG
1059-
"--- %s%s: nwriters_stress=%d nreaders_stress=%d nested_locks=%d stat_interval=%d verbose=%d shuffle_interval=%d stutter=%d shutdown_secs=%d onoff_interval=%d onoff_holdoff=%d readers_bind=%*pbl writers_bind=%*pbl\n",
1040+
"--- %s%s: acq_writer_lim=%d long_hold=%d nested_locks=%d nreaders_stress=%d nwriters_stress=%d onoff_holdoff=%d onoff_interval=%d rt_boost=%d rt_boost_factor=%d shuffle_interval=%d shutdown_secs=%d stat_interval=%d stutter=%d verbose=%d writer_fifo=%d readers_bind=%*pbl writers_bind=%*pbl\n",
10601041
torture_type, tag, cxt.debug_lock ? " [debug]": "",
1061-
cxt.nrealwriters_stress, cxt.nrealreaders_stress,
1062-
nested_locks, stat_interval, verbose, shuffle_interval,
1063-
stutter, shutdown_secs, onoff_interval, onoff_holdoff,
1042+
acq_writer_lim, long_hold, nested_locks, cxt.nrealreaders_stress,
1043+
cxt.nrealwriters_stress, onoff_holdoff, onoff_interval, rt_boost,
1044+
rt_boost_factor, shuffle_interval, shutdown_secs, stat_interval, stutter,
1045+
verbose, writer_fifo,
10641046
cpumask_pr_args(rcmp), cpumask_pr_args(wcmp));
10651047
}
10661048

0 commit comments

Comments
 (0)