Skip to contentSkip to conversation

Torture-test updates for v6.6

PATCH In review Paul E. McKenney 3 participants 17 messages Jul 17, 2023 – Aug 8, 2023

Subsystems (3)
lore
Share & tools
lore

Paul E. McKenney

author maintainer
#0 lore raw

cover Torture-test updates for v6.6

Hello!

This series contains torture-test updates:

1. Dump grace-period state upon rtort_pipe_count incidents.

2. Support randomized shuffling for proxy exec testing, courtesy
of Connor O'Brien.

3. Add lock_torture_writer_fifo module param, courtesy of Dietmar
Eggemann.

4. Make torture_hrtimeout_*() use TASK_IDLE.

5. Move torture_onoff() timeouts to hrtimers.

6. Move torture_shuffle() timeouts to hrtimers.

7. Move stutter_wait() timeouts to hrtimers.

8. Stop right-shifting torture_random() return values.

9. Stop right-shifting torture_random() return values.

Thanx, Paul

------------------------------------------------------------------------

 b/kernel/locking/locktorture.c |    3 ++-
 b/kernel/rcu/rcutorture.c      |    1 +
 b/kernel/torture.c             |   10 ++++++++--
 kernel/rcu/rcutorture.c        |    6 +++---
 kernel/torture.c               |   31 +++++++++++++++++++++----------
 5 files changed, 35 insertions(+), 16 deletions(-)
author maintainer
#1 lore raw

PATCH 1/9 rcutorture: Dump grace-period state upon rtort_pipe_count incidents

The rtort_pipe_count WARN() indicates that grace periods were unable to invoke all callbacks during a stutter_wait() interval. But it is sometimes helpful to have a bit more information as to why. This commit therefore invokes show_rcu_gp_kthreads() immediately before that WARN() in order to dump out some relevant information.

---
 kernel/rcu/rcutorture.c | 1 +
 1 file changed, 1 insertion(+)
kernel/rcu/rcutorture.c +1 -0
index 147551c23baf..d291a1438c30 100644
@@ -1581,6 +1581,7 @@ rcu_torture_writer(void *arg)
 				    rcu_access_pointer(rcu_torture_current) !=
 				    &rcu_tortures[i]) {
 					tracing_off();
+					show_rcu_gp_kthreads();
 					WARN(1, "%s: rtort_pipe_count: %d\n", __func__, rcu_tortures[i].rtort_pipe_count);
 					rcu_ftrace_dump(DUMP_ALL);
 				}
Signature · 1 line
2.40.1
author maintainer
#2 lore raw

PATCH 2/9 torture: Support randomized shuffling for proxy exec testing

In reply to Paul E. McKenney

From: Connor O'Brien <[email protected]>

Currently shuffling sets the same cpu affinities for all tasks, which makes us less likely to hit paths involving migrating blocked tasks onto a cpu where they can't run.

This patch adds an element of randomness to allow affinities of different writer tasks to diverge.

This has helped uncover issues in testing with Proxy Execution

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 Dietmar Eggemann <[email protected]>
---
 kernel/torture.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
kernel/torture.c +8 -2
index 1a0519b836ac..8be83fdc6be1 100644
@@ -54,6 +54,9 @@ module_param(verbose_sleep_frequency, int, 0444);
 static int verbose_sleep_duration = 1;
 module_param(verbose_sleep_duration, int, 0444);
 
+static int random_shuffle;
+module_param(random_shuffle, int, 0444);
+
 static char *torture_type;
 static int verbose;
 
@@ -518,6 +521,7 @@ static void torture_shuffle_task_unregister_all(void)
  */
 static void torture_shuffle_tasks(void)
 {
+	DEFINE_TORTURE_RANDOM(rand);
 	struct shuffle_task *stp;
 
 	cpumask_setall(shuffle_tmp_mask);
@@ -537,8 +541,10 @@ static void torture_shuffle_tasks(void)
 		cpumask_clear_cpu(shuffle_idle_cpu, shuffle_tmp_mask);
 
 	mutex_lock(&shuffle_task_mutex);
-	list_for_each_entry(stp, &shuffle_task_list, st_l)
-		set_cpus_allowed_ptr(stp->st_t, shuffle_tmp_mask);
+	list_for_each_entry(stp, &shuffle_task_list, st_l) {
+		if (!random_shuffle || torture_random(&rand) & 0x1)
+			set_cpus_allowed_ptr(stp->st_t, shuffle_tmp_mask);
+	}
 	mutex_unlock(&shuffle_task_mutex);
 
 	cpus_read_unlock();
Signature · 1 line
2.40.1
author maintainer
#3 lore raw

PATCH 3/9 torture: Add lock_torture_writer_fifo module param

In reply to Paul E. McKenney

From: Dietmar Eggemann <[email protected]>

Modifies locktorture writer to run as RT task.

To use it:
insmod /lib/modules/torture.ko random_shuffle=1 lock_torture_writer_fifo=1

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^

insmod /lib/modules/locktorture.ko torture_type=mutex_lock rt_boost=1 rt_boost_factor=50 nested_locks=3

This patch has been helpful to uncover issues with the proxy-execution series.

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 Dietmar Eggemann <[email protected]>
[jstultz: Include header change to build, reword commit message]
---
 kernel/locking/locktorture.c |  3 ++-
 kernel/torture.c             | 11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
kernel/locking/locktorture.c +2 -1
index 949d3deae506..aac48d323254 100644
@@ -809,7 +809,8 @@ static int lock_torture_writer(void *arg)
 	bool skip_main_lock;
 
 	VERBOSE_TOROUT_STRING("lock_torture_writer task started");
-	set_user_nice(current, MAX_NICE);
+	if (!rt_task(current))
+		set_user_nice(current, MAX_NICE);
 
 	do {
 		if ((torture_random(&rand) & 0xfffff) == 0)
kernel/torture.c +10 -1
index 8be83fdc6be1..db79197e257a 100644
@@ -37,6 +37,7 @@
 #include <linux/ktime.h>
 #include <asm/byteorder.h>
 #include <linux/torture.h>
+#include <linux/sched/rt.h>
 #include "rcu/rcu.h"
 
 MODULE_LICENSE("GPL");
@@ -57,6 +58,9 @@ module_param(verbose_sleep_duration, int, 0444);
 static int random_shuffle;
 module_param(random_shuffle, int, 0444);
 
+static int lock_torture_writer_fifo;
+module_param(lock_torture_writer_fifo, int, 0444);
+
 static char *torture_type;
 static int verbose;
 
@@ -734,7 +738,7 @@ bool stutter_wait(const char *title)
 	cond_resched_tasks_rcu_qs();
 	spt = READ_ONCE(stutter_pause_test);
 	for (; spt; spt = READ_ONCE(stutter_pause_test)) {
-		if (!ret) {
+		if (!ret && !rt_task(current)) {
 			sched_set_normal(current, MAX_NICE);
 			ret = true;
 		}
@@ -944,6 +948,11 @@ int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
 		*tp = NULL;
 		return ret;
 	}
+
+	if (lock_torture_writer_fifo &&
+	    !strncmp(s, "lock_torture_writer", strlen(s)))
+		sched_set_fifo(*tp);
+
 	wake_up_process(*tp);  // Process is sleeping, so ordering provided.
 	torture_shuffle_task_register(*tp);
 	return ret;
Signature · 1 line
2.40.1
author maintainer
#4 lore raw

Re: [PATCH rcu 3/9] torture: Add lock_torture_writer_fifo module param

Quoted 75 lines · Paul E. McKenney

From: Dietmar Eggemann <[email protected]>

Modifies locktorture writer to run as RT task.

To use it:
insmod /lib/modules/torture.ko random_shuffle=1 lock_torture_writer_fifo=1

                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^

insmod /lib/modules/locktorture.ko torture_type=mutex_lock rt_boost=1 rt_boost_factor=50 nested_locks=3

This patch has been helpful to uncover issues with the proxy-execution series.

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 Dietmar Eggemann <[email protected]>
[jstultz: Include header change to build, reword commit message]
---
 kernel/locking/locktorture.c |  3 ++-
 kernel/torture.c             | 11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
kernel/locking/locktorture.c +2 -1
index 949d3deae506..aac48d323254 100644
@@ -809,7 +809,8 @@ static int lock_torture_writer(void *arg)
 	bool skip_main_lock;
 
 	VERBOSE_TOROUT_STRING("lock_torture_writer task started");
-	set_user_nice(current, MAX_NICE);
+	if (!rt_task(current))
+		set_user_nice(current, MAX_NICE);
 
 	do {
 		if ((torture_random(&rand) & 0xfffff) == 0)
kernel/torture.c +5 -1
index 8be83fdc6be1..db79197e257a 100644
@@ -37,6 +37,7 @@
 #include <linux/ktime.h>
 #include <asm/byteorder.h>
 #include <linux/torture.h>
+#include <linux/sched/rt.h>
 #include "rcu/rcu.h"
 
 MODULE_LICENSE("GPL");
@@ -57,6 +58,9 @@ module_param(verbose_sleep_duration, int, 0444);
 static int random_shuffle;
 module_param(random_shuffle, int, 0444);
 
+static int lock_torture_writer_fifo;
+module_param(lock_torture_writer_fifo, int, 0444);
+
 static char *torture_type;
 static int verbose;
 
@@ -734,7 +738,7 @@ bool stutter_wait(const char *title)
 	cond_resched_tasks_rcu_qs();
 	spt = READ_ONCE(stutter_pause_test);
 	for (; spt; spt = READ_ONCE(stutter_pause_test)) {
-		if (!ret) {
+		if (!ret && !rt_task(current)) {
 			sched_set_normal(current, MAX_NICE);
 			ret = true;
 		}

kernel/torture.c int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m, · line 954

Quoted 7 lines
kernel/torture.c +4 -0
@@ -944,6 +948,11 @@ int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
 		*tp = NULL;
 		return ret;
 	}
+
+	if (lock_torture_writer_fifo &&
+	    !strncmp(s, "lock_torture_writer", strlen(s)))
+		sched_set_fifo(*tp);

I replaced this with a callback function in order to confine locktorture-specific code to kernel/locking/locktorture.c.

I will reply with the following two patches.

1. Add a kthread-creation callback to _torture_create_kthread().

2. Add lock_torture writer_fifo module parameter, courtesy of
Dietmar Eggemann.

Please let me know if you have objections to this change.

Thanx, Paul

------------------------------------------------------------------------

 b/Documentation/admin-guide/kernel-parameters.txt |    4 ++++
 b/include/linux/torture.h                         |    7 +++++--
 b/kernel/locking/locktorture.c                    |   12 +++++++-----
 b/kernel/torture.c                                |    6 +++++-
 kernel/torture.c                                  |    3 ++-
 5 files changed, 23 insertions(+), 9 deletions(-)
author maintainer
#5 lore raw

PATCH 1/2 torture: Add a kthread-creation callback to _torture_create_kthread()

This commit adds a kthread-creation callback to the _torture_create_kthread() function, which allows callers of a new torture_create_kthread_cb() macro to specify a function to be invoked after the kthread is created but before it is awakened for the first time.

Cc Dietmar Eggemann <[email protected]>
Cc John Stultz <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Joel Fernandes <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Valentin Schneider <[email protected]>
Cc Dietmar Eggemann <[email protected]>
---
 include/linux/torture.h | 7 +++++--
 kernel/torture.c        | 6 +++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
include/linux/torture.h +5 -2
index 7038104463e4..bb466eec01e4 100644
@@ -108,12 +108,15 @@ bool torture_must_stop(void);
 bool torture_must_stop_irq(void);
 void torture_kthread_stopping(char *title);
 int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
-			     char *f, struct task_struct **tp);
+			     char *f, struct task_struct **tp, void (*cbf)(struct task_struct *tp));
 void _torture_stop_kthread(char *m, struct task_struct **tp);
 
 #define torture_create_kthread(n, arg, tp) \
 	_torture_create_kthread(n, (arg), #n, "Creating " #n " task", \
-				"Failed to create " #n, &(tp))
+				"Failed to create " #n, &(tp), NULL)
+#define torture_create_kthread_cb(n, arg, tp, cbf) \
+	_torture_create_kthread(n, (arg), #n, "Creating " #n " task", \
+				"Failed to create " #n, &(tp), cbf)
 #define torture_stop_kthread(n, tp) \
 	_torture_stop_kthread("Stopping " #n " task", &(tp))
 
kernel/torture.c +5 -1
index 8be83fdc6be1..b88a1a86d9da 100644
@@ -932,7 +932,7 @@ EXPORT_SYMBOL_GPL(torture_kthread_stopping);
  * it starts, you will need to open-code your own.
  */
 int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
-			    char *f, struct task_struct **tp)
+			    char *f, struct task_struct **tp, void (*cbf)(struct task_struct *tp))
 {
 	int ret = 0;
 
@@ -944,6 +944,10 @@ int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
 		*tp = NULL;
 		return ret;
 	}
+
+	if (cbf)
+		cbf(*tp);
+
 	wake_up_process(*tp);  // Process is sleeping, so ordering provided.
 	torture_shuffle_task_register(*tp);
 	return ret;
Signature · 1 line
2.40.1
Reviewed-by on v1 1/2
#6 lore raw

Re: [PATCH rcu 1/2] torture: Add a kthread-creation callback to _torture_create_kthread()

Quoted 11 lines · Paul E. McKenney

This commit adds a kthread-creation callback to the _torture_create_kthread() function, which allows callers of a new torture_create_kthread_cb() macro to specify a function to be invoked after the kthread is created but before it is awakened for the first time.

Cc Dietmar Eggemann <[email protected]>
Cc John Stultz <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Joel Fernandes <[email protected]>

thanks,

- Joel

Quoted 58 lines
Cc Juri Lelli <[email protected]>
Cc Valentin Schneider <[email protected]>
Cc Dietmar Eggemann <[email protected]>
---
 include/linux/torture.h | 7 +++++--
 kernel/torture.c        | 6 +++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
include/linux/torture.h +5 -2
index 7038104463e4..bb466eec01e4 100644
@@ -108,12 +108,15 @@ bool torture_must_stop(void);
 bool torture_must_stop_irq(void);
 void torture_kthread_stopping(char *title);
 int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
-                            char *f, struct task_struct **tp);
+                            char *f, struct task_struct **tp, void (*cbf)(struct task_struct *tp));
 void _torture_stop_kthread(char *m, struct task_struct **tp);
 
 #define torture_create_kthread(n, arg, tp) \
        _torture_create_kthread(n, (arg), #n, "Creating " #n " task", \
-                               "Failed to create " #n, &(tp))
+                               "Failed to create " #n, &(tp), NULL)
+#define torture_create_kthread_cb(n, arg, tp, cbf) \
+       _torture_create_kthread(n, (arg), #n, "Creating " #n " task", \
+                               "Failed to create " #n, &(tp), cbf)
 #define torture_stop_kthread(n, tp) \
        _torture_stop_kthread("Stopping " #n " task", &(tp))
 
kernel/torture.c +5 -2
index 8be83fdc6be1..b88a1a86d9da 100644
@@ -932,7 +932,7 @@ EXPORT_SYMBOL_GPL(torture_kthread_stopping);
  * it starts, you will need to open-code your own.
  */
 int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
-                           char *f, struct task_struct **tp)
+                           char *f, struct task_struct **tp, void (*cbf)(struct task_struct *tp))
 {
        int ret = 0;
 
@@ -944,6 +944,10 @@ int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
                *tp = NULL;
                return ret;
        }
+
+       if (cbf)
+               cbf(*tp);
+
        wake_up_process(*tp);  // Process is sleeping, so ordering provided.
        torture_shuffle_task_register(*tp);
        return ret;
--

2.40.1

Acked-by on v1 1/2
#7 lore raw

Re: [PATCH rcu 1/2] torture: Add a kthread-creation callback to _torture_create_kthread()

In reply to Paul E. McKenney
Quoted 6 lines · Paul E. McKenney

This commit adds a kthread-creation callback to the _torture_create_kthread() function, which allows callers of a new torture_create_kthread_cb() macro to specify a function to be invoked after the kthread is created but before it is awakened for the first time.

Quoted 9 lines
Cc Dietmar Eggemann <[email protected]>
Cc John Stultz <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Joel Fernandes <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Valentin Schneider <[email protected]>
Cc Dietmar Eggemann <[email protected]>

Thanks for improving the patch this way!

author maintainer
#8 lore raw

PATCH 2/2 torture: Add lock_torture writer_fifo module parameter

In reply to Paul E. McKenney

From: Dietmar Eggemann <[email protected]>

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 Dietmar Eggemann <[email protected]>
[jstultz: Include header change to build, reword commit message]
---
 Documentation/admin-guide/kernel-parameters.txt |  4 ++++
 kernel/locking/locktorture.c                    | 12 +++++++-----
 kernel/torture.c                                |  3 ++-
 3 files changed, 13 insertions(+), 6 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +4 -0
index a1457995fd41..7b94455e9ae2 100644
@@ -2918,6 +2918,10 @@
 	locktorture.torture_type= [KNL]
 			Specify the locking implementation to test.
 
+	locktorture.writer_fifo= [KNL]
+			Run the write-side locktorture kthreads at
+			sched_set_fifo() real-time priority.
+
 	locktorture.verbose= [KNL]
 			Enable additional printk() statements.
 
kernel/locking/locktorture.c +7 -5
index 949d3deae506..270c7f80ce84 100644
@@ -45,6 +45,7 @@ torture_param(int, stutter, 5, "Number of jiffies to run/halt test, 0=disable");
 torture_param(int, rt_boost, 2,
 		   "Do periodic rt-boost. 0=Disable, 1=Only for rt_mutex, 2=For all lock types.");
 torture_param(int, rt_boost_factor, 50, "A factor determining how often rt-boost happens.");
+torture_param(int, writer_fifo, 0, "Run writers at sched_set_fifo() priority");
 torture_param(int, verbose, 1, "Enable verbose debugging printk()s");
 torture_param(int, nested_locks, 0, "Number of nested locks (max = 8)");
 /* Going much higher trips "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!" errors */
@@ -809,7 +810,8 @@ static int lock_torture_writer(void *arg)
 	bool skip_main_lock;
 
 	VERBOSE_TOROUT_STRING("lock_torture_writer task started");
-	set_user_nice(current, MAX_NICE);
+	if (!rt_task(current))
+		set_user_nice(current, MAX_NICE);
 
 	do {
 		if ((torture_random(&rand) & 0xfffff) == 0)
@@ -1015,8 +1017,7 @@ static void lock_torture_cleanup(void)
 
 	if (writer_tasks) {
 		for (i = 0; i < cxt.nrealwriters_stress; i++)
-			torture_stop_kthread(lock_torture_writer,
-					     writer_tasks[i]);
+			torture_stop_kthread(lock_torture_writer, writer_tasks[i]);
 		kfree(writer_tasks);
 		writer_tasks = NULL;
 	}
@@ -1244,8 +1245,9 @@ static int __init lock_torture_init(void)
 			goto create_reader;
 
 		/* Create writer. */
-		firsterr = torture_create_kthread(lock_torture_writer, &cxt.lwsa[i],
-						  writer_tasks[i]);
+		firsterr = torture_create_kthread_cb(lock_torture_writer, &cxt.lwsa[i],
+						     writer_tasks[i],
+						     writer_fifo ? sched_set_fifo : NULL);
 		if (torture_init_error(firsterr))
 			goto unwind;
 
kernel/torture.c +2 -1
index b88a1a86d9da..a1ac493488e2 100644
@@ -37,6 +37,7 @@
 #include <linux/ktime.h>
 #include <asm/byteorder.h>
 #include <linux/torture.h>
+#include <linux/sched/rt.h>
 #include "rcu/rcu.h"
 
 MODULE_LICENSE("GPL");
@@ -734,7 +735,7 @@ bool stutter_wait(const char *title)
 	cond_resched_tasks_rcu_qs();
 	spt = READ_ONCE(stutter_pause_test);
 	for (; spt; spt = READ_ONCE(stutter_pause_test)) {
-		if (!ret) {
+		if (!ret && !rt_task(current)) {
 			sched_set_normal(current, MAX_NICE);
 			ret = true;
 		}
Signature · 1 line
2.40.1
Acked-by on v1 2/2
#9 lore raw

Re: [PATCH rcu 2/2] torture: Add lock_torture writer_fifo module parameter

Quoted 9 lines · Paul E. McKenney

From: Dietmar Eggemann <[email protected]>

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

Quoted 6 lines
                                                                                                        ^^^^^^^^^^^^^

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. ]

Thanks again for improving this! I've switched over to your version here in my test tree.

thanks
-john

author maintainer
#10 lore raw

Re: [PATCH rcu 2/2] torture: Add lock_torture writer_fifo module parameter

Quoted 15 lines · John Stultz
Quoted 14 lines · Paul E. McKenney

From: Dietmar Eggemann <[email protected]>

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.

Quoted 6 lines
Quoted 1 line

[ paulmck: Remove locktorture-specific code from kernel/torture.c. ]

Thanks again for improving this! I've switched over to your version here in my test tree.

Thank you both! I will apply on my next rebase.

Thanx, Paul

author maintainer
#11 lore raw

PATCH 4/9 torture: Make torture_hrtimeout_*() use TASK_IDLE

In reply to Paul E. McKenney

Given that it is expected that more code will use torture_hrtimeout_*(), including for longer timeouts, make it use TASK_IDLE instead of TASK_UNINTERRUPTIBLE.

---
 kernel/torture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/torture.c +1 -1
index db79197e257a..836fefa44373 100644
@@ -96,7 +96,7 @@ int torture_hrtimeout_ns(ktime_t baset_ns, u32 fuzzt_ns, struct torture_random_s
 
 	if (trsp)
 		hto += (torture_random(trsp) >> 3) % fuzzt_ns;
-	set_current_state(TASK_UNINTERRUPTIBLE);
+	set_current_state(TASK_IDLE);
 	return schedule_hrtimeout(&hto, HRTIMER_MODE_REL);
 }
 EXPORT_SYMBOL_GPL(torture_hrtimeout_ns);
Signature · 1 line
2.40.1
author maintainer
#12 lore raw

PATCH 5/9 torture: Move torture_onoff() timeouts to hrtimers

In reply to Paul E. McKenney

In order to gain better race coverage, move the CPU-hotplug-related timed waits in torture_onoff() to torture_hrtimeout_jiffies().

---
 kernel/torture.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/torture.c +3 -3
index 836fefa44373..fc873116a399 100644
@@ -357,12 +357,12 @@ torture_onoff(void *arg)
 
 	if (onoff_holdoff > 0) {
 		VERBOSE_TOROUT_STRING("torture_onoff begin holdoff");
-		schedule_timeout_interruptible(onoff_holdoff);
+		torture_hrtimeout_jiffies(onoff_holdoff, &rand);
 		VERBOSE_TOROUT_STRING("torture_onoff end holdoff");
 	}
 	while (!torture_must_stop()) {
 		if (disable_onoff_at_boot && !rcu_inkernel_boot_has_ended()) {
-			schedule_timeout_interruptible(HZ / 10);
+			torture_hrtimeout_jiffies(HZ / 10, &rand);
 			continue;
 		}
 		cpu = (torture_random(&rand) >> 4) % (maxcpu + 1);
@@ -372,7 +372,7 @@ torture_onoff(void *arg)
 			torture_online(cpu,
 				       &n_online_attempts, &n_online_successes,
 				       &sum_online, &min_online, &max_online);
-		schedule_timeout_interruptible(onoff_interval);
+		torture_hrtimeout_jiffies(onoff_interval, &rand);
 	}
 
 stop:
Signature · 1 line
2.40.1
author maintainer
#13 lore raw

PATCH 6/9 torture: Move torture_shuffle() timeouts to hrtimers

In reply to Paul E. McKenney

In order to gain better race coverage, move the CPU-migration timed waits in torture_shuffle() to torture_hrtimeout_jiffies().

---
 kernel/torture.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/torture.c +3 -1
index fc873116a399..3ab4930b9fdb 100644
@@ -560,9 +560,11 @@ static void torture_shuffle_tasks(void)
  */
 static int torture_shuffle(void *arg)
 {
+	DEFINE_TORTURE_RANDOM(rand);
+
 	VERBOSE_TOROUT_STRING("torture_shuffle task started");
 	do {
-		schedule_timeout_interruptible(shuffle_interval);
+		torture_hrtimeout_jiffies(shuffle_interval, &rand);
 		torture_shuffle_tasks();
 		torture_shutdown_absorb("torture_shuffle");
 	} while (!torture_must_stop());
Signature · 1 line
2.40.1
author maintainer
#14 lore raw

PATCH 7/9 torture: Move stutter_wait() timeouts to hrtimers

In reply to Paul E. McKenney

In order to gain better race coverage, move the test start/stop waits in stutter_wait() to torture_hrtimeout_jiffies().

---
 kernel/torture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/torture.c +2 -2
index 3ab4930b9fdb..92704f04a141 100644
@@ -745,7 +745,7 @@ bool stutter_wait(const char *title)
 			ret = true;
 		}
 		if (spt == 1) {
-			schedule_timeout_interruptible(1);
+			torture_hrtimeout_jiffies(1, NULL);
 		} else if (spt == 2) {
 			while (READ_ONCE(stutter_pause_test)) {
 				if (!(i++ & 0xffff))
@@ -753,7 +753,7 @@ bool stutter_wait(const char *title)
 				cond_resched();
 			}
 		} else {
-			schedule_timeout_interruptible(round_jiffies_relative(HZ));
+			torture_hrtimeout_jiffies(round_jiffies_relative(HZ), NULL);
 		}
 		torture_shutdown_absorb(title);
 	}
Signature · 1 line
2.40.1
author maintainer
#15 lore raw

PATCH 8/9 torture: Stop right-shifting torture_random() return values

In reply to Paul E. McKenney

Now that torture_random() uses swahw32(), its callers no longer see not-so-random low-order bits, as these are now swapped up into the upper 16 bits of the torture_random() function's return value. This commit therefore removes the right-shifting of torture_random() return values.

---
 kernel/torture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/torture.c +2 -2
index 92704f04a141..b59eb6048eab 100644
@@ -95,7 +95,7 @@ int torture_hrtimeout_ns(ktime_t baset_ns, u32 fuzzt_ns, struct torture_random_s
 	ktime_t hto = baset_ns;
 
 	if (trsp)
-		hto += (torture_random(trsp) >> 3) % fuzzt_ns;
+		hto += torture_random(trsp) % fuzzt_ns;
 	set_current_state(TASK_IDLE);
 	return schedule_hrtimeout(&hto, HRTIMER_MODE_REL);
 }
@@ -365,7 +365,7 @@ torture_onoff(void *arg)
 			torture_hrtimeout_jiffies(HZ / 10, &rand);
 			continue;
 		}
-		cpu = (torture_random(&rand) >> 4) % (maxcpu + 1);
+		cpu = torture_random(&rand) % (maxcpu + 1);
 		if (!torture_offline(cpu,
 				     &n_offline_attempts, &n_offline_successes,
 				     &sum_offline, &min_offline, &max_offline))
Signature · 1 line
2.40.1
author maintainer
#16 lore raw

PATCH 9/9 rcutorture: Stop right-shifting torture_random() return values

In reply to Paul E. McKenney

Now that torture_random() uses swahw32(), its callers no longer see not-so-random low-order bits, as these are now swapped up into the upper 16 bits of the torture_random() function's return value. This commit therefore removes the right-shifting of torture_random() return values.

---
 kernel/rcu/rcutorture.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/rcu/rcutorture.c +3 -3
index d291a1438c30..ade42d6a9d9b 100644
@@ -1877,7 +1877,7 @@ static int
 rcutorture_extend_mask(int oldmask, struct torture_random_state *trsp)
 {
 	int mask = rcutorture_extend_mask_max();
-	unsigned long randmask1 = torture_random(trsp) >> 8;
+	unsigned long randmask1 = torture_random(trsp);
 	unsigned long randmask2 = randmask1 >> 3;
 	unsigned long preempts = RCUTORTURE_RDR_PREEMPT | RCUTORTURE_RDR_SCHED;
 	unsigned long preempts_irq = preempts | RCUTORTURE_RDR_IRQ;
@@ -1936,7 +1936,7 @@ rcutorture_loop_extend(int *readstate, struct torture_random_state *trsp,
 	if (!((mask - 1) & mask))
 		return rtrsp;  /* Current RCU reader not extendable. */
 	/* Bias towards larger numbers of loops. */
-	i = (torture_random(trsp) >> 3);
+	i = torture_random(trsp);
 	i = ((i | (i >> 3)) & RCUTORTURE_RDR_MAX_LOOPS) + 1;
 	for (j = 0; j < i; j++) {
 		mask = rcutorture_extend_mask(*readstate, trsp);
@@ -2137,7 +2137,7 @@ static int rcu_nocb_toggle(void *arg)
 		toggle_fuzz = NSEC_PER_USEC;
 	do {
 		r = torture_random(&rand);
-		cpu = (r >> 4) % (maxcpu + 1);
+		cpu = (r >> 1) % (maxcpu + 1);
 		if (r & 0x1) {
 			rcu_nocb_cpu_offload(cpu);
 			atomic_long_inc(&n_nocb_offload);
Signature · 1 line
2.40.1