All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13
@ 2021-03-03 23:59 Paul E. McKenney
  2021-03-04  0:00 ` [PATCH tip/core/rcu 01/10] rcu: Remove superfluous rdp fetch paulmck
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Paul E. McKenney @ 2021-03-03 23:59 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel

Hello!

This series contains miscellaneous fixes:

1.	Remove superfluous rdp fetch, courtesy of Frederic Weisbecker.

2.	Fix CPU-offline trace in rcutree_dying_cpu, courtesy of Neeraj
	Upadhyay.

3.	Remove spurious instrumentation_end() in rcu_nmi_enter(),
	courtesy of Zhouyi Zhou.

4.	Replace reference to atomic_ops.rst, courtesy of Akira Yokosawa.

5.	Fix kfree_rcu() docbook errors, courtesy of Mauro Carvalho Chehab.

6.	Don't try waking ksoftirqd before it has been spawned.

7.	Prevent dyntick-idle until ksoftirqd has been spawned.

8.	Correctly spell Stephen Hemminger's name.

9.	Add explicit barrier() to __rcu_read_unlock().

10.	Add a trace event for RCU CPU stall warnings, courtesy of
	Sangmoon Kim.

						Thanx, Paul

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

 Documentation/RCU/RTFP.txt    |    2 +-
 include/linux/rculist_nulls.h |    2 +-
 include/linux/rcupdate.h      |    2 +-
 include/trace/events/rcu.h    |   28 ++++++++++++++++++++++++++++
 kernel/rcu/tree.c             |    4 +---
 kernel/rcu/tree_exp.h         |    1 +
 kernel/rcu/tree_plugin.h      |   14 +++++++++++++-
 kernel/rcu/tree_stall.h       |    2 ++
 kernel/softirq.c              |    2 +-
 9 files changed, 49 insertions(+), 8 deletions(-)

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

* [PATCH tip/core/rcu 01/10] rcu: Remove superfluous rdp fetch
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
@ 2021-03-04  0:00 ` paulmck
  2021-03-04  0:00 ` [PATCH tip/core/rcu 02/10] rcu: Fix CPU-offline trace in rcutree_dying_cpu paulmck
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Frederic Weisbecker,
	Rafael J . Wysocki, Paul E . McKenney

From: Frederic Weisbecker <frederic@kernel.org>

Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar<mingo@kernel.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/tree.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index da6f521..cdf091f 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -648,7 +648,6 @@ static noinstr void rcu_eqs_enter(bool user)
 	instrumentation_begin();
 	trace_rcu_dyntick(TPS("Start"), rdp->dynticks_nesting, 0, atomic_read(&rdp->dynticks));
 	WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && !is_idle_task(current));
-	rdp = this_cpu_ptr(&rcu_data);
 	rcu_prepare_for_idle();
 	rcu_preempt_deferred_qs(current);
 
-- 
2.9.5


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

* [PATCH tip/core/rcu 02/10] rcu: Fix CPU-offline trace in rcutree_dying_cpu
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
  2021-03-04  0:00 ` [PATCH tip/core/rcu 01/10] rcu: Remove superfluous rdp fetch paulmck
@ 2021-03-04  0:00 ` paulmck
  2021-03-04  0:00 ` [PATCH tip/core/rcu 03/10] rcu: Remove spurious instrumentation_end() in rcu_nmi_enter() paulmck
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Neeraj Upadhyay,
	Paul E . McKenney

From: Neeraj Upadhyay <neeraju@codeaurora.org>

The condition in the trace_rcu_grace_period() in rcutree_dying_cpu() is
backwards, so that it uses the string "cpuofl" when the offline CPU is
blocking the current grace period and "cpuofl-bgp" otherwise.  Given that
the "-bgp" stands for "blocking grace period", this is at best misleading.
This commit therefore switches these strings in order to correctly trace
whether the outgoing cpu blocks the current grace period.

Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index cdf091f..e62c2de 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -2413,7 +2413,7 @@ int rcutree_dying_cpu(unsigned int cpu)
 
 	blkd = !!(rnp->qsmask & rdp->grpmask);
 	trace_rcu_grace_period(rcu_state.name, READ_ONCE(rnp->gp_seq),
-			       blkd ? TPS("cpuofl") : TPS("cpuofl-bgp"));
+			       blkd ? TPS("cpuofl-bgp") : TPS("cpuofl"));
 	return 0;
 }
 
-- 
2.9.5


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

* [PATCH tip/core/rcu 03/10] rcu: Remove spurious instrumentation_end() in rcu_nmi_enter()
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
  2021-03-04  0:00 ` [PATCH tip/core/rcu 01/10] rcu: Remove superfluous rdp fetch paulmck
  2021-03-04  0:00 ` [PATCH tip/core/rcu 02/10] rcu: Fix CPU-offline trace in rcutree_dying_cpu paulmck
@ 2021-03-04  0:00 ` paulmck
  2021-03-04  0:00 ` [PATCH tip/core/rcu 04/10] rculist: Replace reference to atomic_ops.rst paulmck
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Zhouyi Zhou, Paul E . McKenney

From: Zhouyi Zhou <zhouzhouyi@gmail.com>

In rcu_nmi_enter(), there is an erroneous instrumentation_end() in the
second branch of the "if" statement.  Oddly enough, "objtool check -f
vmlinux.o" fails to complain because it is unable to correctly cover
all cases.  Instead, objtool visits the third branch first, which marks
following trace_rcu_dyntick() as visited.  This commit therefore removes
the spurious instrumentation_end().

Fixes: 04b25a495bd6 ("rcu: Mark rcu_nmi_enter() call to rcu_cleanup_after_idle() noinstr")
Reported-by Neeraj Upadhyay <neeraju@codeaurora.org>
Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/tree.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index e62c2de..4d90f20 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1076,7 +1076,6 @@ noinstr void rcu_nmi_enter(void)
 	} else if (!in_nmi()) {
 		instrumentation_begin();
 		rcu_irq_enter_check_tick();
-		instrumentation_end();
 	} else  {
 		instrumentation_begin();
 	}
-- 
2.9.5


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

* [PATCH tip/core/rcu 04/10] rculist: Replace reference to atomic_ops.rst
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
                   ` (2 preceding siblings ...)
  2021-03-04  0:00 ` [PATCH tip/core/rcu 03/10] rcu: Remove spurious instrumentation_end() in rcu_nmi_enter() paulmck
@ 2021-03-04  0:00 ` paulmck
  2021-03-04  0:00 ` [PATCH tip/core/rcu 05/10] rcu: Fix kfree_rcu() docbook errors paulmck
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Akira Yokosawa,
	Paul E . McKenney

From: Akira Yokosawa <akiyks@gmail.com>

The hlist_nulls_for_each_entry_rcu() docbook header references the
atomic_ops.rst file, which was removed in commit f0400a77ebdc ("atomic:
Delete obsolete documentation").  This commit therefore substitutes a
section in memory-barriers.txt discussing the use of barrier() in loops.

Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 include/linux/rculist_nulls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h
index ff3e947..d8afdb8 100644
--- a/include/linux/rculist_nulls.h
+++ b/include/linux/rculist_nulls.h
@@ -161,7 +161,7 @@ static inline void hlist_nulls_add_fake(struct hlist_nulls_node *n)
  *
  * The barrier() is needed to make sure compiler doesn't cache first element [1],
  * as this loop can be restarted [2]
- * [1] Documentation/core-api/atomic_ops.rst around line 114
+ * [1] Documentation/memory-barriers.txt around line 1533
  * [2] Documentation/RCU/rculist_nulls.rst around line 146
  */
 #define hlist_nulls_for_each_entry_rcu(tpos, pos, head, member)			\
-- 
2.9.5


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

* [PATCH tip/core/rcu 05/10] rcu: Fix kfree_rcu() docbook errors
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
                   ` (3 preceding siblings ...)
  2021-03-04  0:00 ` [PATCH tip/core/rcu 04/10] rculist: Replace reference to atomic_ops.rst paulmck
@ 2021-03-04  0:00 ` paulmck
  2021-03-04  0:00 ` [PATCH tip/core/rcu 06/10] softirq: Don't try waking ksoftirqd before it has been spawned paulmck
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Mauro Carvalho Chehab,
	Paul E . McKenney

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

After commit 5130b8fd0690 ("rcu: Introduce kfree_rcu() single-argument macro"),
kernel-doc now emits two warnings:

	./include/linux/rcupdate.h:884: warning: Excess function parameter 'ptr' description in 'kfree_rcu'
	./include/linux/rcupdate.h:884: warning: Excess function parameter 'rhf' description in 'kfree_rcu'

This commit added some macro magic in order to call two different versions
of kfree_rcu(), the first having just one argument and the second having
two arguments.  That makes it difficult to document the kfree_rcu() arguments
in the docboook header.

In order to make clearer that this macro accepts optional arguments,
this commit uses macro concatenation so that this macro changes from:
	#define kfree_rcu kvfree_rcu

to:
	#define kfree_rcu(ptr, rhf...) kvfree_rcu(ptr, ## rhf)

That not only helps kernel-doc understand the macro arguments, but also
provides a better C definition that makes clearer that the first argument
is mandatory and the second one is optional.

Fixes: 5130b8fd0690 ("rcu: Introduce kfree_rcu() single-argument macro")
Tested-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 include/linux/rcupdate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index bd04f72..5cc6dea 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -881,7 +881,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
  * The BUILD_BUG_ON check must not involve any function calls, hence the
  * checks are done in macros here.
  */
-#define kfree_rcu kvfree_rcu
+#define kfree_rcu(ptr, rhf...) kvfree_rcu(ptr, ## rhf)
 
 /**
  * kvfree_rcu() - kvfree an object after a grace period.
-- 
2.9.5


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

* [PATCH tip/core/rcu 06/10] softirq: Don't try waking ksoftirqd before it has been spawned
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
                   ` (4 preceding siblings ...)
  2021-03-04  0:00 ` [PATCH tip/core/rcu 05/10] rcu: Fix kfree_rcu() docbook errors paulmck
@ 2021-03-04  0:00 ` paulmck
  2021-03-12 11:36   ` Frederic Weisbecker
  2021-03-04  0:00 ` [PATCH tip/core/rcu 07/10] rcu: Prevent dyntick-idle until ksoftirqd " paulmck
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

From: "Paul E. McKenney" <paulmck@kernel.org>

If there is heavy softirq activity, the softirq system will attempt
to awaken ksoftirqd and will stop the traditional back-of-interrupt
softirq processing.  This is all well and good, but only if the
ksoftirqd kthreads already exist, which is not the case during early
boot, in which case the system hangs.

One reproducer is as follows:

tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 2 --configs "TREE03" --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y CONFIG_NO_HZ_IDLE=y CONFIG_HZ_PERIODIC=n" --bootargs "threadirqs=1" --trust-make

This commit therefore adds a couple of existence checks for ksoftirqd
and forces back-of-interrupt softirq processing when ksoftirqd does not
yet exist.  With this change, the above test passes.

Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reported-by: Uladzislau Rezki <urezki@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
[ paulmck: Remove unneeded check per Sebastian Siewior feedback. ]
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/softirq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 9908ec4a..bad14ca 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -211,7 +211,7 @@ static inline void invoke_softirq(void)
 	if (ksoftirqd_running(local_softirq_pending()))
 		return;
 
-	if (!force_irqthreads) {
+	if (!force_irqthreads || !__this_cpu_read(ksoftirqd)) {
 #ifdef CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK
 		/*
 		 * We can safely execute softirq on the current stack if
-- 
2.9.5


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

* [PATCH tip/core/rcu 07/10] rcu: Prevent dyntick-idle until ksoftirqd has been spawned
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
                   ` (5 preceding siblings ...)
  2021-03-04  0:00 ` [PATCH tip/core/rcu 06/10] softirq: Don't try waking ksoftirqd before it has been spawned paulmck
@ 2021-03-04  0:00 ` paulmck
  2021-03-11 23:23   ` Frederic Weisbecker
  2021-03-04  0:00 ` [PATCH tip/core/rcu 08/10] docs: Correctly spell Stephen Hemminger's name paulmck
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

From: "Paul E. McKenney" <paulmck@kernel.org>

After interrupts have enabled at boot but before some random point
in early_initcall() processing, softirq processing is unreliable.
If softirq sees a need to push softirq-handler invocation to ksoftirqd
during this time, then those handlers can be delayed until the ksoftirqd
kthreads have been spawned, which happens at some random point in the
early_initcall() processing.  In many cases, this delay is just fine.
However, if the boot sequence blocks waiting for a wakeup from a softirq
handler, this delay will result in a silent-hang deadlock.

This commit therefore prevents these hangs by ensuring that the tick
stays active until after the ksoftirqd kthreads have been spawned.
This change causes the tick to eventually drain the backlog of delayed
softirq handlers, breaking this deadlock.

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

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 2d60377..36212de 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -1255,6 +1255,11 @@ static void rcu_prepare_kthreads(int cpu)
  */
 int rcu_needs_cpu(u64 basemono, u64 *nextevt)
 {
+	/* Through early_initcall(), need tick for softirq handlers. */
+	if (!IS_ENABLED(CONFIG_HZ_PERIODIC) && !this_cpu_ksoftirqd()) {
+		*nextevt = 1;
+		return 1;
+	}
 	*nextevt = KTIME_MAX;
 	return !rcu_segcblist_empty(&this_cpu_ptr(&rcu_data)->cblist) &&
 	       !rcu_segcblist_is_offloaded(&this_cpu_ptr(&rcu_data)->cblist);
@@ -1350,6 +1355,12 @@ int rcu_needs_cpu(u64 basemono, u64 *nextevt)
 
 	lockdep_assert_irqs_disabled();
 
+	/* Through early_initcall(), need tick for softirq handlers. */
+	if (!IS_ENABLED(CONFIG_HZ_PERIODIC) && !this_cpu_ksoftirqd()) {
+		*nextevt = 1;
+		return 1;
+	}
+
 	/* If no non-offloaded callbacks, RCU doesn't need the CPU. */
 	if (rcu_segcblist_empty(&rdp->cblist) ||
 	    rcu_segcblist_is_offloaded(&this_cpu_ptr(&rcu_data)->cblist)) {
-- 
2.9.5


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

* [PATCH tip/core/rcu 08/10] docs: Correctly spell Stephen Hemminger's name
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
                   ` (6 preceding siblings ...)
  2021-03-04  0:00 ` [PATCH tip/core/rcu 07/10] rcu: Prevent dyntick-idle until ksoftirqd " paulmck
@ 2021-03-04  0:00 ` paulmck
  2021-03-04  0:00 ` [PATCH tip/core/rcu 09/10] rcu: Add explicit barrier() to __rcu_read_unlock() paulmck
  2021-03-04  0:00 ` [PATCH tip/core/rcu 10/10] rcu/tree: Add a trace event for RCU CPU stall warnings paulmck
  9 siblings, 0 replies; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

From: "Paul E. McKenney" <paulmck@kernel.org>

This commit replaces "Steve" with the his real name, which is "Stephen".

Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 Documentation/RCU/RTFP.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/RCU/RTFP.txt b/Documentation/RCU/RTFP.txt
index 3b0876c..588d973 100644
--- a/Documentation/RCU/RTFP.txt
+++ b/Documentation/RCU/RTFP.txt
@@ -847,7 +847,7 @@ Symposium on Distributed Computing}
 	'It's entirely possible that the current user could be replaced
 	by RCU and/or seqlocks, and we could get rid of brlocks entirely.'
 	.
-	Steve Hemminger responds by replacing them with RCU.
+	Stephen Hemminger responds by replacing them with RCU.
 }
 }
 
-- 
2.9.5


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

* [PATCH tip/core/rcu 09/10] rcu: Add explicit barrier() to __rcu_read_unlock()
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
                   ` (7 preceding siblings ...)
  2021-03-04  0:00 ` [PATCH tip/core/rcu 08/10] docs: Correctly spell Stephen Hemminger's name paulmck
@ 2021-03-04  0:00 ` paulmck
  2021-03-04  0:00 ` [PATCH tip/core/rcu 10/10] rcu/tree: Add a trace event for RCU CPU stall warnings paulmck
  9 siblings, 0 replies; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Paul E. McKenney

From: "Paul E. McKenney" <paulmck@kernel.org>

Because preemptible RCU's __rcu_read_unlock() is an external function,
the rough equivalent of an implicit barrier() is inserted by the compiler.
Except that there is a direct call to __rcu_read_unlock() in that same
file, and compilers are getting to the point where they might choose to
inline the fastpath of the __rcu_read_unlock() function.

This commit therefore adds an explicit barrier() to the very beginning
of __rcu_read_unlock().

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/tree_plugin.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 36212de..d9495de 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -393,8 +393,9 @@ void __rcu_read_unlock(void)
 {
 	struct task_struct *t = current;
 
+	barrier();  // critical section before exit code.
 	if (rcu_preempt_read_exit() == 0) {
-		barrier();  /* critical section before exit code. */
+		barrier();  // critical-section exit before .s check.
 		if (unlikely(READ_ONCE(t->rcu_read_unlock_special.s)))
 			rcu_read_unlock_special(t);
 	}
-- 
2.9.5


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

* [PATCH tip/core/rcu 10/10] rcu/tree: Add a trace event for RCU CPU stall warnings
  2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
                   ` (8 preceding siblings ...)
  2021-03-04  0:00 ` [PATCH tip/core/rcu 09/10] rcu: Add explicit barrier() to __rcu_read_unlock() paulmck
@ 2021-03-04  0:00 ` paulmck
  9 siblings, 0 replies; 15+ messages in thread
From: paulmck @ 2021-03-04  0:00 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, Sangmoon Kim, Paul E . McKenney

From: Sangmoon Kim <sangmoon.kim@samsung.com>

This commit adds a trace event which allows tracing the beginnings of RCU
CPU stall warnings on systems where sysctl_panic_on_rcu_stall is disabled.

The first parameter is the name of RCU flavor like other trace events.
The second parameter indicates whether this is a stall of an expedited
grace period, a self-detected stall of a normal grace period, or a stall
of a normal grace period detected by some CPU other than the one that
is stalled.

RCU CPU stall warnings are often caused by external-to-RCU issues,
for example, in interrupt handling or task scheduling.  Therefore,
this event uses TRACE_EVENT, not TRACE_EVENT_RCU, to avoid requiring
those interested in tracing RCU CPU stalls to rebuild their kernels
with CONFIG_RCU_TRACE=y.

Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Neeraj Upadhyay <neeraju@codeaurora.org>
Signed-off-by: Sangmoon Kim <sangmoon.kim@samsung.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 include/trace/events/rcu.h | 28 ++++++++++++++++++++++++++++
 kernel/rcu/tree_exp.h      |  1 +
 kernel/rcu/tree_stall.h    |  2 ++
 3 files changed, 31 insertions(+)

diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
index 5fc2940..c7711e9 100644
--- a/include/trace/events/rcu.h
+++ b/include/trace/events/rcu.h
@@ -432,6 +432,34 @@ TRACE_EVENT_RCU(rcu_fqs,
 		  __entry->cpu, __entry->qsevent)
 );
 
+/*
+ * Tracepoint for RCU stall events. Takes a string identifying the RCU flavor
+ * and a string identifying which function detected the RCU stall as follows:
+ *
+ *	"StallDetected": Scheduler-tick detects other CPU's stalls.
+ *	"SelfDetected": Scheduler-tick detects a current CPU's stall.
+ *	"ExpeditedStall": Expedited grace period detects stalls.
+ */
+TRACE_EVENT(rcu_stall_warning,
+
+	TP_PROTO(const char *rcuname, const char *msg),
+
+	TP_ARGS(rcuname, msg),
+
+	TP_STRUCT__entry(
+		__field(const char *, rcuname)
+		__field(const char *, msg)
+	),
+
+	TP_fast_assign(
+		__entry->rcuname = rcuname;
+		__entry->msg = msg;
+	),
+
+	TP_printk("%s %s",
+		  __entry->rcuname, __entry->msg)
+);
+
 #endif /* #if defined(CONFIG_TREE_RCU) */
 
 /*
diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index 6c6ff06..2796084 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -521,6 +521,7 @@ static void synchronize_rcu_expedited_wait(void)
 		if (rcu_stall_is_suppressed())
 			continue;
 		panic_on_rcu_stall();
+		trace_rcu_stall_warning(rcu_state.name, TPS("ExpeditedStall"));
 		pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {",
 		       rcu_state.name);
 		ndetected = 0;
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index 475b261..59b95cc 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -536,6 +536,7 @@ static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps)
 	 * See Documentation/RCU/stallwarn.rst for info on how to debug
 	 * RCU CPU stall warnings.
 	 */
+	trace_rcu_stall_warning(rcu_state.name, TPS("StallDetected"));
 	pr_err("INFO: %s detected stalls on CPUs/tasks:\n", rcu_state.name);
 	rcu_for_each_leaf_node(rnp) {
 		raw_spin_lock_irqsave_rcu_node(rnp, flags);
@@ -606,6 +607,7 @@ static void print_cpu_stall(unsigned long gps)
 	 * See Documentation/RCU/stallwarn.rst for info on how to debug
 	 * RCU CPU stall warnings.
 	 */
+	trace_rcu_stall_warning(rcu_state.name, TPS("SelfDetected"));
 	pr_err("INFO: %s self-detected stall on CPU\n", rcu_state.name);
 	raw_spin_lock_irqsave_rcu_node(rdp->mynode, flags);
 	print_cpu_stall_info(smp_processor_id());
-- 
2.9.5


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

* Re: [PATCH tip/core/rcu 07/10] rcu: Prevent dyntick-idle until ksoftirqd has been spawned
  2021-03-04  0:00 ` [PATCH tip/core/rcu 07/10] rcu: Prevent dyntick-idle until ksoftirqd " paulmck
@ 2021-03-11 23:23   ` Frederic Weisbecker
  2021-03-11 23:34     ` Paul E. McKenney
  0 siblings, 1 reply; 15+ messages in thread
From: Frederic Weisbecker @ 2021-03-11 23:23 UTC (permalink / raw)
  To: paulmck
  Cc: rcu, linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel

On Wed, Mar 03, 2021 at 04:00:16PM -0800, paulmck@kernel.org wrote:
> From: "Paul E. McKenney" <paulmck@kernel.org>
> 
> After interrupts have enabled at boot but before some random point
> in early_initcall() processing, softirq processing is unreliable.
> If softirq sees a need to push softirq-handler invocation to ksoftirqd
> during this time, then those handlers can be delayed until the ksoftirqd
> kthreads have been spawned, which happens at some random point in the
> early_initcall() processing.  In many cases, this delay is just fine.
> However, if the boot sequence blocks waiting for a wakeup from a softirq
> handler, this delay will result in a silent-hang deadlock.
> 
> This commit therefore prevents these hangs by ensuring that the tick
> stays active until after the ksoftirqd kthreads have been spawned.
> This change causes the tick to eventually drain the backlog of delayed
> softirq handlers, breaking this deadlock.
> 
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> ---
>  kernel/rcu/tree_plugin.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 2d60377..36212de 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -1255,6 +1255,11 @@ static void rcu_prepare_kthreads(int cpu)
>   */
>  int rcu_needs_cpu(u64 basemono, u64 *nextevt)
>  {
> +	/* Through early_initcall(), need tick for softirq handlers. */
> +	if (!IS_ENABLED(CONFIG_HZ_PERIODIC) && !this_cpu_ksoftirqd()) {
> +		*nextevt = 1;
> +		return 1;
> +	}
>  	*nextevt = KTIME_MAX;
>  	return !rcu_segcblist_empty(&this_cpu_ptr(&rcu_data)->cblist) &&
>  	       !rcu_segcblist_is_offloaded(&this_cpu_ptr(&rcu_data)->cblist);
> @@ -1350,6 +1355,12 @@ int rcu_needs_cpu(u64 basemono, u64 *nextevt)
>  
>  	lockdep_assert_irqs_disabled();
>  
> +	/* Through early_initcall(), need tick for softirq handlers. */
> +	if (!IS_ENABLED(CONFIG_HZ_PERIODIC) && !this_cpu_ksoftirqd()) {
> +		*nextevt = 1;
> +		return 1;
> +	}
> +
>  	/* If no non-offloaded callbacks, RCU doesn't need the CPU. */
>  	if (rcu_segcblist_empty(&rdp->cblist) ||
>  	    rcu_segcblist_is_offloaded(&this_cpu_ptr(&rcu_data)->cblist)) {


I suspect rcutiny should be concerned as well?

In fact this patch doesn't look necessary because can_stop_idle_tick() refuse
to stop the tick when softirqs are pending.

Thanks.

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

* Re: [PATCH tip/core/rcu 07/10] rcu: Prevent dyntick-idle until ksoftirqd has been spawned
  2021-03-11 23:23   ` Frederic Weisbecker
@ 2021-03-11 23:34     ` Paul E. McKenney
  0 siblings, 0 replies; 15+ messages in thread
From: Paul E. McKenney @ 2021-03-11 23:34 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: rcu, linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel

On Fri, Mar 12, 2021 at 12:23:57AM +0100, Frederic Weisbecker wrote:
> On Wed, Mar 03, 2021 at 04:00:16PM -0800, paulmck@kernel.org wrote:
> > From: "Paul E. McKenney" <paulmck@kernel.org>
> > 
> > After interrupts have enabled at boot but before some random point
> > in early_initcall() processing, softirq processing is unreliable.
> > If softirq sees a need to push softirq-handler invocation to ksoftirqd
> > during this time, then those handlers can be delayed until the ksoftirqd
> > kthreads have been spawned, which happens at some random point in the
> > early_initcall() processing.  In many cases, this delay is just fine.
> > However, if the boot sequence blocks waiting for a wakeup from a softirq
> > handler, this delay will result in a silent-hang deadlock.
> > 
> > This commit therefore prevents these hangs by ensuring that the tick
> > stays active until after the ksoftirqd kthreads have been spawned.
> > This change causes the tick to eventually drain the backlog of delayed
> > softirq handlers, breaking this deadlock.
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > ---
> >  kernel/rcu/tree_plugin.h | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> > index 2d60377..36212de 100644
> > --- a/kernel/rcu/tree_plugin.h
> > +++ b/kernel/rcu/tree_plugin.h
> > @@ -1255,6 +1255,11 @@ static void rcu_prepare_kthreads(int cpu)
> >   */
> >  int rcu_needs_cpu(u64 basemono, u64 *nextevt)
> >  {
> > +	/* Through early_initcall(), need tick for softirq handlers. */
> > +	if (!IS_ENABLED(CONFIG_HZ_PERIODIC) && !this_cpu_ksoftirqd()) {
> > +		*nextevt = 1;
> > +		return 1;
> > +	}
> >  	*nextevt = KTIME_MAX;
> >  	return !rcu_segcblist_empty(&this_cpu_ptr(&rcu_data)->cblist) &&
> >  	       !rcu_segcblist_is_offloaded(&this_cpu_ptr(&rcu_data)->cblist);
> > @@ -1350,6 +1355,12 @@ int rcu_needs_cpu(u64 basemono, u64 *nextevt)
> >  
> >  	lockdep_assert_irqs_disabled();
> >  
> > +	/* Through early_initcall(), need tick for softirq handlers. */
> > +	if (!IS_ENABLED(CONFIG_HZ_PERIODIC) && !this_cpu_ksoftirqd()) {
> > +		*nextevt = 1;
> > +		return 1;
> > +	}
> > +
> >  	/* If no non-offloaded callbacks, RCU doesn't need the CPU. */
> >  	if (rcu_segcblist_empty(&rdp->cblist) ||
> >  	    rcu_segcblist_is_offloaded(&this_cpu_ptr(&rcu_data)->cblist)) {
> 
> 
> I suspect rcutiny should be concerned as well?
> 
> In fact this patch doesn't look necessary because can_stop_idle_tick() refuse
> to stop the tick when softirqs are pending.

So it does, thank you!  I will drop this patch.

							Thanx, Paul

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

* Re: [PATCH tip/core/rcu 06/10] softirq: Don't try waking ksoftirqd before it has been spawned
  2021-03-04  0:00 ` [PATCH tip/core/rcu 06/10] softirq: Don't try waking ksoftirqd before it has been spawned paulmck
@ 2021-03-12 11:36   ` Frederic Weisbecker
  2021-03-15 23:11     ` Paul E. McKenney
  0 siblings, 1 reply; 15+ messages in thread
From: Frederic Weisbecker @ 2021-03-12 11:36 UTC (permalink / raw)
  To: paulmck
  Cc: rcu, linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel

On Wed, Mar 03, 2021 at 04:00:15PM -0800, paulmck@kernel.org wrote:
> From: "Paul E. McKenney" <paulmck@kernel.org>
> 
> If there is heavy softirq activity, the softirq system will attempt
> to awaken ksoftirqd and will stop the traditional back-of-interrupt
> softirq processing.  This is all well and good, but only if the
> ksoftirqd kthreads already exist, which is not the case during early
> boot, in which case the system hangs.
> 
> One reproducer is as follows:
> 
> tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 2 --configs "TREE03" --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y CONFIG_NO_HZ_IDLE=y CONFIG_HZ_PERIODIC=n" --bootargs "threadirqs=1" --trust-make
> 
> This commit therefore adds a couple of existence checks for ksoftirqd
> and forces back-of-interrupt softirq processing when ksoftirqd does not
> yet exist.  With this change, the above test passes.
> 
> Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Reported-by: Uladzislau Rezki <urezki@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> [ paulmck: Remove unneeded check per Sebastian Siewior feedback. ]
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>

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

* Re: [PATCH tip/core/rcu 06/10] softirq: Don't try waking ksoftirqd before it has been spawned
  2021-03-12 11:36   ` Frederic Weisbecker
@ 2021-03-15 23:11     ` Paul E. McKenney
  0 siblings, 0 replies; 15+ messages in thread
From: Paul E. McKenney @ 2021-03-15 23:11 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: rcu, linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel

On Fri, Mar 12, 2021 at 12:36:41PM +0100, Frederic Weisbecker wrote:
> On Wed, Mar 03, 2021 at 04:00:15PM -0800, paulmck@kernel.org wrote:
> > From: "Paul E. McKenney" <paulmck@kernel.org>
> > 
> > If there is heavy softirq activity, the softirq system will attempt
> > to awaken ksoftirqd and will stop the traditional back-of-interrupt
> > softirq processing.  This is all well and good, but only if the
> > ksoftirqd kthreads already exist, which is not the case during early
> > boot, in which case the system hangs.
> > 
> > One reproducer is as follows:
> > 
> > tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 2 --configs "TREE03" --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y CONFIG_NO_HZ_IDLE=y CONFIG_HZ_PERIODIC=n" --bootargs "threadirqs=1" --trust-make
> > 
> > This commit therefore adds a couple of existence checks for ksoftirqd
> > and forces back-of-interrupt softirq processing when ksoftirqd does not
> > yet exist.  With this change, the above test passes.
> > 
> > Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > Reported-by: Uladzislau Rezki <urezki@gmail.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > [ paulmck: Remove unneeded check per Sebastian Siewior feedback. ]
> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> 
> Reviewed-by: Frederic Weisbecker <frederic@kernel.org>

Applied, thank you!

							Thanx, Paul

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

end of thread, other threads:[~2021-03-15 23:12 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 23:59 [PATCH tip/core/rcu 0/10] Miscellaneous fixes for v5.13 Paul E. McKenney
2021-03-04  0:00 ` [PATCH tip/core/rcu 01/10] rcu: Remove superfluous rdp fetch paulmck
2021-03-04  0:00 ` [PATCH tip/core/rcu 02/10] rcu: Fix CPU-offline trace in rcutree_dying_cpu paulmck
2021-03-04  0:00 ` [PATCH tip/core/rcu 03/10] rcu: Remove spurious instrumentation_end() in rcu_nmi_enter() paulmck
2021-03-04  0:00 ` [PATCH tip/core/rcu 04/10] rculist: Replace reference to atomic_ops.rst paulmck
2021-03-04  0:00 ` [PATCH tip/core/rcu 05/10] rcu: Fix kfree_rcu() docbook errors paulmck
2021-03-04  0:00 ` [PATCH tip/core/rcu 06/10] softirq: Don't try waking ksoftirqd before it has been spawned paulmck
2021-03-12 11:36   ` Frederic Weisbecker
2021-03-15 23:11     ` Paul E. McKenney
2021-03-04  0:00 ` [PATCH tip/core/rcu 07/10] rcu: Prevent dyntick-idle until ksoftirqd " paulmck
2021-03-11 23:23   ` Frederic Weisbecker
2021-03-11 23:34     ` Paul E. McKenney
2021-03-04  0:00 ` [PATCH tip/core/rcu 08/10] docs: Correctly spell Stephen Hemminger's name paulmck
2021-03-04  0:00 ` [PATCH tip/core/rcu 09/10] rcu: Add explicit barrier() to __rcu_read_unlock() paulmck
2021-03-04  0:00 ` [PATCH tip/core/rcu 10/10] rcu/tree: Add a trace event for RCU CPU stall warnings paulmck

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.