All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rcu 0/7] Miscellaneous changes for v6.13
@ 2024-10-09 18:00 Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 1/7] rcu: Add rcuog kthreads to RCU_NOCB_CPU help text Paul E. McKenney
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Paul E. McKenney @ 2024-10-09 18:00 UTC (permalink / raw)
  To: frederic, rcu; +Cc: linux-kernel, kernel-team, rostedt

Hello!

This series contains miscelleous updates for v6.13:

1.	Add rcuog kthreads to RCU_NOCB_CPU help text.

2.	Add rcuog kthreads to kernel-per-CPU-kthreads.rst.

3.	Allow short-circuiting of synchronize_rcu_tasks_rude().

4.	Permit start_poll_synchronize_rcu*() with interrupts disabled.

5.	Test start-poll primitives with interrupts disabled.

6.	Remove kernel-parameters.txt entry for rcutorture.read_exit.

7.	Remove open-coded one-byte cmpxchg() emulation.

						Thanx, Paul

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

 b/Documentation/admin-guide/kernel-parameters.txt       |    5 --
 b/Documentation/admin-guide/kernel-per-CPU-kthreads.rst |    2 -
 b/kernel/rcu/Kconfig                                    |   28 ++++++++++------
 b/kernel/rcu/rcutorture.c                               |   10 +++++
 b/kernel/rcu/tasks.h                                    |    3 +
 b/kernel/rcu/tree.c                                     |    7 ----
 kernel/rcu/tasks.h                                      |   17 ---------
 7 files changed, 32 insertions(+), 40 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH rcu 1/7] rcu: Add rcuog kthreads to RCU_NOCB_CPU help text
  2024-10-09 18:00 [PATCH rcu 0/7] Miscellaneous changes for v6.13 Paul E. McKenney
@ 2024-10-09 18:00 ` Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 2/7] doc: Add rcuog kthreads to kernel-per-CPU-kthreads.rst Paul E. McKenney
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Paul E. McKenney @ 2024-10-09 18:00 UTC (permalink / raw)
  To: frederic, rcu
  Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney,
	Olivier Langlois

The RCU_NOCB_CPU help text currently fails to mention rcuog kthreads,
so this commit adds this information.

Reported-by: Olivier Langlois <olivier@trillion01.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/Kconfig | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
index 3e079de0f5b43..b9b6bc55185db 100644
--- a/kernel/rcu/Kconfig
+++ b/kernel/rcu/Kconfig
@@ -249,16 +249,24 @@ config RCU_NOCB_CPU
 	  workloads will incur significant increases in context-switch
 	  rates.
 
-	  This option offloads callback invocation from the set of CPUs
-	  specified at boot time by the rcu_nocbs parameter.  For each
-	  such CPU, a kthread ("rcuox/N") will be created to invoke
-	  callbacks, where the "N" is the CPU being offloaded, and where
-	  the "x" is "p" for RCU-preempt (PREEMPTION kernels) and "s" for
-	  RCU-sched (!PREEMPTION kernels).  Nothing prevents this kthread
-	  from running on the specified CPUs, but (1) the kthreads may be
-	  preempted between each callback, and (2) affinity or cgroups can
-	  be used to force the kthreads to run on whatever set of CPUs is
-	  desired.
+	  This option offloads callback invocation from the set of
+	  CPUs specified at boot time by the rcu_nocbs parameter.
+	  For each such CPU, a kthread ("rcuox/N") will be created to
+	  invoke callbacks, where the "N" is the CPU being offloaded,
+	  and where the "x" is "p" for RCU-preempt (PREEMPTION kernels)
+	  and "s" for RCU-sched (!PREEMPTION kernels).	This option
+	  also creates another kthread for each sqrt(nr_cpu_ids) CPUs
+	  ("rcuog/N", where N is the first CPU in that group to come
+	  online), which handles grace periods for its group.  Nothing
+	  prevents these kthreads from running on the specified CPUs,
+	  but (1) the kthreads may be preempted between each callback,
+	  and (2) affinity or cgroups can be used to force the kthreads
+	  to run on whatever set of CPUs is desired.
+
+	  The sqrt(nr_cpu_ids) grouping may be overridden using the
+	  rcutree.rcu_nocb_gp_stride kernel boot parameter.  This can
+	  be especially helpful for smaller numbers of CPUs, where
+	  sqrt(nr_cpu_ids) can be a bit of a blunt instrument.
 
 	  Say Y here if you need reduced OS jitter, despite added overhead.
 	  Say N here if you are unsure.
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH rcu 2/7] doc: Add rcuog kthreads to kernel-per-CPU-kthreads.rst
  2024-10-09 18:00 [PATCH rcu 0/7] Miscellaneous changes for v6.13 Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 1/7] rcu: Add rcuog kthreads to RCU_NOCB_CPU help text Paul E. McKenney
@ 2024-10-09 18:00 ` Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 3/7] rcu: Allow short-circuiting of synchronize_rcu_tasks_rude() Paul E. McKenney
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Paul E. McKenney @ 2024-10-09 18:00 UTC (permalink / raw)
  To: frederic, rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

This commit adds the rcuog kthreads to the list of callback-offloading
kthreads that can be affinitied away from worker CPUs.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 Documentation/admin-guide/kernel-per-CPU-kthreads.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-per-CPU-kthreads.rst b/Documentation/admin-guide/kernel-per-CPU-kthreads.rst
index b6aeae3327ceb..ea7fa2a8bbf0b 100644
--- a/Documentation/admin-guide/kernel-per-CPU-kthreads.rst
+++ b/Documentation/admin-guide/kernel-per-CPU-kthreads.rst
@@ -315,7 +315,7 @@ To reduce its OS jitter, do at least one of the following:
 	to do.
 
 Name:
-  rcuop/%d and rcuos/%d
+  rcuop/%d, rcuos/%d, and rcuog/%d
 
 Purpose:
   Offload RCU callbacks from the corresponding CPU.
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH rcu 3/7] rcu: Allow short-circuiting of synchronize_rcu_tasks_rude()
  2024-10-09 18:00 [PATCH rcu 0/7] Miscellaneous changes for v6.13 Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 1/7] rcu: Add rcuog kthreads to RCU_NOCB_CPU help text Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 2/7] doc: Add rcuog kthreads to kernel-per-CPU-kthreads.rst Paul E. McKenney
@ 2024-10-09 18:00 ` Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 4/7] rcu: Permit start_poll_synchronize_rcu*() with interrupts disabled Paul E. McKenney
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Paul E. McKenney @ 2024-10-09 18:00 UTC (permalink / raw)
  To: frederic, rcu
  Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney,
	Peter Zijlstra, Neeraj Upadhyay

There are now architectures for which all deep-idle and entry-exit
functions are properly inlined or marked noinstr.  Such architectures do
not need synchronize_rcu_tasks_rude(), or will not once RCU Tasks has
been modified to pay attention to idle tasks.  This commit therefore
allows a CONFIG_ARCH_HAS_NOINSTR_MARKINGS Kconfig option to turn
synchronize_rcu_tasks_rude() into a no-op.

To facilitate testing, kernels built by rcutorture scripting will enable
RCU Tasks Trace even on systems that do not need it.

[ paulmck: Apply Peter Zijlstra feedback. ]

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
---
 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index 6333f4ccf024b..dd9730fd44fbe 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -1398,7 +1398,8 @@ static void call_rcu_tasks_rude(struct rcu_head *rhp, rcu_callback_t func)
  */
 void synchronize_rcu_tasks_rude(void)
 {
-	synchronize_rcu_tasks_generic(&rcu_tasks_rude);
+	if (!IS_ENABLED(CONFIG_ARCH_WANTS_NO_INSTR) || IS_ENABLED(CONFIG_FORCE_TASKS_RUDE_RCU))
+		synchronize_rcu_tasks_generic(&rcu_tasks_rude);
 }
 EXPORT_SYMBOL_GPL(synchronize_rcu_tasks_rude);
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH rcu 4/7] rcu: Permit start_poll_synchronize_rcu*() with interrupts disabled
  2024-10-09 18:00 [PATCH rcu 0/7] Miscellaneous changes for v6.13 Paul E. McKenney
                   ` (2 preceding siblings ...)
  2024-10-09 18:00 ` [PATCH rcu 3/7] rcu: Allow short-circuiting of synchronize_rcu_tasks_rude() Paul E. McKenney
@ 2024-10-09 18:00 ` Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 5/7] rcutorture: Test start-poll primitives " Paul E. McKenney
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Paul E. McKenney @ 2024-10-09 18:00 UTC (permalink / raw)
  To: frederic, rcu
  Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney,
	Kent Overstreet

The header comment for both start_poll_synchronize_rcu() and
start_poll_synchronize_rcu_full() state that interrupts must be enabled
when calling these two functions, and there is a lockdep assertion in
start_poll_synchronize_rcu_common() enforcing this restriction.  However,
there is no need for this restrictions, as can be seen in call_rcu(),
which does wakeups when interrupts are disabled.

This commit therefore removes the lockdep assertion and the comments.

Reported-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/tree.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index a60616e69b663..3d6507d0b8d33 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -4193,7 +4193,6 @@ static void start_poll_synchronize_rcu_common(void)
 	struct rcu_data *rdp;
 	struct rcu_node *rnp;
 
-	lockdep_assert_irqs_enabled();
 	local_irq_save(flags);
 	rdp = this_cpu_ptr(&rcu_data);
 	rnp = rdp->mynode;
@@ -4218,9 +4217,6 @@ static void start_poll_synchronize_rcu_common(void)
  * grace period has elapsed in the meantime.  If the needed grace period
  * is not already slated to start, notifies RCU core of the need for that
  * grace period.
- *
- * Interrupts must be enabled for the case where it is necessary to awaken
- * the grace-period kthread.
  */
 unsigned long start_poll_synchronize_rcu(void)
 {
@@ -4241,9 +4237,6 @@ EXPORT_SYMBOL_GPL(start_poll_synchronize_rcu);
  * grace period (whether normal or expedited) has elapsed in the meantime.
  * If the needed grace period is not already slated to start, notifies
  * RCU core of the need for that grace period.
- *
- * Interrupts must be enabled for the case where it is necessary to awaken
- * the grace-period kthread.
  */
 void start_poll_synchronize_rcu_full(struct rcu_gp_oldstate *rgosp)
 {
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH rcu 5/7] rcutorture: Test start-poll primitives with interrupts disabled
  2024-10-09 18:00 [PATCH rcu 0/7] Miscellaneous changes for v6.13 Paul E. McKenney
                   ` (3 preceding siblings ...)
  2024-10-09 18:00 ` [PATCH rcu 4/7] rcu: Permit start_poll_synchronize_rcu*() with interrupts disabled Paul E. McKenney
@ 2024-10-09 18:00 ` Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 6/7] doc: Remove kernel-parameters.txt entry for rcutorture.read_exit Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 7/7] rcu-tasks: Remove open-coded one-byte cmpxchg() emulation Paul E. McKenney
  6 siblings, 0 replies; 8+ messages in thread
From: Paul E. McKenney @ 2024-10-09 18:00 UTC (permalink / raw)
  To: frederic, rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

This commit tests the ->start_poll() and ->start_poll_full() functions
with interrupts disabled, but only for RCU variants setting the
->start_poll_irqsoff flag.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/rcutorture.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index bb75dbf5c800c..b4cb7623a8bfc 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -393,6 +393,7 @@ struct rcu_torture_ops {
 	int slow_gps;
 	int no_pi_lock;
 	int debug_objects;
+	int start_poll_irqsoff;
 	const char *name;
 };
 
@@ -581,6 +582,7 @@ static struct rcu_torture_ops rcu_ops = {
 	.can_boost		= IS_ENABLED(CONFIG_RCU_BOOST),
 	.extendables		= RCUTORTURE_MAX_EXTEND,
 	.debug_objects		= 1,
+	.start_poll_irqsoff	= 1,
 	.name			= "rcu"
 };
 
@@ -1695,14 +1697,22 @@ rcu_torture_fakewriter(void *arg)
 				cur_ops->cond_sync_exp_full(&gp_snap_full);
 				break;
 			case RTWS_POLL_GET:
+				if (cur_ops->start_poll_irqsoff)
+					local_irq_disable();
 				gp_snap = cur_ops->start_gp_poll();
+				if (cur_ops->start_poll_irqsoff)
+					local_irq_enable();
 				while (!cur_ops->poll_gp_state(gp_snap)) {
 					torture_hrtimeout_jiffies(torture_random(&rand) % 16,
 								  &rand);
 				}
 				break;
 			case RTWS_POLL_GET_FULL:
+				if (cur_ops->start_poll_irqsoff)
+					local_irq_disable();
 				cur_ops->start_gp_poll_full(&gp_snap_full);
+				if (cur_ops->start_poll_irqsoff)
+					local_irq_enable();
 				while (!cur_ops->poll_gp_state_full(&gp_snap_full)) {
 					torture_hrtimeout_jiffies(torture_random(&rand) % 16,
 								  &rand);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH rcu 6/7] doc: Remove kernel-parameters.txt entry for rcutorture.read_exit
  2024-10-09 18:00 [PATCH rcu 0/7] Miscellaneous changes for v6.13 Paul E. McKenney
                   ` (4 preceding siblings ...)
  2024-10-09 18:00 ` [PATCH rcu 5/7] rcutorture: Test start-poll primitives " Paul E. McKenney
@ 2024-10-09 18:00 ` Paul E. McKenney
  2024-10-09 18:00 ` [PATCH rcu 7/7] rcu-tasks: Remove open-coded one-byte cmpxchg() emulation Paul E. McKenney
  6 siblings, 0 replies; 8+ messages in thread
From: Paul E. McKenney @ 2024-10-09 18:00 UTC (permalink / raw)
  To: frederic, rcu
  Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney,
	Alexei Starovoitov, Andrii Nakryiko, Peter Zijlstra,
	Kent Overstreet, bpf

There is only ever the one read-exit task, and there is no module
parameter named rcutorture.read_exit, so remove the bogus documentation.
Instead, use rcutorture.read_exit_burst to enable/disable read-exit
race testing.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: <bpf@vger.kernel.org>
---
 Documentation/admin-guide/kernel-parameters.txt | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 1518343bbe223..7edc5a5ba9c98 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5412,11 +5412,6 @@
 			Set time (jiffies) between CPU-hotplug operations,
 			or zero to disable CPU-hotplug testing.
 
-	rcutorture.read_exit= [KNL]
-			Set the number of read-then-exit kthreads used
-			to test the interaction of RCU updaters and
-			task-exit processing.
-
 	rcutorture.read_exit_burst= [KNL]
 			The number of times in a given read-then-exit
 			episode that a set of read-then-exit kthreads
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH rcu 7/7] rcu-tasks: Remove open-coded one-byte cmpxchg() emulation
  2024-10-09 18:00 [PATCH rcu 0/7] Miscellaneous changes for v6.13 Paul E. McKenney
                   ` (5 preceding siblings ...)
  2024-10-09 18:00 ` [PATCH rcu 6/7] doc: Remove kernel-parameters.txt entry for rcutorture.read_exit Paul E. McKenney
@ 2024-10-09 18:00 ` Paul E. McKenney
  6 siblings, 0 replies; 8+ messages in thread
From: Paul E. McKenney @ 2024-10-09 18:00 UTC (permalink / raw)
  To: frederic, rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

This commit removes the open-coded one-byte cmpxchg() emulation from
rcu_trc_cmpxchg_need_qs(), replacing it with just cmpxchg() given the
latter's new-found ability to handle single-byte arguments across all
architectures.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/tasks.h | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index dd9730fd44fbe..c789d994e7ebc 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -1541,22 +1541,7 @@ static void rcu_st_need_qs(struct task_struct *t, u8 v)
  */
 u8 rcu_trc_cmpxchg_need_qs(struct task_struct *t, u8 old, u8 new)
 {
-	union rcu_special ret;
-	union rcu_special trs_old = READ_ONCE(t->trc_reader_special);
-	union rcu_special trs_new = trs_old;
-
-	if (trs_old.b.need_qs != old)
-		return trs_old.b.need_qs;
-	trs_new.b.need_qs = new;
-
-	// Although cmpxchg() appears to KCSAN to update all four bytes,
-	// only the .b.need_qs byte actually changes.
-	instrument_atomic_read_write(&t->trc_reader_special.b.need_qs,
-				     sizeof(t->trc_reader_special.b.need_qs));
-	// Avoid false-positive KCSAN failures.
-	ret.s = data_race(cmpxchg(&t->trc_reader_special.s, trs_old.s, trs_new.s));
-
-	return ret.b.need_qs;
+	return cmpxchg(&t->trc_reader_special.b.need_qs, old, new);
 }
 EXPORT_SYMBOL_GPL(rcu_trc_cmpxchg_need_qs);
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-09 18:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09 18:00 [PATCH rcu 0/7] Miscellaneous changes for v6.13 Paul E. McKenney
2024-10-09 18:00 ` [PATCH rcu 1/7] rcu: Add rcuog kthreads to RCU_NOCB_CPU help text Paul E. McKenney
2024-10-09 18:00 ` [PATCH rcu 2/7] doc: Add rcuog kthreads to kernel-per-CPU-kthreads.rst Paul E. McKenney
2024-10-09 18:00 ` [PATCH rcu 3/7] rcu: Allow short-circuiting of synchronize_rcu_tasks_rude() Paul E. McKenney
2024-10-09 18:00 ` [PATCH rcu 4/7] rcu: Permit start_poll_synchronize_rcu*() with interrupts disabled Paul E. McKenney
2024-10-09 18:00 ` [PATCH rcu 5/7] rcutorture: Test start-poll primitives " Paul E. McKenney
2024-10-09 18:00 ` [PATCH rcu 6/7] doc: Remove kernel-parameters.txt entry for rcutorture.read_exit Paul E. McKenney
2024-10-09 18:00 ` [PATCH rcu 7/7] rcu-tasks: Remove open-coded one-byte cmpxchg() emulation Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.