* [PATCH rcu 00/11] RCU torture changes for v6.15
@ 2025-02-19 15:39 Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 01/11] torture: Add get_torture_init_jiffies() for test-start time Boqun Feng
` (10 more replies)
0 siblings, 11 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
Hi,
Please find the upcoming changes in rcutorture for v6.15. The
changes can also be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git torture.2025.02.05a
Regards,
Boqun
Paul E. McKenney (11):
torture: Add get_torture_init_jiffies() for test-start time
rcutorture: Add a test_boost_holdoff module parameter
rcutorture: Include grace-period sequence numbers in
failure/close-call
rcutorture: Expand failure/close-call grace-period output
rcu: Trace expedited grace-period numbers in hexadecimal
rcutorture: Add ftrace-compatible timestamp to GP# failure/close-call
output
rcutorture: Make cur_ops->format_gp_seqs take buffer length
rcutorture: Move RCU_TORTURE_TEST_{CHK_RDR_STATE,LOG_CPU} to bool
rcutorture: Complain when invalid SRCU reader_flavor is specified
srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
torture: Make SRCU lockdep testing use srcu_read_lock_nmisafe()
.../admin-guide/kernel-parameters.txt | 5 ++
include/linux/torture.h | 1 +
include/trace/events/rcu.h | 2 +-
kernel/rcu/Kconfig | 11 ++++
kernel/rcu/Kconfig.debug | 18 ++++-
kernel/rcu/rcu.h | 2 +
kernel/rcu/rcutorture.c | 65 +++++++++++++++++--
kernel/rcu/tiny.c | 14 ++++
kernel/rcu/tree.c | 20 ++++++
kernel/torture.c | 12 ++++
.../selftests/rcutorture/bin/srcu_lockdep.sh | 2 +-
11 files changed, 144 insertions(+), 8 deletions(-)
--
2.39.5 (Apple Git-154)
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH rcu 01/11] torture: Add get_torture_init_jiffies() for test-start time
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 02/11] rcutorture: Add a test_boost_holdoff module parameter Boqun Feng
` (9 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
From: "Paul E. McKenney" <paulmck@kernel.org>
This commit adds a get_torture_init_jiffies() function that returns the
value of the jiffies counter at the start of the test, that is, at the
point where torture_init_begin() was invoked.
This will be used to enable torture-test holdoffs for tests implemented
using per-CPU kthreads, which are created and deleted by CPU-hotplug
operations, and thus (unlike normal kthreads) don't automatically know
when the test started.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
include/linux/torture.h | 1 +
kernel/torture.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/include/linux/torture.h b/include/linux/torture.h
index 0134e7221cae..1b59056c3b18 100644
--- a/include/linux/torture.h
+++ b/include/linux/torture.h
@@ -104,6 +104,7 @@ int torture_stutter_init(int s, int sgap);
/* Initialization and cleanup. */
bool torture_init_begin(char *ttype, int v);
void torture_init_end(void);
+unsigned long get_torture_init_jiffies(void);
bool torture_cleanup_begin(void);
void torture_cleanup_end(void);
bool torture_must_stop(void);
diff --git a/kernel/torture.c b/kernel/torture.c
index dede150aef01..3a0a8cc60401 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -792,6 +792,8 @@ static void torture_stutter_cleanup(void)
stutter_task = NULL;
}
+static unsigned long torture_init_jiffies;
+
static void
torture_print_module_parms(void)
{
@@ -821,6 +823,7 @@ bool torture_init_begin(char *ttype, int v)
torture_type = ttype;
verbose = v;
fullstop = FULLSTOP_DONTSTOP;
+ WRITE_ONCE(torture_init_jiffies, jiffies); // Lockless reads.
torture_print_module_parms();
return true;
}
@@ -836,6 +839,15 @@ void torture_init_end(void)
}
EXPORT_SYMBOL_GPL(torture_init_end);
+/*
+ * Get the torture_init_begin()-time value of the jiffies counter.
+ */
+unsigned long get_torture_init_jiffies(void)
+{
+ return READ_ONCE(torture_init_jiffies);
+}
+EXPORT_SYMBOL_GPL(get_torture_init_jiffies);
+
/*
* Clean up torture module. Please note that this is -not- invoked via
* the usual module_exit() mechanism, but rather by an explicit call from
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 02/11] rcutorture: Add a test_boost_holdoff module parameter
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 01/11] torture: Add get_torture_init_jiffies() for test-start time Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 03/11] rcutorture: Include grace-period sequence numbers in failure/close-call Boqun Feng
` (8 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
From: "Paul E. McKenney" <paulmck@kernel.org>
This commit adds a test_boost_holdoff module parameter that tells the RCU
priority-boosting tests to wait for the specified number of seconds past
the start of the rcutorture test. This can be useful when rcutorture
is built into the kernel (as opposed to being modprobed), especially on
large systems where early start of RCU priority boosting can delay the
boot sequence, which adds a full CPU's worth of load onto the system.
This can in turn result in pointless stall warnings.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
.../admin-guide/kernel-parameters.txt | 5 +++++
kernel/rcu/rcutorture.c | 19 ++++++++++++++++---
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index fb8752b42ec8..ed1a0df03b18 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5758,6 +5758,11 @@
rcutorture.test_boost_duration= [KNL]
Duration (s) of each individual boost test.
+ rcutorture.test_boost_holdoff= [KNL]
+ Holdoff time (s) from start of test to the start
+ of RCU priority-boost testing. Defaults to zero,
+ that is, no holdoff.
+
rcutorture.test_boost_interval= [KNL]
Interval (s) between each boost test.
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index d26fb1d33ed9..fbf1d7fcf61d 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -135,6 +135,7 @@ torture_param(int, stat_interval, 60, "Number of seconds between stats printk()s
torture_param(int, stutter, 5, "Number of seconds to run/halt test");
torture_param(int, test_boost, 1, "Test RCU prio boost: 0=no, 1=maybe, 2=yes.");
torture_param(int, test_boost_duration, 4, "Duration of each boost test, seconds.");
+torture_param(int, test_boost_holdoff, 0, "Holdoff time from rcutorture start, seconds.");
torture_param(int, test_boost_interval, 7, "Interval between boost tests, seconds.");
torture_param(int, test_nmis, 0, "End-test NMI tests, 0 to disable.");
torture_param(bool, test_no_idle_hz, true, "Test support for tickless idle CPUs");
@@ -1148,8 +1149,19 @@ static int rcu_torture_boost(void *arg)
unsigned long gp_state;
unsigned long gp_state_time;
unsigned long oldstarttime;
+ unsigned long booststarttime = get_torture_init_jiffies() + test_boost_holdoff * HZ;
- VERBOSE_TOROUT_STRING("rcu_torture_boost started");
+ if (test_boost_holdoff <= 0 || time_after(jiffies, booststarttime)) {
+ VERBOSE_TOROUT_STRING("rcu_torture_boost started");
+ } else {
+ VERBOSE_TOROUT_STRING("rcu_torture_boost started holdoff period");
+ while (time_before(jiffies, booststarttime)) {
+ schedule_timeout_idle(HZ);
+ if (kthread_should_stop())
+ goto cleanup;
+ }
+ VERBOSE_TOROUT_STRING("rcu_torture_boost finished holdoff period");
+ }
/* Set real-time priority. */
sched_set_fifo_low(current);
@@ -1225,6 +1237,7 @@ checkwait: if (stutter_wait("rcu_torture_boost"))
sched_set_fifo_low(current);
} while (!torture_must_stop());
+cleanup:
/* Clean up and exit. */
while (!kthread_should_stop()) {
torture_shutdown_absorb("rcu_torture_boost");
@@ -2512,7 +2525,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)
"shuffle_interval=%d stutter=%d irqreader=%d "
"fqs_duration=%d fqs_holdoff=%d fqs_stutter=%d "
"test_boost=%d/%d test_boost_interval=%d "
- "test_boost_duration=%d shutdown_secs=%d "
+ "test_boost_duration=%d test_boost_holdoff=%d shutdown_secs=%d "
"stall_cpu=%d stall_cpu_holdoff=%d stall_cpu_irqsoff=%d "
"stall_cpu_block=%d stall_cpu_repeat=%d "
"n_barrier_cbs=%d "
@@ -2526,7 +2539,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)
stat_interval, verbose, test_no_idle_hz, shuffle_interval,
stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter,
test_boost, cur_ops->can_boost,
- test_boost_interval, test_boost_duration, shutdown_secs,
+ test_boost_interval, test_boost_duration, test_boost_holdoff, shutdown_secs,
stall_cpu, stall_cpu_holdoff, stall_cpu_irqsoff,
stall_cpu_block, stall_cpu_repeat,
n_barrier_cbs,
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 03/11] rcutorture: Include grace-period sequence numbers in failure/close-call
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 01/11] torture: Add get_torture_init_jiffies() for test-start time Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 02/11] rcutorture: Add a test_boost_holdoff module parameter Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 04/11] rcutorture: Expand failure/close-call grace-period output Boqun Feng
` (7 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest, kernel test robot
From: "Paul E. McKenney" <paulmck@kernel.org>
This commit includes the grace-period sequence numbers at the beginning
and end of each segment in the "Failure/close-call rcutorture reader
segments" list. These are in hexadecimal, and only the bottom byte.
Currently, only RCU is supported, with its three sequence numbers (normal,
expedited, and polled).
Note that if all the grace-period sequence numbers remain the same across
a given reader segment, only one copy of the number will be printed.
Of course, if there is a change, both sets of values will be printed.
Because the overhead of collecting this information can suppress
heisenbugs, this information is collected and printed only in kernels
built with CONFIG_RCU_TORTURE_TEST_LOG_GP=y.
[ paulmck: Apply Nathan Chancellor feedback for IS_ENABLED(). ]
[ paulmck: Apply feedback from kernel test robot. ]
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Tested-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
kernel/rcu/Kconfig.debug | 14 ++++++++++++++
kernel/rcu/rcu.h | 2 ++
kernel/rcu/rcutorture.c | 34 ++++++++++++++++++++++++++++++++++
kernel/rcu/tiny.c | 14 ++++++++++++++
kernel/rcu/tree.c | 20 ++++++++++++++++++++
5 files changed, 84 insertions(+)
diff --git a/kernel/rcu/Kconfig.debug b/kernel/rcu/Kconfig.debug
index 6af90510a1ca..25a9dc2be0dc 100644
--- a/kernel/rcu/Kconfig.debug
+++ b/kernel/rcu/Kconfig.debug
@@ -84,6 +84,20 @@ config RCU_TORTURE_TEST_LOG_CPU
Say Y here if you want CPU IDs logged.
Say N if you are unsure.
+config RCU_TORTURE_TEST_LOG_GP
+ bool "Log grace-period numbers for rcutorture failures"
+ depends on RCU_TORTURE_TEST
+ default n
+ help
+ This option causes rcutorture to decorate each entry of its
+ log of failure/close-call rcutorture reader segments with the
+ corresponding grace-period sequence numbers. This information
+ can be useful, but it does incur additional overhead, overhead
+ that can make both failures and close calls less probable.
+
+ Say Y here if you want grace-period sequence numbers logged.
+ Say N if you are unsure.
+
config RCU_REF_SCALE_TEST
tristate "Scalability tests for read-side synchronization (RCU and others)"
depends on DEBUG_KERNEL
diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index feb3ac1dc5d5..a6098997a14b 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -590,6 +590,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
#endif
static inline void rcu_gp_set_torture_wait(int duration) { }
#endif
+unsigned long rcutorture_gather_gp_seqs(void);
+void rcutorture_format_gp_seqs(unsigned long seqs, char *cp);
#ifdef CONFIG_TINY_SRCU
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index fbf1d7fcf61d..2113583cae34 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -273,6 +273,8 @@ struct rt_read_seg {
bool rt_preempted;
int rt_cpu;
int rt_end_cpu;
+ unsigned long rt_gp_seq;
+ unsigned long rt_gp_seq_end;
};
static int err_segs_recorded;
static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS];
@@ -407,6 +409,8 @@ struct rcu_torture_ops {
void (*gp_slow_register)(atomic_t *rgssp);
void (*gp_slow_unregister)(atomic_t *rgssp);
bool (*reader_blocked)(void);
+ unsigned long (*gather_gp_seqs)(void);
+ void (*format_gp_seqs)(unsigned long seqs, char *cp);
long cbflood_max;
int irq_capable;
int can_boost;
@@ -611,6 +615,8 @@ static struct rcu_torture_ops rcu_ops = {
.reader_blocked = IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_CPU)
? has_rcu_reader_blocked
: NULL,
+ .gather_gp_seqs = rcutorture_gather_gp_seqs,
+ .format_gp_seqs = rcutorture_format_gp_seqs,
.irq_capable = 1,
.can_boost = IS_ENABLED(CONFIG_RCU_BOOST),
.extendables = RCUTORTURE_MAX_EXTEND,
@@ -656,6 +662,8 @@ static struct rcu_torture_ops rcu_busted_ops = {
.sync = synchronize_rcu_busted,
.exp_sync = synchronize_rcu_busted,
.call = call_rcu_busted,
+ .gather_gp_seqs = rcutorture_gather_gp_seqs,
+ .format_gp_seqs = rcutorture_format_gp_seqs,
.irq_capable = 1,
.extendables = RCUTORTURE_MAX_EXTEND,
.name = "busted"
@@ -1978,6 +1986,12 @@ static void rcutorture_one_extend(int *readstate, int newstate, bool insoftirq,
rtrsp[-1].rt_preempted = cur_ops->reader_blocked();
}
}
+ // Sample grace-period sequence number, as good a place as any.
+ if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_GP) && cur_ops->gather_gp_seqs) {
+ rtrsp->rt_gp_seq = cur_ops->gather_gp_seqs();
+ if (!first)
+ rtrsp[-1].rt_gp_seq_end = rtrsp->rt_gp_seq;
+ }
/*
* Next, remove old protection, in decreasing order of strength
@@ -3566,6 +3580,7 @@ rcu_torture_cleanup(void)
int flags = 0;
unsigned long gp_seq = 0;
int i;
+ int j;
if (torture_cleanup_begin()) {
if (cur_ops->cb_barrier != NULL) {
@@ -3661,6 +3676,25 @@ rcu_torture_cleanup(void)
else
pr_cont(" ...");
}
+ if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_GP) &&
+ cur_ops->gather_gp_seqs && cur_ops->format_gp_seqs) {
+ char buf1[16+1];
+ char buf2[16+1];
+ char sepchar = '-';
+
+ cur_ops->format_gp_seqs(err_segs[i].rt_gp_seq, buf1);
+ cur_ops->format_gp_seqs(err_segs[i].rt_gp_seq_end, buf2);
+ if (err_segs[i].rt_gp_seq == err_segs[i].rt_gp_seq_end) {
+ if (buf2[0]) {
+ for (j = 0; buf2[j]; j++)
+ buf2[j] = '.';
+ if (j)
+ buf2[j - 1] = ' ';
+ }
+ sepchar = ' ';
+ }
+ pr_cont(" %s%c%s", buf1, sepchar, buf2);
+ }
if (err_segs[i].rt_delay_ms != 0) {
pr_cont(" %s%ldms", firsttime ? "" : "+",
err_segs[i].rt_delay_ms);
diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
index 4b3f31911465..f9c4a24dc59c 100644
--- a/kernel/rcu/tiny.c
+++ b/kernel/rcu/tiny.c
@@ -257,6 +257,20 @@ void kvfree_call_rcu(struct rcu_head *head, void *ptr)
EXPORT_SYMBOL_GPL(kvfree_call_rcu);
#endif
+#if IS_ENABLED(CONFIG_RCU_TORTURE_TEST)
+unsigned long rcutorture_gather_gp_seqs(void)
+{
+ return READ_ONCE(rcu_ctrlblk.gp_seq) & 0xff;
+}
+EXPORT_SYMBOL_GPL(rcutorture_gather_gp_seqs);
+
+void rcutorture_format_gp_seqs(unsigned long seqs, char *cp)
+{
+ snprintf(cp, 8, "g%02lx", seqs & 0xff);
+}
+EXPORT_SYMBOL_GPL(rcutorture_format_gp_seqs);
+#endif
+
void __init rcu_init(void)
{
open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 475f31deed14..e40c4b5c3267 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -538,6 +538,26 @@ void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq)
}
EXPORT_SYMBOL_GPL(rcutorture_get_gp_data);
+/* Gather grace-period sequence numbers for rcutorture diagnostics. */
+unsigned long rcutorture_gather_gp_seqs(void)
+{
+ return ((READ_ONCE(rcu_state.gp_seq) & 0xff) << 16) |
+ ((READ_ONCE(rcu_state.expedited_sequence) & 0xff) << 8) |
+ (READ_ONCE(rcu_state.gp_seq_polled) & 0xff);
+}
+EXPORT_SYMBOL_GPL(rcutorture_gather_gp_seqs);
+
+/* Format grace-period sequence numbers for rcutorture diagnostics. */
+void rcutorture_format_gp_seqs(unsigned long seqs, char *cp)
+{
+ unsigned int egp = (seqs >> 8) & 0xff;
+ unsigned int ggp = (seqs >> 16) & 0xff;
+ unsigned int pgp = seqs & 0xff;
+
+ snprintf(cp, 16, "g%02x:e%02x:p%02x", ggp, egp, pgp);
+}
+EXPORT_SYMBOL_GPL(rcutorture_format_gp_seqs);
+
#if defined(CONFIG_NO_HZ_FULL) && (!defined(CONFIG_GENERIC_ENTRY) || !defined(CONFIG_KVM_XFER_TO_GUEST_WORK))
/*
* An empty function that will trigger a reschedule on
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 04/11] rcutorture: Expand failure/close-call grace-period output
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
` (2 preceding siblings ...)
2025-02-19 15:39 ` [PATCH rcu 03/11] rcutorture: Include grace-period sequence numbers in failure/close-call Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 05/11] rcu: Trace expedited grace-period numbers in hexadecimal Boqun Feng
` (6 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
From: "Paul E. McKenney" <paulmck@kernel.org>
With only eight bits per grace-period sequence number, wrap can happen
in 64 grace periods. This commit therefore increases this to sixteen
bits for normal grace-period sequence numbers and the combined short-form
polling sequence numbers, thus deferring wrap for at least 16,384 grace
periods. Because expedited grace periods go faster, expand these to 24
bits, deferring wrap for at least 4,194,304 expedited grace periods.
These longer wrap times makes it easier to correlate these numbers to
trace-event output.
Note that the low-order two bits are reserved for intra-grace-period
state, hence the above wrap numbers being a factor of four smaller than
you might expect.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
kernel/rcu/rcu.h | 4 ++--
kernel/rcu/rcutorture.c | 12 ++++++------
kernel/rcu/tiny.c | 8 ++++----
kernel/rcu/tree.c | 18 +++++++++---------
4 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index a6098997a14b..705fcbe6f500 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -590,8 +590,8 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
#endif
static inline void rcu_gp_set_torture_wait(int duration) { }
#endif
-unsigned long rcutorture_gather_gp_seqs(void);
-void rcutorture_format_gp_seqs(unsigned long seqs, char *cp);
+unsigned long long rcutorture_gather_gp_seqs(void);
+void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp);
#ifdef CONFIG_TINY_SRCU
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 2113583cae34..fb1b80498ae0 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -273,8 +273,8 @@ struct rt_read_seg {
bool rt_preempted;
int rt_cpu;
int rt_end_cpu;
- unsigned long rt_gp_seq;
- unsigned long rt_gp_seq_end;
+ unsigned long long rt_gp_seq;
+ unsigned long long rt_gp_seq_end;
};
static int err_segs_recorded;
static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS];
@@ -409,8 +409,8 @@ struct rcu_torture_ops {
void (*gp_slow_register)(atomic_t *rgssp);
void (*gp_slow_unregister)(atomic_t *rgssp);
bool (*reader_blocked)(void);
- unsigned long (*gather_gp_seqs)(void);
- void (*format_gp_seqs)(unsigned long seqs, char *cp);
+ unsigned long long (*gather_gp_seqs)(void);
+ void (*format_gp_seqs)(unsigned long long seqs, char *cp);
long cbflood_max;
int irq_capable;
int can_boost;
@@ -3678,8 +3678,8 @@ rcu_torture_cleanup(void)
}
if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_GP) &&
cur_ops->gather_gp_seqs && cur_ops->format_gp_seqs) {
- char buf1[16+1];
- char buf2[16+1];
+ char buf1[20+1];
+ char buf2[20+1];
char sepchar = '-';
cur_ops->format_gp_seqs(err_segs[i].rt_gp_seq, buf1);
diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
index f9c4a24dc59c..8cbec3401184 100644
--- a/kernel/rcu/tiny.c
+++ b/kernel/rcu/tiny.c
@@ -258,15 +258,15 @@ EXPORT_SYMBOL_GPL(kvfree_call_rcu);
#endif
#if IS_ENABLED(CONFIG_RCU_TORTURE_TEST)
-unsigned long rcutorture_gather_gp_seqs(void)
+unsigned long long rcutorture_gather_gp_seqs(void)
{
- return READ_ONCE(rcu_ctrlblk.gp_seq) & 0xff;
+ return READ_ONCE(rcu_ctrlblk.gp_seq) & 0xffffULL;
}
EXPORT_SYMBOL_GPL(rcutorture_gather_gp_seqs);
-void rcutorture_format_gp_seqs(unsigned long seqs, char *cp)
+void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp)
{
- snprintf(cp, 8, "g%02lx", seqs & 0xff);
+ snprintf(cp, 8, "g%04llx", seqs & 0xffffULL);
}
EXPORT_SYMBOL_GPL(rcutorture_format_gp_seqs);
#endif
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index e40c4b5c3267..83cba3d2cc48 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -539,22 +539,22 @@ void rcutorture_get_gp_data(int *flags, unsigned long *gp_seq)
EXPORT_SYMBOL_GPL(rcutorture_get_gp_data);
/* Gather grace-period sequence numbers for rcutorture diagnostics. */
-unsigned long rcutorture_gather_gp_seqs(void)
+unsigned long long rcutorture_gather_gp_seqs(void)
{
- return ((READ_ONCE(rcu_state.gp_seq) & 0xff) << 16) |
- ((READ_ONCE(rcu_state.expedited_sequence) & 0xff) << 8) |
- (READ_ONCE(rcu_state.gp_seq_polled) & 0xff);
+ return ((READ_ONCE(rcu_state.gp_seq) & 0xffffULL) << 40) |
+ ((READ_ONCE(rcu_state.expedited_sequence) & 0xffffffULL) << 16) |
+ (READ_ONCE(rcu_state.gp_seq_polled) & 0xffffULL);
}
EXPORT_SYMBOL_GPL(rcutorture_gather_gp_seqs);
/* Format grace-period sequence numbers for rcutorture diagnostics. */
-void rcutorture_format_gp_seqs(unsigned long seqs, char *cp)
+void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp)
{
- unsigned int egp = (seqs >> 8) & 0xff;
- unsigned int ggp = (seqs >> 16) & 0xff;
- unsigned int pgp = seqs & 0xff;
+ unsigned int egp = (seqs >> 16) & 0xffffffULL;
+ unsigned int ggp = (seqs >> 40) & 0xffffULL;
+ unsigned int pgp = seqs & 0xffffULL;
- snprintf(cp, 16, "g%02x:e%02x:p%02x", ggp, egp, pgp);
+ snprintf(cp, 20, "g%04x:e%06x:p%04x", ggp, egp, pgp);
}
EXPORT_SYMBOL_GPL(rcutorture_format_gp_seqs);
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 05/11] rcu: Trace expedited grace-period numbers in hexadecimal
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
` (3 preceding siblings ...)
2025-02-19 15:39 ` [PATCH rcu 04/11] rcutorture: Expand failure/close-call grace-period output Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 06/11] rcutorture: Add ftrace-compatible timestamp to GP# failure/close-call output Boqun Feng
` (5 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
From: "Paul E. McKenney" <paulmck@kernel.org>
This commit reformats the expedited grace-period numbers into hexadecimal
for easier decoding and comparison. The normal grace-period numbers
remain in decimal for the time being.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
include/trace/events/rcu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
index e81431deaa50..63fd8aa99af7 100644
--- a/include/trace/events/rcu.h
+++ b/include/trace/events/rcu.h
@@ -207,7 +207,7 @@ TRACE_EVENT_RCU(rcu_exp_grace_period,
__entry->gpevent = gpevent;
),
- TP_printk("%s %ld %s",
+ TP_printk("%s %#lx %s",
__entry->rcuname, __entry->gpseq, __entry->gpevent)
);
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 06/11] rcutorture: Add ftrace-compatible timestamp to GP# failure/close-call output
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
` (4 preceding siblings ...)
2025-02-19 15:39 ` [PATCH rcu 05/11] rcu: Trace expedited grace-period numbers in hexadecimal Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 07/11] rcutorture: Make cur_ops->format_gp_seqs take buffer length Boqun Feng
` (4 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
From: "Paul E. McKenney" <paulmck@kernel.org>
This commit adds an ftrace-compatible microsecond-scale timestamp
to the failure/close-call output, but only in kernels built with
CONFIG_RCU_TORTURE_TEST_LOG_GP=y.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
kernel/rcu/rcutorture.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index fb1b80498ae0..1fdadc1df9ad 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -275,6 +275,7 @@ struct rt_read_seg {
int rt_end_cpu;
unsigned long long rt_gp_seq;
unsigned long long rt_gp_seq_end;
+ u64 rt_ts;
};
static int err_segs_recorded;
static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS];
@@ -1989,6 +1990,7 @@ static void rcutorture_one_extend(int *readstate, int newstate, bool insoftirq,
// Sample grace-period sequence number, as good a place as any.
if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_GP) && cur_ops->gather_gp_seqs) {
rtrsp->rt_gp_seq = cur_ops->gather_gp_seqs();
+ rtrsp->rt_ts = ktime_get_mono_fast_ns();
if (!first)
rtrsp[-1].rt_gp_seq_end = rtrsp->rt_gp_seq;
}
@@ -3663,7 +3665,11 @@ rcu_torture_cleanup(void)
pr_alert("\t: No segments recorded!!!\n");
firsttime = 1;
for (i = 0; i < rt_read_nsegs; i++) {
- pr_alert("\t%d: %#4x", i, err_segs[i].rt_readstate);
+ if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_GP))
+ pr_alert("\t%lluus ", div64_u64(err_segs[i].rt_ts, 1000ULL));
+ else
+ pr_alert("\t");
+ pr_cont("%d: %#4x", i, err_segs[i].rt_readstate);
if (err_segs[i].rt_delay_jiffies != 0) {
pr_cont("%s%ldjiffies", firsttime ? "" : "+",
err_segs[i].rt_delay_jiffies);
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 07/11] rcutorture: Make cur_ops->format_gp_seqs take buffer length
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
` (5 preceding siblings ...)
2025-02-19 15:39 ` [PATCH rcu 06/11] rcutorture: Add ftrace-compatible timestamp to GP# failure/close-call output Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 08/11] rcutorture: Move RCU_TORTURE_TEST_{CHK_RDR_STATE,LOG_CPU} to bool Boqun Feng
` (3 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
From: "Paul E. McKenney" <paulmck@kernel.org>
The Tree and Tiny implementations of rcutorture_format_gp_seqs() use
hard-coded constants for the length of the buffer that they format into.
This is of course an accident waiting to happen, so this commit therefore
makes them take a length argument. The rcutorture calling code uses
ARRAY_SIZE() to safely compute this new argument.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
kernel/rcu/rcu.h | 2 +-
kernel/rcu/rcutorture.c | 8 +++++---
kernel/rcu/tiny.c | 4 ++--
kernel/rcu/tree.c | 4 ++--
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index 705fcbe6f500..82d8b494cc30 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -591,7 +591,7 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
static inline void rcu_gp_set_torture_wait(int duration) { }
#endif
unsigned long long rcutorture_gather_gp_seqs(void);
-void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp);
+void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp, size_t len);
#ifdef CONFIG_TINY_SRCU
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 1fdadc1df9ad..9c9a349b9c7f 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -411,7 +411,7 @@ struct rcu_torture_ops {
void (*gp_slow_unregister)(atomic_t *rgssp);
bool (*reader_blocked)(void);
unsigned long long (*gather_gp_seqs)(void);
- void (*format_gp_seqs)(unsigned long long seqs, char *cp);
+ void (*format_gp_seqs)(unsigned long long seqs, char *cp, size_t len);
long cbflood_max;
int irq_capable;
int can_boost;
@@ -3688,8 +3688,10 @@ rcu_torture_cleanup(void)
char buf2[20+1];
char sepchar = '-';
- cur_ops->format_gp_seqs(err_segs[i].rt_gp_seq, buf1);
- cur_ops->format_gp_seqs(err_segs[i].rt_gp_seq_end, buf2);
+ cur_ops->format_gp_seqs(err_segs[i].rt_gp_seq,
+ buf1, ARRAY_SIZE(buf1));
+ cur_ops->format_gp_seqs(err_segs[i].rt_gp_seq_end,
+ buf2, ARRAY_SIZE(buf2));
if (err_segs[i].rt_gp_seq == err_segs[i].rt_gp_seq_end) {
if (buf2[0]) {
for (j = 0; buf2[j]; j++)
diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
index 8cbec3401184..8a52aca686a5 100644
--- a/kernel/rcu/tiny.c
+++ b/kernel/rcu/tiny.c
@@ -264,9 +264,9 @@ unsigned long long rcutorture_gather_gp_seqs(void)
}
EXPORT_SYMBOL_GPL(rcutorture_gather_gp_seqs);
-void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp)
+void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp, size_t len)
{
- snprintf(cp, 8, "g%04llx", seqs & 0xffffULL);
+ snprintf(cp, len, "g%04llx", seqs & 0xffffULL);
}
EXPORT_SYMBOL_GPL(rcutorture_format_gp_seqs);
#endif
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 83cba3d2cc48..bb061e5870c3 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -548,13 +548,13 @@ unsigned long long rcutorture_gather_gp_seqs(void)
EXPORT_SYMBOL_GPL(rcutorture_gather_gp_seqs);
/* Format grace-period sequence numbers for rcutorture diagnostics. */
-void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp)
+void rcutorture_format_gp_seqs(unsigned long long seqs, char *cp, size_t len)
{
unsigned int egp = (seqs >> 16) & 0xffffffULL;
unsigned int ggp = (seqs >> 40) & 0xffffULL;
unsigned int pgp = seqs & 0xffffULL;
- snprintf(cp, 20, "g%04x:e%06x:p%04x", ggp, egp, pgp);
+ snprintf(cp, len, "g%04x:e%06x:p%04x", ggp, egp, pgp);
}
EXPORT_SYMBOL_GPL(rcutorture_format_gp_seqs);
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 08/11] rcutorture: Move RCU_TORTURE_TEST_{CHK_RDR_STATE,LOG_CPU} to bool
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
` (6 preceding siblings ...)
2025-02-19 15:39 ` [PATCH rcu 07/11] rcutorture: Make cur_ops->format_gp_seqs take buffer length Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 09/11] rcutorture: Complain when invalid SRCU reader_flavor is specified Boqun Feng
` (2 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest, kernel test robot
From: "Paul E. McKenney" <paulmck@kernel.org>
The RCU_TORTURE_TEST_CHK_RDR_STATE and RCU_TORTURE_TEST_LOG_CPU Kconfig
options are pointlessly defined as tristate. This commit therefore
converts them to bool.
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202412241458.150d082b-lkp@intel.com
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
kernel/rcu/Kconfig.debug | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/Kconfig.debug b/kernel/rcu/Kconfig.debug
index 25a9dc2be0dc..12e4c64ebae1 100644
--- a/kernel/rcu/Kconfig.debug
+++ b/kernel/rcu/Kconfig.debug
@@ -54,7 +54,7 @@ config RCU_TORTURE_TEST
Say N if you are unsure.
config RCU_TORTURE_TEST_CHK_RDR_STATE
- tristate "Check rcutorture reader state"
+ bool "Check rcutorture reader state"
depends on RCU_TORTURE_TEST
default n
help
@@ -70,7 +70,7 @@ config RCU_TORTURE_TEST_CHK_RDR_STATE
Say N if you are unsure.
config RCU_TORTURE_TEST_LOG_CPU
- tristate "Log CPU for rcutorture failures"
+ bool "Log CPU for rcutorture failures"
depends on RCU_TORTURE_TEST
default n
help
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 09/11] rcutorture: Complain when invalid SRCU reader_flavor is specified
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
` (7 preceding siblings ...)
2025-02-19 15:39 ` [PATCH rcu 08/11] rcutorture: Move RCU_TORTURE_TEST_{CHK_RDR_STATE,LOG_CPU} to bool Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 11/11] torture: Make SRCU lockdep testing use srcu_read_lock_nmisafe() Boqun Feng
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
From: "Paul E. McKenney" <paulmck@kernel.org>
Currently, rcutorture ignores reader_flavor bits that are not in the
SRCU_READ_FLAVOR_ALL bitmask, which could confuse rcutorture users into
believing buggy patches had been fully tested. This commit therefore
produces a splat in this case.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
kernel/rcu/rcutorture.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 9c9a349b9c7f..be4e3c6b912f 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -689,6 +689,8 @@ static int srcu_torture_read_lock(void)
int idx;
int ret = 0;
+ WARN_ON_ONCE(reader_flavor & ~SRCU_READ_FLAVOR_ALL);
+
if ((reader_flavor & SRCU_READ_FLAVOR_NORMAL) || !(reader_flavor & SRCU_READ_FLAVOR_ALL)) {
idx = srcu_read_lock(srcu_ctlp);
WARN_ON_ONCE(idx & ~0x1);
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
` (8 preceding siblings ...)
2025-02-19 15:39 ` [PATCH rcu 09/11] rcutorture: Complain when invalid SRCU reader_flavor is specified Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
2025-03-25 8:04 ` Geert Uytterhoeven
2025-02-19 15:39 ` [PATCH rcu 11/11] torture: Make SRCU lockdep testing use srcu_read_lock_nmisafe() Boqun Feng
10 siblings, 1 reply; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
From: "Paul E. McKenney" <paulmck@kernel.org>
The srcu_read_lock_nmisafe() and srcu_read_unlock_nmisafe() functions
map to __srcu_read_lock() and __srcu_read_unlock() on systems like x86
that have NMI-safe this_cpu_inc() operations. This makes the underlying
__srcu_read_lock_nmisafe() and __srcu_read_unlock_nmisafe() functions
difficult to test on (for example) x86 systems, allowing bugs to creep in.
This commit therefore creates a FORCE_NEED_SRCU_NMI_SAFE Kconfig that
forces those underlying functions to be used even on systems where they
are not needed, thus providing better testing coverage.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
kernel/rcu/Kconfig | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
index b9b6bc55185d..c8e540af3a35 100644
--- a/kernel/rcu/Kconfig
+++ b/kernel/rcu/Kconfig
@@ -65,6 +65,17 @@ config TREE_SRCU
help
This option selects the full-fledged version of SRCU.
+config FORCE_NEED_SRCU_NMI_SAFE
+ bool "Force selection of NEED_SRCU_NMI_SAFE"
+ depends on !TINY_SRCU
+ select NEED_SRCU_NMI_SAFE
+ default n
+ help
+ This option forces selection of the NEED_SRCU_NMI_SAFE
+ Kconfig option, allowing testing of srcu_read_lock_nmisafe()
+ and srcu_read_unlock_nmisafe() on architectures (like x86)
+ that select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option.
+
config NEED_SRCU_NMI_SAFE
def_bool HAVE_NMI && !ARCH_HAS_NMI_SAFE_THIS_CPU_OPS && !TINY_SRCU
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH rcu 11/11] torture: Make SRCU lockdep testing use srcu_read_lock_nmisafe()
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
` (9 preceding siblings ...)
2025-02-19 15:39 ` [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing Boqun Feng
@ 2025-02-19 15:39 ` Boqun Feng
10 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-02-19 15:39 UTC (permalink / raw)
To: rcu
Cc: Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
Uladzislau Rezki, Lai Jiangshan, Zqiang, Davidlohr Bueso,
Shuah Khan, Andrew Morton, Thomas Huth, Borislav Petkov (AMD),
Ard Biesheuvel, Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
From: "Paul E. McKenney" <paulmck@kernel.org>
Recent experience shows that the srcu_read_lock_nmisafe() and
srcu_read_unlock_nmisafe() functions are not sufficiently tested.
This commit therefore causes the torture.sh script's SRCU lockdep testing
to use these two functions. This will cause these two functions to
be regularly tested by several developers (myself included) who use
torture.sh as an RCU acceptance test.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
index 2e63ef009d59..2db12c5cad9c 100755
--- a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
+++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
@@ -49,7 +49,7 @@ do
do
err=
val=$((d*1000+t*10+c))
- tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --configs "SRCU-P" --bootargs "rcutorture.test_srcu_lockdep=$val" --trust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1
+ tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --configs "SRCU-P" --kconfig "CONFIG_FORCE_NEED_SRCU_NMI_SAFE=y" --bootargs "rcutorture.test_srcu_lockdep=$val rcutorture.reader_flavor=0x2" --trust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1
ret=$?
mv "$T/kvm.sh.out" "$RCUTORTURE/res/$ds/$val"
if test "$d" -ne 0 && test "$ret" -eq 0
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
2025-02-19 15:39 ` [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing Boqun Feng
@ 2025-03-25 8:04 ` Geert Uytterhoeven
2025-03-25 14:36 ` Paul E. McKenney
0 siblings, 1 reply; 19+ messages in thread
From: Geert Uytterhoeven @ 2025-03-25 8:04 UTC (permalink / raw)
To: Boqun Feng, Paul E. McKenney
Cc: rcu, Jonathan Corbet, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Lai Jiangshan,
Zqiang, Davidlohr Bueso, Shuah Khan, Andrew Morton, Thomas Huth,
Borislav Petkov (AMD), Ard Biesheuvel, Greg Kroah-Hartman,
Josh Poimboeuf, Yury Norov, Valentin Schneider, linux-doc,
linux-kernel, linux-trace-kernel, linux-kselftest
Hi Boqun, Paul,
On Wed, 19 Feb 2025 at 16:44, Boqun Feng <boqun.feng@gmail.com> wrote:
> From: "Paul E. McKenney" <paulmck@kernel.org>
>
> The srcu_read_lock_nmisafe() and srcu_read_unlock_nmisafe() functions
> map to __srcu_read_lock() and __srcu_read_unlock() on systems like x86
> that have NMI-safe this_cpu_inc() operations. This makes the underlying
> __srcu_read_lock_nmisafe() and __srcu_read_unlock_nmisafe() functions
> difficult to test on (for example) x86 systems, allowing bugs to creep in.
>
> This commit therefore creates a FORCE_NEED_SRCU_NMI_SAFE Kconfig that
> forces those underlying functions to be used even on systems where they
> are not needed, thus providing better testing coverage.
>
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Thanks for your patch, which is now commit 536e8b9b80bc7a0a ("srcu:
Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing") in linus/master
> --- a/kernel/rcu/Kconfig
> +++ b/kernel/rcu/Kconfig
> @@ -65,6 +65,17 @@ config TREE_SRCU
> help
> This option selects the full-fledged version of SRCU.
>
> +config FORCE_NEED_SRCU_NMI_SAFE
> + bool "Force selection of NEED_SRCU_NMI_SAFE"
What am I supposed to answer here? "n" I guess.
What about distro and allmodconfig kernels?
> + depends on !TINY_SRCU
> + select NEED_SRCU_NMI_SAFE
> + default n
> + help
> + This option forces selection of the NEED_SRCU_NMI_SAFE
> + Kconfig option, allowing testing of srcu_read_lock_nmisafe()
> + and srcu_read_unlock_nmisafe() on architectures (like x86)
> + that select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option.
Perhaps this should depend on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS?
> +
> config NEED_SRCU_NMI_SAFE
> def_bool HAVE_NMI && !ARCH_HAS_NMI_SAFE_THIS_CPU_OPS && !TINY_SRCU
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
2025-03-25 8:04 ` Geert Uytterhoeven
@ 2025-03-25 14:36 ` Paul E. McKenney
2025-03-25 14:57 ` Geert Uytterhoeven
0 siblings, 1 reply; 19+ messages in thread
From: Paul E. McKenney @ 2025-03-25 14:36 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Boqun Feng, rcu, Jonathan Corbet, Steven Rostedt,
Masami Hiramatsu, Mathieu Desnoyers, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Lai Jiangshan, Zqiang, Davidlohr Bueso, Shuah Khan, Andrew Morton,
Thomas Huth, Borislav Petkov (AMD), Ard Biesheuvel,
Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
On Tue, Mar 25, 2025 at 09:04:31AM +0100, Geert Uytterhoeven wrote:
> Hi Boqun, Paul,
>
> On Wed, 19 Feb 2025 at 16:44, Boqun Feng <boqun.feng@gmail.com> wrote:
> > From: "Paul E. McKenney" <paulmck@kernel.org>
> >
> > The srcu_read_lock_nmisafe() and srcu_read_unlock_nmisafe() functions
> > map to __srcu_read_lock() and __srcu_read_unlock() on systems like x86
> > that have NMI-safe this_cpu_inc() operations. This makes the underlying
> > __srcu_read_lock_nmisafe() and __srcu_read_unlock_nmisafe() functions
> > difficult to test on (for example) x86 systems, allowing bugs to creep in.
> >
> > This commit therefore creates a FORCE_NEED_SRCU_NMI_SAFE Kconfig that
> > forces those underlying functions to be used even on systems where they
> > are not needed, thus providing better testing coverage.
> >
> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
>
> Thanks for your patch, which is now commit 536e8b9b80bc7a0a ("srcu:
> Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing") in linus/master
>
> > --- a/kernel/rcu/Kconfig
> > +++ b/kernel/rcu/Kconfig
> > @@ -65,6 +65,17 @@ config TREE_SRCU
> > help
> > This option selects the full-fledged version of SRCU.
> >
> > +config FORCE_NEED_SRCU_NMI_SAFE
> > + bool "Force selection of NEED_SRCU_NMI_SAFE"
>
> What am I supposed to answer here? "n" I guess.
> What about distro and allmodconfig kernels?
Yes, you should select "n" unless ...
> > + depends on !TINY_SRCU
> > + select NEED_SRCU_NMI_SAFE
> > + default n
> > + help
> > + This option forces selection of the NEED_SRCU_NMI_SAFE
> > + Kconfig option, allowing testing of srcu_read_lock_nmisafe()
> > + and srcu_read_unlock_nmisafe() on architectures (like x86)
> > + that select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option.
>
> Perhaps this should depend on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS?
... you are on a system selecting ARCH_HAS_NMI_SAFE_THIS_CPU_OPS and
you would like to test the SRCU setup that needed only by systems that
do not select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS.
Ah. I forgot to add "depends on RCU_EXPERT".
Apologies, I will fix this. Does the patch show below do the trick?
Thanx, Paul
------------------------------------------------------------------------
commit b5c8c6f89c6d7ac778e961ad4b883eada0c1f42a
Author: Paul E. McKenney <paulmck@kernel.org>
Date: Tue Mar 25 07:31:45 2025 -0700
srcu: Make FORCE_NEED_SRCU_NMI_SAFE depend on RCU_EXPERT
The FORCE_NEED_SRCU_NMI_SAFE is useful only for those wishing to test
the SRCU code paths that accommodate architectures that do not have
NMI-safe per-CPU operations, that is, those architectures that do not
select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option. As such, this
is a specialized Kconfig option that is not intended for casual users.
This commit therefore hides it behind the RCU_EXPERT Kconfig option.
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Closes: https://lore.kernel.org/all/CAMuHMdX6dy9_tmpLkpcnGzxyRbe6qSWYukcPp=H1GzZdyd3qBQ@mail.gmail.com/
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
index b3f985d41717a..cc4ce79f58aa6 100644
--- a/kernel/rcu/Kconfig
+++ b/kernel/rcu/Kconfig
@@ -68,6 +68,7 @@ config TREE_SRCU
config FORCE_NEED_SRCU_NMI_SAFE
bool "Force selection of NEED_SRCU_NMI_SAFE"
depends on !TINY_SRCU
+ depends on RCU_EXPERT
select NEED_SRCU_NMI_SAFE
default n
help
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
2025-03-25 14:36 ` Paul E. McKenney
@ 2025-03-25 14:57 ` Geert Uytterhoeven
2025-03-25 15:07 ` Paul E. McKenney
0 siblings, 1 reply; 19+ messages in thread
From: Geert Uytterhoeven @ 2025-03-25 14:57 UTC (permalink / raw)
To: paulmck
Cc: Boqun Feng, rcu, Jonathan Corbet, Steven Rostedt,
Masami Hiramatsu, Mathieu Desnoyers, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Lai Jiangshan, Zqiang, Davidlohr Bueso, Shuah Khan, Andrew Morton,
Thomas Huth, Borislav Petkov (AMD), Ard Biesheuvel,
Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
Hi Paul,
On Tue, 25 Mar 2025 at 15:36, Paul E. McKenney <paulmck@kernel.org> wrote:
> On Tue, Mar 25, 2025 at 09:04:31AM +0100, Geert Uytterhoeven wrote:
> > On Wed, 19 Feb 2025 at 16:44, Boqun Feng <boqun.feng@gmail.com> wrote:
> > > From: "Paul E. McKenney" <paulmck@kernel.org>
> > >
> > > The srcu_read_lock_nmisafe() and srcu_read_unlock_nmisafe() functions
> > > map to __srcu_read_lock() and __srcu_read_unlock() on systems like x86
> > > that have NMI-safe this_cpu_inc() operations. This makes the underlying
> > > __srcu_read_lock_nmisafe() and __srcu_read_unlock_nmisafe() functions
> > > difficult to test on (for example) x86 systems, allowing bugs to creep in.
> > >
> > > This commit therefore creates a FORCE_NEED_SRCU_NMI_SAFE Kconfig that
> > > forces those underlying functions to be used even on systems where they
> > > are not needed, thus providing better testing coverage.
> > >
> > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> >
> > Thanks for your patch, which is now commit 536e8b9b80bc7a0a ("srcu:
> > Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing") in linus/master
> >
> > > --- a/kernel/rcu/Kconfig
> > > +++ b/kernel/rcu/Kconfig
> > > @@ -65,6 +65,17 @@ config TREE_SRCU
> > > help
> > > This option selects the full-fledged version of SRCU.
> > >
> > > +config FORCE_NEED_SRCU_NMI_SAFE
> > > + bool "Force selection of NEED_SRCU_NMI_SAFE"
> >
> > What am I supposed to answer here? "n" I guess.
> > What about distro and allmodconfig kernels?
>
> Yes, you should select "n" unless ...
>
> > > + depends on !TINY_SRCU
> > > + select NEED_SRCU_NMI_SAFE
> > > + default n
> > > + help
> > > + This option forces selection of the NEED_SRCU_NMI_SAFE
> > > + Kconfig option, allowing testing of srcu_read_lock_nmisafe()
> > > + and srcu_read_unlock_nmisafe() on architectures (like x86)
> > > + that select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option.
> >
> > Perhaps this should depend on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS?
>
> ... you are on a system selecting ARCH_HAS_NMI_SAFE_THIS_CPU_OPS and
So a dependency on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS does make sense,
doesn't it?
> you would like to test the SRCU setup that needed only by systems that
> do not select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS.
>
> Ah. I forgot to add "depends on RCU_EXPERT".
Yes, that makes sense.
> Apologies, I will fix this. Does the patch show below do the trick?
>
> Thanx, Paul
>
> ------------------------------------------------------------------------
>
> commit b5c8c6f89c6d7ac778e961ad4b883eada0c1f42a
> Author: Paul E. McKenney <paulmck@kernel.org>
> Date: Tue Mar 25 07:31:45 2025 -0700
>
> srcu: Make FORCE_NEED_SRCU_NMI_SAFE depend on RCU_EXPERT
>
> The FORCE_NEED_SRCU_NMI_SAFE is useful only for those wishing to test
> the SRCU code paths that accommodate architectures that do not have
> NMI-safe per-CPU operations, that is, those architectures that do not
> select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option. As such, this
> is a specialized Kconfig option that is not intended for casual users.
>
> This commit therefore hides it behind the RCU_EXPERT Kconfig option.
>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Closes: https://lore.kernel.org/all/CAMuHMdX6dy9_tmpLkpcnGzxyRbe6qSWYukcPp=H1GzZdyd3qBQ@mail.gmail.com/
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
>
> diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
> index b3f985d41717a..cc4ce79f58aa6 100644
> --- a/kernel/rcu/Kconfig
> +++ b/kernel/rcu/Kconfig
> @@ -68,6 +68,7 @@ config TREE_SRCU
> config FORCE_NEED_SRCU_NMI_SAFE
> bool "Force selection of NEED_SRCU_NMI_SAFE"
> depends on !TINY_SRCU
> + depends on RCU_EXPERT
> select NEED_SRCU_NMI_SAFE
> default n
> help
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
2025-03-25 14:57 ` Geert Uytterhoeven
@ 2025-03-25 15:07 ` Paul E. McKenney
2025-03-25 15:36 ` Geert Uytterhoeven
0 siblings, 1 reply; 19+ messages in thread
From: Paul E. McKenney @ 2025-03-25 15:07 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Boqun Feng, rcu, Jonathan Corbet, Steven Rostedt,
Masami Hiramatsu, Mathieu Desnoyers, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Lai Jiangshan, Zqiang, Davidlohr Bueso, Shuah Khan, Andrew Morton,
Thomas Huth, Borislav Petkov (AMD), Ard Biesheuvel,
Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
On Tue, Mar 25, 2025 at 03:57:43PM +0100, Geert Uytterhoeven wrote:
> Hi Paul,
>
> On Tue, 25 Mar 2025 at 15:36, Paul E. McKenney <paulmck@kernel.org> wrote:
> > On Tue, Mar 25, 2025 at 09:04:31AM +0100, Geert Uytterhoeven wrote:
> > > On Wed, 19 Feb 2025 at 16:44, Boqun Feng <boqun.feng@gmail.com> wrote:
> > > > From: "Paul E. McKenney" <paulmck@kernel.org>
> > > >
> > > > The srcu_read_lock_nmisafe() and srcu_read_unlock_nmisafe() functions
> > > > map to __srcu_read_lock() and __srcu_read_unlock() on systems like x86
> > > > that have NMI-safe this_cpu_inc() operations. This makes the underlying
> > > > __srcu_read_lock_nmisafe() and __srcu_read_unlock_nmisafe() functions
> > > > difficult to test on (for example) x86 systems, allowing bugs to creep in.
> > > >
> > > > This commit therefore creates a FORCE_NEED_SRCU_NMI_SAFE Kconfig that
> > > > forces those underlying functions to be used even on systems where they
> > > > are not needed, thus providing better testing coverage.
> > > >
> > > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> > >
> > > Thanks for your patch, which is now commit 536e8b9b80bc7a0a ("srcu:
> > > Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing") in linus/master
> > >
> > > > --- a/kernel/rcu/Kconfig
> > > > +++ b/kernel/rcu/Kconfig
> > > > @@ -65,6 +65,17 @@ config TREE_SRCU
> > > > help
> > > > This option selects the full-fledged version of SRCU.
> > > >
> > > > +config FORCE_NEED_SRCU_NMI_SAFE
> > > > + bool "Force selection of NEED_SRCU_NMI_SAFE"
> > >
> > > What am I supposed to answer here? "n" I guess.
> > > What about distro and allmodconfig kernels?
> >
> > Yes, you should select "n" unless ...
> >
> > > > + depends on !TINY_SRCU
> > > > + select NEED_SRCU_NMI_SAFE
> > > > + default n
> > > > + help
> > > > + This option forces selection of the NEED_SRCU_NMI_SAFE
> > > > + Kconfig option, allowing testing of srcu_read_lock_nmisafe()
> > > > + and srcu_read_unlock_nmisafe() on architectures (like x86)
> > > > + that select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option.
> > >
> > > Perhaps this should depend on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS?
> >
> > ... you are on a system selecting ARCH_HAS_NMI_SAFE_THIS_CPU_OPS and
>
> So a dependency on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS does make sense,
> doesn't it?
The FORCE_NEED_SRCU_NMI_SAFE has no effect otherwise, so it cannot
hurt. Again, please see below.
Thanx, Paul
> > you would like to test the SRCU setup that needed only by systems that
> > do not select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS.
> >
> > Ah. I forgot to add "depends on RCU_EXPERT".
>
> Yes, that makes sense.
>
> > Apologies, I will fix this. Does the patch show below do the trick?
> >
> > Thanx, Paul
-----------------------------------------------------------------------
commit 2245ef8605a80726548253d885b4cadd97f69f3b
Author: Paul E. McKenney <paulmck@kernel.org>
Date: Tue Mar 25 07:31:45 2025 -0700
srcu: Make FORCE_NEED_SRCU_NMI_SAFE depend on RCU_EXPERT
The FORCE_NEED_SRCU_NMI_SAFE is useful only for those wishing to test
the SRCU code paths that accommodate architectures that do not have
NMI-safe per-CPU operations, that is, those architectures that do not
select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option. As such, this
is a specialized Kconfig option that is not intended for casual users.
This commit therefore hides it behind the RCU_EXPERT Kconfig option.
Given that this new FORCE_NEED_SRCU_NMI_SAFE Kconfig option has no effect
unless the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option is also selected,
it also depends on this Kconfig option.
[ paulmck: Apply Geert Uytterhoeven feedback. ]
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Closes: https://lore.kernel.org/all/CAMuHMdX6dy9_tmpLkpcnGzxyRbe6qSWYukcPp=H1GzZdyd3qBQ@mail.gmail.com/
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
index b3f985d41717a..ceaf6594f634c 100644
--- a/kernel/rcu/Kconfig
+++ b/kernel/rcu/Kconfig
@@ -68,6 +68,8 @@ config TREE_SRCU
config FORCE_NEED_SRCU_NMI_SAFE
bool "Force selection of NEED_SRCU_NMI_SAFE"
depends on !TINY_SRCU
+ depends on RCU_EXPERT
+ depends on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
select NEED_SRCU_NMI_SAFE
default n
help
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
2025-03-25 15:07 ` Paul E. McKenney
@ 2025-03-25 15:36 ` Geert Uytterhoeven
2025-03-25 15:51 ` Paul E. McKenney
0 siblings, 1 reply; 19+ messages in thread
From: Geert Uytterhoeven @ 2025-03-25 15:36 UTC (permalink / raw)
To: paulmck
Cc: Boqun Feng, rcu, Jonathan Corbet, Steven Rostedt,
Masami Hiramatsu, Mathieu Desnoyers, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Lai Jiangshan, Zqiang, Davidlohr Bueso, Shuah Khan, Andrew Morton,
Thomas Huth, Borislav Petkov (AMD), Ard Biesheuvel,
Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
Hi Paul,
On Tue, 25 Mar 2025 at 16:08, Paul E. McKenney <paulmck@kernel.org> wrote:
> commit 2245ef8605a80726548253d885b4cadd97f69f3b
> Author: Paul E. McKenney <paulmck@kernel.org>
> Date: Tue Mar 25 07:31:45 2025 -0700
>
> srcu: Make FORCE_NEED_SRCU_NMI_SAFE depend on RCU_EXPERT
>
> The FORCE_NEED_SRCU_NMI_SAFE is useful only for those wishing to test
> the SRCU code paths that accommodate architectures that do not have
> NMI-safe per-CPU operations, that is, those architectures that do not
> select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option. As such, this
> is a specialized Kconfig option that is not intended for casual users.
>
> This commit therefore hides it behind the RCU_EXPERT Kconfig option.
> Given that this new FORCE_NEED_SRCU_NMI_SAFE Kconfig option has no effect
> unless the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option is also selected,
> it also depends on this Kconfig option.
>
> [ paulmck: Apply Geert Uytterhoeven feedback. ]
>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Closes: https://lore.kernel.org/all/CAMuHMdX6dy9_tmpLkpcnGzxyRbe6qSWYukcPp=H1GzZdyd3qBQ@mail.gmail.com/
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
>
> diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
> index b3f985d41717a..ceaf6594f634c 100644
> --- a/kernel/rcu/Kconfig
> +++ b/kernel/rcu/Kconfig
> @@ -68,6 +68,8 @@ config TREE_SRCU
> config FORCE_NEED_SRCU_NMI_SAFE
> bool "Force selection of NEED_SRCU_NMI_SAFE"
> depends on !TINY_SRCU
> + depends on RCU_EXPERT
> + depends on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
> select NEED_SRCU_NMI_SAFE
> default n
> help
LGTM, so
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
2025-03-25 15:36 ` Geert Uytterhoeven
@ 2025-03-25 15:51 ` Paul E. McKenney
2025-03-26 5:42 ` Boqun Feng
0 siblings, 1 reply; 19+ messages in thread
From: Paul E. McKenney @ 2025-03-25 15:51 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Boqun Feng, rcu, Jonathan Corbet, Steven Rostedt,
Masami Hiramatsu, Mathieu Desnoyers, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Lai Jiangshan, Zqiang, Davidlohr Bueso, Shuah Khan, Andrew Morton,
Thomas Huth, Borislav Petkov (AMD), Ard Biesheuvel,
Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
On Tue, Mar 25, 2025 at 04:36:23PM +0100, Geert Uytterhoeven wrote:
> Hi Paul,
>
> On Tue, 25 Mar 2025 at 16:08, Paul E. McKenney <paulmck@kernel.org> wrote:
> > commit 2245ef8605a80726548253d885b4cadd97f69f3b
> > Author: Paul E. McKenney <paulmck@kernel.org>
> > Date: Tue Mar 25 07:31:45 2025 -0700
> >
> > srcu: Make FORCE_NEED_SRCU_NMI_SAFE depend on RCU_EXPERT
> >
> > The FORCE_NEED_SRCU_NMI_SAFE is useful only for those wishing to test
> > the SRCU code paths that accommodate architectures that do not have
> > NMI-safe per-CPU operations, that is, those architectures that do not
> > select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option. As such, this
> > is a specialized Kconfig option that is not intended for casual users.
> >
> > This commit therefore hides it behind the RCU_EXPERT Kconfig option.
> > Given that this new FORCE_NEED_SRCU_NMI_SAFE Kconfig option has no effect
> > unless the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option is also selected,
> > it also depends on this Kconfig option.
> >
> > [ paulmck: Apply Geert Uytterhoeven feedback. ]
> >
> > Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > Closes: https://lore.kernel.org/all/CAMuHMdX6dy9_tmpLkpcnGzxyRbe6qSWYukcPp=H1GzZdyd3qBQ@mail.gmail.com/
> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> >
> > diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
> > index b3f985d41717a..ceaf6594f634c 100644
> > --- a/kernel/rcu/Kconfig
> > +++ b/kernel/rcu/Kconfig
> > @@ -68,6 +68,8 @@ config TREE_SRCU
> > config FORCE_NEED_SRCU_NMI_SAFE
> > bool "Force selection of NEED_SRCU_NMI_SAFE"
> > depends on !TINY_SRCU
> > + depends on RCU_EXPERT
> > + depends on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
> > select NEED_SRCU_NMI_SAFE
> > default n
> > help
>
> LGTM, so
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Applied, and thank you very much for both the review and the report!
Thanx, Paul
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing
2025-03-25 15:51 ` Paul E. McKenney
@ 2025-03-26 5:42 ` Boqun Feng
0 siblings, 0 replies; 19+ messages in thread
From: Boqun Feng @ 2025-03-26 5:42 UTC (permalink / raw)
To: Paul E. McKenney
Cc: Geert Uytterhoeven, rcu, Jonathan Corbet, Steven Rostedt,
Masami Hiramatsu, Mathieu Desnoyers, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Lai Jiangshan, Zqiang, Davidlohr Bueso, Shuah Khan, Andrew Morton,
Thomas Huth, Borislav Petkov (AMD), Ard Biesheuvel,
Greg Kroah-Hartman, Josh Poimboeuf, Yury Norov,
Valentin Schneider, linux-doc, linux-kernel, linux-trace-kernel,
linux-kselftest
On Tue, Mar 25, 2025 at 08:51:05AM -0700, Paul E. McKenney wrote:
> On Tue, Mar 25, 2025 at 04:36:23PM +0100, Geert Uytterhoeven wrote:
> > Hi Paul,
> >
> > On Tue, 25 Mar 2025 at 16:08, Paul E. McKenney <paulmck@kernel.org> wrote:
> > > commit 2245ef8605a80726548253d885b4cadd97f69f3b
> > > Author: Paul E. McKenney <paulmck@kernel.org>
> > > Date: Tue Mar 25 07:31:45 2025 -0700
> > >
> > > srcu: Make FORCE_NEED_SRCU_NMI_SAFE depend on RCU_EXPERT
> > >
> > > The FORCE_NEED_SRCU_NMI_SAFE is useful only for those wishing to test
> > > the SRCU code paths that accommodate architectures that do not have
> > > NMI-safe per-CPU operations, that is, those architectures that do not
> > > select the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option. As such, this
> > > is a specialized Kconfig option that is not intended for casual users.
> > >
> > > This commit therefore hides it behind the RCU_EXPERT Kconfig option.
> > > Given that this new FORCE_NEED_SRCU_NMI_SAFE Kconfig option has no effect
> > > unless the ARCH_HAS_NMI_SAFE_THIS_CPU_OPS Kconfig option is also selected,
> > > it also depends on this Kconfig option.
> > >
> > > [ paulmck: Apply Geert Uytterhoeven feedback. ]
> > >
> > > Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > > Closes: https://lore.kernel.org/all/CAMuHMdX6dy9_tmpLkpcnGzxyRbe6qSWYukcPp=H1GzZdyd3qBQ@mail.gmail.com/
> > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > >
> > > diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
> > > index b3f985d41717a..ceaf6594f634c 100644
> > > --- a/kernel/rcu/Kconfig
> > > +++ b/kernel/rcu/Kconfig
> > > @@ -68,6 +68,8 @@ config TREE_SRCU
> > > config FORCE_NEED_SRCU_NMI_SAFE
> > > bool "Force selection of NEED_SRCU_NMI_SAFE"
> > > depends on !TINY_SRCU
> > > + depends on RCU_EXPERT
> > > + depends on ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
> > > select NEED_SRCU_NMI_SAFE
> > > default n
> > > help
> >
> > LGTM, so
> > Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
> Applied, and thank you very much for both the review and the report!
>
Queued for further testing, thank you both!
Regards,
Boqun
> Thanx, Paul
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-03-26 5:42 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 15:39 [PATCH rcu 00/11] RCU torture changes for v6.15 Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 01/11] torture: Add get_torture_init_jiffies() for test-start time Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 02/11] rcutorture: Add a test_boost_holdoff module parameter Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 03/11] rcutorture: Include grace-period sequence numbers in failure/close-call Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 04/11] rcutorture: Expand failure/close-call grace-period output Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 05/11] rcu: Trace expedited grace-period numbers in hexadecimal Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 06/11] rcutorture: Add ftrace-compatible timestamp to GP# failure/close-call output Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 07/11] rcutorture: Make cur_ops->format_gp_seqs take buffer length Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 08/11] rcutorture: Move RCU_TORTURE_TEST_{CHK_RDR_STATE,LOG_CPU} to bool Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 09/11] rcutorture: Complain when invalid SRCU reader_flavor is specified Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 10/11] srcu: Add FORCE_NEED_SRCU_NMI_SAFE Kconfig for testing Boqun Feng
2025-03-25 8:04 ` Geert Uytterhoeven
2025-03-25 14:36 ` Paul E. McKenney
2025-03-25 14:57 ` Geert Uytterhoeven
2025-03-25 15:07 ` Paul E. McKenney
2025-03-25 15:36 ` Geert Uytterhoeven
2025-03-25 15:51 ` Paul E. McKenney
2025-03-26 5:42 ` Boqun Feng
2025-02-19 15:39 ` [PATCH rcu 11/11] torture: Make SRCU lockdep testing use srcu_read_lock_nmisafe() Boqun Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).