mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] Miscellaneous fixes for post-v4.19
@ 2025-12-29 19:16 Paul E. McKenney
  2025-12-29 19:16 ` [PATCH v4 1/2] rcu: Make expedited RCU CPU stall warnings detect stall-end races Paul E. McKenney
  2025-12-29 19:16 ` [PATCH v4 2/2] rcutorture: Correctly compute probability to invoke ->exp_current() Paul E. McKenney
  0 siblings, 2 replies; 4+ messages in thread
From: Paul E. McKenney @ 2025-12-29 19:16 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt

Hello!

This series contains miscellaneous fixes:

1.	Make expedited RCU CPU stall warnings detect stall-end races.

2.	Correctly compute probability to invoke ->exp_current().

						Thanx, Paul

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

 rcutorture.c |    4 ++--
 tree_exp.h   |    7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

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

* [PATCH v4 1/2] rcu: Make expedited RCU CPU stall warnings detect stall-end races
  2025-12-29 19:16 [PATCH 0/2] Miscellaneous fixes for post-v4.19 Paul E. McKenney
@ 2025-12-29 19:16 ` Paul E. McKenney
  2025-12-31 17:13   ` Borislav Petkov
  2025-12-29 19:16 ` [PATCH v4 2/2] rcutorture: Correctly compute probability to invoke ->exp_current() Paul E. McKenney
  1 sibling, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2025-12-29 19:16 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney, Borislav Petkov

If an expedited RCU CPU stall ends just at the stall-warning timeout,
the current code will print an expedited stall-warning message, but one
that doesn't identify any CPUs or tasks causing the stall.  This is most
likely to happen for short-timeout stalls, for example, the 20-millisecond
timeouts that are sometimes used for small embedded devices.  Needless to
say, these semi-empty stall-warning messages can be rather confusing.

One option would be to suppress the stall-warning message entirely in
this case, but the near-miss information can be quite valuable.

This commit therefore detects this race condition and emits a "INFO:
Expedited stall ended before state dump start" message to clarify matters.

Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/tree_exp.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index 96c49c56fc14a..82cada459e5d0 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -589,7 +589,12 @@ static void synchronize_rcu_expedited_stall(unsigned long jiffies_start, unsigne
 	pr_cont(" } %lu jiffies s: %lu root: %#lx/%c\n",
 		j - jiffies_start, rcu_state.expedited_sequence, data_race(rnp_root->expmask),
 		".T"[!!data_race(rnp_root->exp_tasks)]);
-	if (ndetected) {
+	if (!ndetected) {
+		// This is invoked from the grace-period worker, so
+		// a new grace period cannot have started.  And if this
+		// worker were stalled, we would not get here.  ;-)
+		pr_err("INFO: Expedited stall ended before state dump start\n");
+	} else {
 		pr_err("blocking rcu_node structures (internal RCU debug):");
 		rcu_for_each_node_breadth_first(rnp) {
 			if (rnp == rnp_root)
-- 
2.40.1


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

* [PATCH v4 2/2] rcutorture: Correctly compute probability to invoke ->exp_current()
  2025-12-29 19:16 [PATCH 0/2] Miscellaneous fixes for post-v4.19 Paul E. McKenney
  2025-12-29 19:16 ` [PATCH v4 1/2] rcu: Make expedited RCU CPU stall warnings detect stall-end races Paul E. McKenney
@ 2025-12-29 19:16 ` Paul E. McKenney
  1 sibling, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2025-12-29 19:16 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney,
	Chris Mason, Joel Fernandes

Lack of parentheses causes the ->exp_current() function, for example,
srcu_expedite_current(), to be called only once in four billion times
instead of the intended once in 256 times.  This commit therefore adds
the needed parentheses.

Reported-by: Chris Mason <clm@meta.com>
Reported-by: Joel Fernandes <joelagnelf@nvidia.com>
Fixes: 950063c6e897 ("rcutorture: Test srcu_expedite_current()")
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/rcutorture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 63053031ade21..47ce7f49b52c6 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1749,7 +1749,7 @@ rcu_torture_writer(void *arg)
 					ulo[i] = cur_ops->get_comp_state();
 				gp_snap = cur_ops->start_gp_poll();
 				rcu_torture_writer_state = RTWS_POLL_WAIT;
-				if (cur_ops->exp_current && !torture_random(&rand) % 0xff)
+				if (cur_ops->exp_current && !(torture_random(&rand) & 0xff))
 					cur_ops->exp_current();
 				while (!cur_ops->poll_gp_state(gp_snap)) {
 					gp_snap1 = cur_ops->get_gp_state();
@@ -1771,7 +1771,7 @@ rcu_torture_writer(void *arg)
 					cur_ops->get_comp_state_full(&rgo[i]);
 				cur_ops->start_gp_poll_full(&gp_snap_full);
 				rcu_torture_writer_state = RTWS_POLL_WAIT_FULL;
-				if (cur_ops->exp_current && !torture_random(&rand) % 0xff)
+				if (cur_ops->exp_current && !(torture_random(&rand) & 0xff))
 					cur_ops->exp_current();
 				while (!cur_ops->poll_gp_state_full(&gp_snap_full)) {
 					cur_ops->get_gp_state_full(&gp_snap1_full);
-- 
2.40.1


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

* Re: [PATCH v4 1/2] rcu: Make expedited RCU CPU stall warnings detect stall-end races
  2025-12-29 19:16 ` [PATCH v4 1/2] rcu: Make expedited RCU CPU stall warnings detect stall-end races Paul E. McKenney
@ 2025-12-31 17:13   ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2025-12-31 17:13 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: rcu, linux-kernel, kernel-team, rostedt

On Mon, Dec 29, 2025 at 11:16:15AM -0800, Paul E. McKenney wrote:
> If an expedited RCU CPU stall ends just at the stall-warning timeout,
> the current code will print an expedited stall-warning message, but one
> that doesn't identify any CPUs or tasks causing the stall.  This is most
> likely to happen for short-timeout stalls, for example, the 20-millisecond
> timeouts that are sometimes used for small embedded devices.  Needless to
> say, these semi-empty stall-warning messages can be rather confusing.
> 
> One option would be to suppress the stall-warning message entirely in
> this case, but the near-miss information can be quite valuable.
> 
> This commit therefore detects this race condition and emits a "INFO:

s/This commit therefore detects this/Detect this/

> Expedited stall ended before state dump start" message to clarify matters.
> 
> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> ---
>  kernel/rcu/tree_exp.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

But yeah, makes sense.

Acked-by: Borislav Petkov (AMD) <bp@alien8.de>

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

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

end of thread, other threads:[~2025-12-31 17:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-29 19:16 [PATCH 0/2] Miscellaneous fixes for post-v4.19 Paul E. McKenney
2025-12-29 19:16 ` [PATCH v4 1/2] rcu: Make expedited RCU CPU stall warnings detect stall-end races Paul E. McKenney
2025-12-31 17:13   ` Borislav Petkov
2025-12-29 19:16 ` [PATCH v4 2/2] rcutorture: Correctly compute probability to invoke ->exp_current() Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®