Skip to content

Commit 5d248bb

Browse files
deggemanpaulmckrcu
authored andcommitted
torture: Add lock_torture writer_fifo module parameter
This commit adds a module parameter that causes the locktorture writer to run at real-time priority. To use it: insmod /lib/modules/torture.ko random_shuffle=1 insmod /lib/modules/locktorture.ko torture_type=mutex_lock rt_boost=1 rt_boost_factor=50 nested_locks=3 writer_fifo=1 ^^^^^^^^^^^^^ A predecessor to this patch has been helpful to uncover issues with the proxy-execution series. [ paulmck: Remove locktorture-specific code from kernel/torture.c. ] Cc: "Paul E. McKenney" <[email protected]> Cc: Josh Triplett <[email protected]> Cc: Joel Fernandes <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: [email protected] Signed-off-by: Dietmar Eggemann <[email protected]> [jstultz: Include header change to build, reword commit message] Signed-off-by: John Stultz <[email protected]> Acked-by: Davidlohr Bueso <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 67d5404 commit 5d248bb

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,6 +2918,10 @@
29182918
locktorture.torture_type= [KNL]
29192919
Specify the locking implementation to test.
29202920

2921+
locktorture.writer_fifo= [KNL]
2922+
Run the write-side locktorture kthreads at
2923+
sched_set_fifo() real-time priority.
2924+
29212925
locktorture.verbose= [KNL]
29222926
Enable additional printk() statements.
29232927

kernel/locking/locktorture.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ torture_param(int, stutter, 5, "Number of jiffies to run/halt test, 0=disable");
4545
torture_param(int, rt_boost, 2,
4646
"Do periodic rt-boost. 0=Disable, 1=Only for rt_mutex, 2=For all lock types.");
4747
torture_param(int, rt_boost_factor, 50, "A factor determining how often rt-boost happens.");
48+
torture_param(int, writer_fifo, 0, "Run writers at sched_set_fifo() priority");
4849
torture_param(int, verbose, 1, "Enable verbose debugging printk()s");
4950
torture_param(int, nested_locks, 0, "Number of nested locks (max = 8)");
5051
/* Going much higher trips "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!" errors */
@@ -809,7 +810,8 @@ static int lock_torture_writer(void *arg)
809810
bool skip_main_lock;
810811

811812
VERBOSE_TOROUT_STRING("lock_torture_writer task started");
812-
set_user_nice(current, MAX_NICE);
813+
if (!rt_task(current))
814+
set_user_nice(current, MAX_NICE);
813815

814816
do {
815817
if ((torture_random(&rand) & 0xfffff) == 0)
@@ -1015,8 +1017,7 @@ static void lock_torture_cleanup(void)
10151017

10161018
if (writer_tasks) {
10171019
for (i = 0; i < cxt.nrealwriters_stress; i++)
1018-
torture_stop_kthread(lock_torture_writer,
1019-
writer_tasks[i]);
1020+
torture_stop_kthread(lock_torture_writer, writer_tasks[i]);
10201021
kfree(writer_tasks);
10211022
writer_tasks = NULL;
10221023
}
@@ -1244,8 +1245,9 @@ static int __init lock_torture_init(void)
12441245
goto create_reader;
12451246

12461247
/* Create writer. */
1247-
firsterr = torture_create_kthread(lock_torture_writer, &cxt.lwsa[i],
1248-
writer_tasks[i]);
1248+
firsterr = torture_create_kthread_cb(lock_torture_writer, &cxt.lwsa[i],
1249+
writer_tasks[i],
1250+
writer_fifo ? sched_set_fifo : NULL);
12491251
if (torture_init_error(firsterr))
12501252
goto unwind;
12511253

kernel/torture.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/ktime.h>
3838
#include <asm/byteorder.h>
3939
#include <linux/torture.h>
40+
#include <linux/sched/rt.h>
4041
#include "rcu/rcu.h"
4142

4243
MODULE_LICENSE("GPL");
@@ -734,7 +735,7 @@ bool stutter_wait(const char *title)
734735
cond_resched_tasks_rcu_qs();
735736
spt = READ_ONCE(stutter_pause_test);
736737
for (; spt; spt = READ_ONCE(stutter_pause_test)) {
737-
if (!ret) {
738+
if (!ret && !rt_task(current)) {
738739
sched_set_normal(current, MAX_NICE);
739740
ret = true;
740741
}

0 commit comments

Comments
 (0)