Skip to contentSkip to conversation

My new rcutorture patches for 6.15

PATCH Superseded Joel Fernandes 1 participant 5 messages Apr 15, 2025

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Joel Fernandes

author maintainer
#0 lore raw

v4 cover My new rcutorture patches for 6.15

The gpwrap one is is v4 where I just fixed the hrtimer_init() since v2.

The ARM64 image check is now in my for-next branch, it is required to do large scale tests with SRCU.

(These are only the new commits, the existing ones in my for-next branch for rcutorture will be sent separately once we figure out which one of them is causing SRCU issues).

Joel Fernandes (2):
rcutorture: Perform more frequent testing of ->gpwrap
rcutorture: Fix issue with re-using old images on ARM64

 kernel/rcu/rcu.h                              |  4 ++
 kernel/rcu/rcutorture.c                       | 68 ++++++++++++++++++-
 kernel/rcu/tree.c                             | 34 +++++++++-
 kernel/rcu/tree.h                             |  1 +
 .../rcutorture/bin/kvm-test-1-run.sh          |  2 +-
 6 files changed, 107 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v4 1/2 rcutorture: Perform more frequent testing of ->gpwrap

Currently, the ->gpwrap is not tested (at all per my testing) due to the requirement of a large delta between a CPU's rdp->gp_seq and its node's rnp->gpseq.

This results in no testing of ->gpwrap being set. This patch by default adds 5 minutes of testing with ->gpwrap forced by lowering the delta between rdp->gp_seq and rnp->gp_seq to just 8 GPs. All of this is configurable, including the active time for the setting and a full testing cycle.

By default, the first 25 minutes of a test will have the _default_ behavior there is right now (ULONG_MAX / 4) delta. Then for 5 minutes, we switch to a smaller delta causing 1-2 wraps in 5 minutes. I believe this is reasonable since we at least add a little bit of testing for usecases where ->gpwrap is set.

---
 kernel/rcu/rcu.h        |  4 +++
 kernel/rcu/rcutorture.c | 67 ++++++++++++++++++++++++++++++++++++++++-
 kernel/rcu/tree.c       | 34 +++++++++++++++++++--
 kernel/rcu/tree.h       |  1 +
 4 files changed, 103 insertions(+), 3 deletions(-)
kernel/rcu/rcu.h +4 -0
index eed2951a4962..516b26024a37 100644
@@ -572,6 +572,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
 			       unsigned long c_old,
 			       unsigned long c);
 void rcu_gp_set_torture_wait(int duration);
+void rcu_set_gpwrap_lag(unsigned long lag);
+int rcu_get_gpwrap_count(int cpu);
 #else
 static inline void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq)
 {
@@ -589,6 +591,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
 	do { } while (0)
 #endif
 static inline void rcu_gp_set_torture_wait(int duration) { }
+static inline void rcu_set_gpwrap_lag(unsigned long lag) { }
+static inline int rcu_get_gpwrap_count(int cpu) { return 0; }
 #endif
 unsigned long long rcutorture_gather_gp_seqs(void);
 void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp, size_t len);
kernel/rcu/rcutorture.c +66 -1

122 lines not on this page · raw message

kernel/rcu/tree.c +32 -2
index 659f83e71048..6ec30d07759d 100644
@@ -80,6 +80,15 @@ static void rcu_sr_normal_gp_cleanup_work(struct work_struct *);
 static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_data, rcu_data) = {
 	.gpwrap = true,
 };
+
+int rcu_get_gpwrap_count(int cpu)
+{
+	struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
+
+	return READ_ONCE(rdp->gpwrap_count);
+}
+EXPORT_SYMBOL_GPL(rcu_get_gpwrap_count);
+
 static struct rcu_state rcu_state = {
 	.level = { &rcu_state.node[0] },
 	.gp_state = RCU_GP_IDLE,
@@ -757,6 +766,25 @@ void rcu_request_urgent_qs_task(struct task_struct *t)
 	smp_store_release(per_cpu_ptr(&rcu_data.rcu_urgent_qs, cpu), true);
 }
 
+/**
+ * rcu_set_gpwrap_lag - Set RCU GP sequence overflow lag value.
+ * @lag_gps: Set overflow lag to this many grace period worth of counters
+ * which is used by rcutorture to quickly force a gpwrap situation.
+ * @lag_gps = 0 means we reset it back to the boot-time value.
+ */
+static unsigned long seq_gpwrap_lag = ULONG_MAX / 4;
+
+void rcu_set_gpwrap_lag(unsigned long lag_gps)
+{
+	unsigned long lag_seq_count;
+
+	lag_seq_count = (lag_gps == 0)
+			? ULONG_MAX / 4
+			: lag_gps << RCU_SEQ_CTR_SHIFT;
+	WRITE_ONCE(seq_gpwrap_lag, lag_seq_count);
+}
+EXPORT_SYMBOL_GPL(rcu_set_gpwrap_lag);
+
 /*
  * When trying to report a quiescent state on behalf of some other CPU,
  * it is our responsibility to check for and handle potential overflow
@@ -767,9 +795,11 @@ void rcu_request_urgent_qs_task(struct task_struct *t)
 static void rcu_gpnum_ovf(struct rcu_node *rnp, struct rcu_data *rdp)
 {
 	raw_lockdep_assert_held_rcu_node(rnp);
-	if (ULONG_CMP_LT(rcu_seq_current(&rdp->gp_seq) + ULONG_MAX / 4,
-			 rnp->gp_seq))
+	if (ULONG_CMP_LT(rcu_seq_current(&rdp->gp_seq) + seq_gpwrap_lag,
+			 rnp->gp_seq)) {
 		WRITE_ONCE(rdp->gpwrap, true);
+		WRITE_ONCE(rdp->gpwrap_count, READ_ONCE(rdp->gpwrap_count) + 1);
+	}
 	if (ULONG_CMP_LT(rdp->rcu_iw_gp_seq + ULONG_MAX / 4, rnp->gp_seq))
 		rdp->rcu_iw_gp_seq = rnp->gp_seq + ULONG_MAX / 4;
 }
kernel/rcu/tree.h +1 -0
index a9a811d9d7a3..63bea388c243 100644
@@ -183,6 +183,7 @@ struct rcu_data {
 	bool		core_needs_qs;	/* Core waits for quiescent state. */
 	bool		beenonline;	/* CPU online at least once. */
 	bool		gpwrap;		/* Possible ->gp_seq wrap. */
+	unsigned int	gpwrap_count;	/* Count of GP sequence wrap. */
 	bool		cpu_started;	/* RCU watching this onlining CPU. */
 	struct rcu_node *mynode;	/* This CPU's leaf of hierarchy */
 	unsigned long grpmask;		/* Mask to apply to leaf qsmask. */
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v4 2/2 rcutorture: Fix issue with re-using old images on ARM64

In reply to Joel Fernandes

On ARM64, when running with --configs '36*SRCU-P', I noticed that only 1 instance instead of 36 for starting.

Fix it by checking for Image files, instead of bzImage which ARM does not seem to have. With this I see all 36 instances running at the same time in the batch.

---
 kernel/rcu/rcutorture.c                                  | 3 ++-
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
kernel/rcu/rcutorture.c +2 -1
index 74de92c3a9ab..df6504a855aa 100644
@@ -2412,7 +2412,8 @@ rcu_torture_stats_print(void)
 			pipesummary[i] += READ_ONCE(per_cpu(rcu_torture_count, cpu)[i]);
 			batchsummary[i] += READ_ONCE(per_cpu(rcu_torture_batch, cpu)[i]);
 		}
-		n_gpwraps += cur_ops->get_gpwrap_count(cpu);
+		if (cur_ops->get_gpwrap_count)
+			n_gpwraps += cur_ops->get_gpwrap_count(cpu);
 	}
 	for (i = RCU_TORTURE_PIPE_LEN; i >= 0; i--) {
 		if (pipesummary[i] != 0)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +1 -1
index ad79784e552d..957800c9ffba 100755
@@ -73,7 +73,7 @@ config_override_param "$config_dir/CFcommon.$(uname -m)" KcList \
 cp $T/KcList $resdir/ConfigFragment
 
 base_resdir=`echo $resdir | sed -e 's/\.[0-9]\+$//'`
-if test "$base_resdir" != "$resdir" && test -f $base_resdir/bzImage && test -f $base_resdir/vmlinux
+if test "$base_resdir" != "$resdir" && (test -f $base_resdir/bzImage || test -f $base_resdir/Image) && test -f $base_resdir/vmlinux
 then
 	# Rerunning previous test, so use that test's kernel.
 	QEMU="`identify_qemu $base_resdir/vmlinux`"
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

Re: [PATCH v4 2/2] rcutorture: Fix issue with re-using old images on ARM64

Quoted 19 lines · Joel Fernandes

On ARM64, when running with --configs '36*SRCU-P', I noticed that only 1 instance instead of 36 for starting.

Fix it by checking for Image files, instead of bzImage which ARM does not seem to have. With this I see all 36 instances running at the same time in the batch.

---
 kernel/rcu/rcutorture.c                                  | 3 ++-
 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
kernel/rcu/rcutorture.c +0 -0
index 74de92c3a9ab..df6504a855aa 100644

kernel/rcu/rcutorture.c rcu_torture_stats_print(void) · line 2417

Quoted 7 lines
kernel/rcu/rcutorture.c +2 -1
@@ -2412,7 +2412,8 @@ rcu_torture_stats_print(void)
 			pipesummary[i] += READ_ONCE(per_cpu(rcu_torture_count, cpu)[i]);
 			batchsummary[i] += READ_ONCE(per_cpu(rcu_torture_batch, cpu)[i]);
 		}
-		n_gpwraps += cur_ops->get_gpwrap_count(cpu);
+		if (cur_ops->get_gpwrap_count)
+			n_gpwraps += cur_ops->get_gpwrap_count(cpu);
 	}

Oops, this hunk was supposed to go into the previous patch. I fixed it in my tree and will post with the full set of torture patches later:

https://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git/log/?h=rcu/torture-for-6.16

Thanks.

author maintainer
#4 lore raw
In reply to Joel Fernandes
Quoted 13 lines · Joel Fernandes

The gpwrap one is is v4 where I just fixed the hrtimer_init() since v2.

The ARM64 image check is now in my for-next branch, it is required to do large scale tests with SRCU.

(These are only the new commits, the existing ones in my for-next branch for rcutorture will be sent separately once we figure out which one of them is causing SRCU issues).

Joel Fernandes (2):
rcutorture: Perform more frequent testing of ->gpwrap
rcutorture: Fix issue with re-using old images on ARM64

Quoted 7 lines
 kernel/rcu/rcu.h                              |  4 ++
 kernel/rcu/rcutorture.c                       | 68 ++++++++++++++++++-
 kernel/rcu/tree.c                             | 34 +++++++++-
 kernel/rcu/tree.h                             |  1 +
 .../rcutorture/bin/kvm-test-1-run.sh          |  2 +-
 6 files changed, 107 insertions(+), 6 deletions(-)

Oops, s/15/16/ in subject :)

- Joel