* [PATCH rcu 0/4] RCU stall updates for v6.12
@ 2024-08-16 6:10 Neeraj Upadhyay
2024-08-16 6:13 ` [PATCH rcu 1/4] rcu: Summarize RCU CPU stall warnings during CSD-lock stalls neeraj.upadhyay
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Neeraj Upadhyay @ 2024-08-16 6:10 UTC (permalink / raw)
To: rcu
Cc: paulmck, joel, frederic, boqun.feng, urezki, linux-kernel,
kernel-team, rostedt, takakura
Hello,
This series contains following RCU stall updates for v6.12:
1. Abbreviate RCU CPU stall warnings during CSD-lock stalls, courtesy of
Paul E. McKenney.
2. Allow dump_cpu_task() to be called without disabling preemption,
courtesy of Ryo Takakura.
Git tree: https://git.kernel.org/pub/scm/linux/kernel/git/neeraj.upadhyay/linux-rcu.git/log/?h=rcustall.15.08.24a
(rebased on top of csd.lock.15.08.24a because of commit dependency on commit ac9d45544cd5 "locking/csd_lock:
Provide an indication of ongoing CSD-lock stall")
- Neeraj
Paul E. McKenney (3):
rcu: Summarize RCU CPU stall warnings during CSD-lock stalls
rcu: Extract synchronize_rcu_expedited_stall() from
synchronize_rcu_expedited_wait()
rcu: Summarize expedited RCU CPU stall warnings during CSD-lock stalls
Ryo Takakura (1):
rcu: Let dump_cpu_task() be used without preemption disabled
.../admin-guide/kernel-parameters.txt | 4 +
kernel/rcu/tree_exp.h | 113 ++++++++++--------
kernel/rcu/tree_stall.h | 8 +-
kernel/sched/core.c | 2 +-
4 files changed, 74 insertions(+), 53 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH rcu 1/4] rcu: Summarize RCU CPU stall warnings during CSD-lock stalls
2024-08-16 6:10 [PATCH rcu 0/4] RCU stall updates for v6.12 Neeraj Upadhyay
@ 2024-08-16 6:13 ` neeraj.upadhyay
2024-08-16 6:13 ` [PATCH rcu 2/4] rcu: Extract synchronize_rcu_expedited_stall() from synchronize_rcu_expedited_wait() neeraj.upadhyay
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: neeraj.upadhyay @ 2024-08-16 6:13 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, kernel-team, rostedt, paulmck, neeraj.upadhyay,
neeraj.upadhyay, boqun.feng, joel, urezki, frederic
From: "Paul E. McKenney" <paulmck@kernel.org>
During CSD-lock stalls, the additional information output by RCU CPU
stall warnings is usually redundant, flooding the console for not good
reason. However, this has been the way things work for a few years.
This commit therefore adds an rcutree.csd_lock_suppress_rcu_stall kernel
boot parameter that causes RCU CPU stall warnings to be abbreviated to
a single line when there is at least one CPU that has been stuck waiting
for CSD lock for more than five seconds.
To make this abbreviated message happen with decent probability:
tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 8 \
--configs "2*TREE01" --kconfig "CONFIG_CSD_LOCK_WAIT_DEBUG=y" \
--bootargs "csdlock_debug=1 rcutorture.stall_cpu=200 \
rcutorture.stall_cpu_holdoff=120 rcutorture.stall_cpu_irqsoff=1 \
rcutree.csd_lock_suppress_rcu_stall=1 \
rcupdate.rcu_exp_cpu_stall_timeout=5000" --trust-make
[ paulmck: Apply kernel test robot feedback. ]
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
---
Documentation/admin-guide/kernel-parameters.txt | 4 ++++
kernel/rcu/tree_stall.h | 8 +++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index f1384c7b59c9..d56356c13184 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4937,6 +4937,10 @@
Set maximum number of finished RCU callbacks to
process in one batch.
+ rcutree.csd_lock_suppress_rcu_stall= [KNL]
+ Do only a one-line RCU CPU stall warning when
+ there is an ongoing too-long CSD-lock wait.
+
rcutree.do_rcu_barrier= [KNL]
Request a call to rcu_barrier(). This is
throttled so that userspace tests can safely
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index 4b0e9d7c4c68..b497d4c6dabd 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -9,6 +9,7 @@
#include <linux/kvm_para.h>
#include <linux/rcu_notifier.h>
+#include <linux/smp.h>
//////////////////////////////////////////////////////////////////////////////
//
@@ -719,6 +720,9 @@ static void print_cpu_stall(unsigned long gps)
set_preempt_need_resched();
}
+static bool csd_lock_suppress_rcu_stall;
+module_param(csd_lock_suppress_rcu_stall, bool, 0644);
+
static void check_cpu_stall(struct rcu_data *rdp)
{
bool self_detected;
@@ -791,7 +795,9 @@ static void check_cpu_stall(struct rcu_data *rdp)
return;
rcu_stall_notifier_call_chain(RCU_STALL_NOTIFY_NORM, (void *)j - gps);
- if (self_detected) {
+ if (READ_ONCE(csd_lock_suppress_rcu_stall) && csd_lock_is_stuck()) {
+ pr_err("INFO: %s detected stall, but suppressed full report due to a stuck CSD-lock.\n", rcu_state.name);
+ } else if (self_detected) {
/* We haven't checked in, so go dump stack. */
print_cpu_stall(gps);
} else {
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH rcu 2/4] rcu: Extract synchronize_rcu_expedited_stall() from synchronize_rcu_expedited_wait()
2024-08-16 6:10 [PATCH rcu 0/4] RCU stall updates for v6.12 Neeraj Upadhyay
2024-08-16 6:13 ` [PATCH rcu 1/4] rcu: Summarize RCU CPU stall warnings during CSD-lock stalls neeraj.upadhyay
@ 2024-08-16 6:13 ` neeraj.upadhyay
2024-08-16 6:13 ` [PATCH rcu 3/4] rcu: Summarize expedited RCU CPU stall warnings during CSD-lock stalls neeraj.upadhyay
2024-08-16 6:13 ` [PATCH rcu 4/4] rcu: Let dump_cpu_task() be used without preemption disabled neeraj.upadhyay
3 siblings, 0 replies; 5+ messages in thread
From: neeraj.upadhyay @ 2024-08-16 6:13 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, kernel-team, rostedt, paulmck, neeraj.upadhyay,
neeraj.upadhyay, boqun.feng, joel, urezki, frederic
From: "Paul E. McKenney" <paulmck@kernel.org>
This commit extracts the RCU CPU stall-warning report code from
synchronize_rcu_expedited_wait() and places it in a new function named
synchronize_rcu_expedited_stall(). This is strictly a code-movement
commit. A later commit will use this reorganization to avoid printing
expedited RCU CPU stall warnings while there are ongoing CSD-lock stall
reports.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
---
kernel/rcu/tree_exp.h | 111 +++++++++++++++++++++++-------------------
1 file changed, 60 insertions(+), 51 deletions(-)
diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index 4acd29d16fdb..17dd5169012d 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -542,6 +542,65 @@ static bool synchronize_rcu_expedited_wait_once(long tlimit)
return false;
}
+/*
+ * Print out an expedited RCU CPU stall warning message.
+ */
+static void synchronize_rcu_expedited_stall(unsigned long jiffies_start, unsigned long j)
+{
+ int cpu;
+ unsigned long mask;
+ int ndetected;
+ struct rcu_node *rnp;
+ struct rcu_node *rnp_root = rcu_get_root();
+
+ pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {", rcu_state.name);
+ ndetected = 0;
+ rcu_for_each_leaf_node(rnp) {
+ ndetected += rcu_print_task_exp_stall(rnp);
+ for_each_leaf_node_possible_cpu(rnp, cpu) {
+ struct rcu_data *rdp;
+
+ mask = leaf_node_cpu_bit(rnp, cpu);
+ if (!(READ_ONCE(rnp->expmask) & mask))
+ continue;
+ ndetected++;
+ rdp = per_cpu_ptr(&rcu_data, cpu);
+ pr_cont(" %d-%c%c%c%c", cpu,
+ "O."[!!cpu_online(cpu)],
+ "o."[!!(rdp->grpmask & rnp->expmaskinit)],
+ "N."[!!(rdp->grpmask & rnp->expmaskinitnext)],
+ "D."[!!data_race(rdp->cpu_no_qs.b.exp)]);
+ }
+ }
+ 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) {
+ pr_err("blocking rcu_node structures (internal RCU debug):");
+ rcu_for_each_node_breadth_first(rnp) {
+ if (rnp == rnp_root)
+ continue; /* printed unconditionally */
+ if (sync_rcu_exp_done_unlocked(rnp))
+ continue;
+ pr_cont(" l=%u:%d-%d:%#lx/%c",
+ rnp->level, rnp->grplo, rnp->grphi, data_race(rnp->expmask),
+ ".T"[!!data_race(rnp->exp_tasks)]);
+ }
+ pr_cont("\n");
+ }
+ rcu_for_each_leaf_node(rnp) {
+ for_each_leaf_node_possible_cpu(rnp, cpu) {
+ mask = leaf_node_cpu_bit(rnp, cpu);
+ if (!(READ_ONCE(rnp->expmask) & mask))
+ continue;
+ preempt_disable(); // For smp_processor_id() in dump_cpu_task().
+ dump_cpu_task(cpu);
+ preempt_enable();
+ }
+ rcu_exp_print_detail_task_stall_rnp(rnp);
+ }
+}
+
/*
* Wait for the expedited grace period to elapse, issuing any needed
* RCU CPU stall warnings along the way.
@@ -553,10 +612,8 @@ static void synchronize_rcu_expedited_wait(void)
unsigned long jiffies_stall;
unsigned long jiffies_start;
unsigned long mask;
- int ndetected;
struct rcu_data *rdp;
struct rcu_node *rnp;
- struct rcu_node *rnp_root = rcu_get_root();
unsigned long flags;
trace_rcu_exp_grace_period(rcu_state.name, rcu_exp_gp_seq_endval(), TPS("startwait"));
@@ -593,55 +650,7 @@ static void synchronize_rcu_expedited_wait(void)
j = jiffies;
rcu_stall_notifier_call_chain(RCU_STALL_NOTIFY_EXP, (void *)(j - jiffies_start));
trace_rcu_stall_warning(rcu_state.name, TPS("ExpeditedStall"));
- pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {",
- rcu_state.name);
- ndetected = 0;
- rcu_for_each_leaf_node(rnp) {
- ndetected += rcu_print_task_exp_stall(rnp);
- for_each_leaf_node_possible_cpu(rnp, cpu) {
- struct rcu_data *rdp;
-
- mask = leaf_node_cpu_bit(rnp, cpu);
- if (!(READ_ONCE(rnp->expmask) & mask))
- continue;
- ndetected++;
- rdp = per_cpu_ptr(&rcu_data, cpu);
- pr_cont(" %d-%c%c%c%c", cpu,
- "O."[!!cpu_online(cpu)],
- "o."[!!(rdp->grpmask & rnp->expmaskinit)],
- "N."[!!(rdp->grpmask & rnp->expmaskinitnext)],
- "D."[!!data_race(rdp->cpu_no_qs.b.exp)]);
- }
- }
- 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) {
- pr_err("blocking rcu_node structures (internal RCU debug):");
- rcu_for_each_node_breadth_first(rnp) {
- if (rnp == rnp_root)
- continue; /* printed unconditionally */
- if (sync_rcu_exp_done_unlocked(rnp))
- continue;
- pr_cont(" l=%u:%d-%d:%#lx/%c",
- rnp->level, rnp->grplo, rnp->grphi,
- data_race(rnp->expmask),
- ".T"[!!data_race(rnp->exp_tasks)]);
- }
- pr_cont("\n");
- }
- rcu_for_each_leaf_node(rnp) {
- for_each_leaf_node_possible_cpu(rnp, cpu) {
- mask = leaf_node_cpu_bit(rnp, cpu);
- if (!(READ_ONCE(rnp->expmask) & mask))
- continue;
- preempt_disable(); // For smp_processor_id() in dump_cpu_task().
- dump_cpu_task(cpu);
- preempt_enable();
- }
- rcu_exp_print_detail_task_stall_rnp(rnp);
- }
+ synchronize_rcu_expedited_stall(jiffies_start, j);
jiffies_stall = 3 * rcu_exp_jiffies_till_stall_check() + 3;
panic_on_rcu_stall();
}
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH rcu 3/4] rcu: Summarize expedited RCU CPU stall warnings during CSD-lock stalls
2024-08-16 6:10 [PATCH rcu 0/4] RCU stall updates for v6.12 Neeraj Upadhyay
2024-08-16 6:13 ` [PATCH rcu 1/4] rcu: Summarize RCU CPU stall warnings during CSD-lock stalls neeraj.upadhyay
2024-08-16 6:13 ` [PATCH rcu 2/4] rcu: Extract synchronize_rcu_expedited_stall() from synchronize_rcu_expedited_wait() neeraj.upadhyay
@ 2024-08-16 6:13 ` neeraj.upadhyay
2024-08-16 6:13 ` [PATCH rcu 4/4] rcu: Let dump_cpu_task() be used without preemption disabled neeraj.upadhyay
3 siblings, 0 replies; 5+ messages in thread
From: neeraj.upadhyay @ 2024-08-16 6:13 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, kernel-team, rostedt, paulmck, neeraj.upadhyay,
neeraj.upadhyay, boqun.feng, joel, urezki, frederic
From: "Paul E. McKenney" <paulmck@kernel.org>
During CSD-lock stalls, the additional information output by expedited
RCU CPU stall warnings is usually redundant, flooding the console for
not good reason. However, this has been the way things work for a few
years. This commit therefore uses rcutree.csd_lock_suppress_rcu_stall
kernel boot parameter that causes expedited RCU CPU stall warnings to
be abbreviated to a single line when there is at least one CPU that has
been stuck waiting for CSD lock for more than five seconds.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
---
kernel/rcu/tree_exp.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index 17dd5169012d..d4be644afb50 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -553,6 +553,10 @@ static void synchronize_rcu_expedited_stall(unsigned long jiffies_start, unsigne
struct rcu_node *rnp;
struct rcu_node *rnp_root = rcu_get_root();
+ if (READ_ONCE(csd_lock_suppress_rcu_stall) && csd_lock_is_stuck()) {
+ pr_err("INFO: %s detected expedited stalls, but suppressed full report due to a stuck CSD-lock.\n", rcu_state.name);
+ return;
+ }
pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {", rcu_state.name);
ndetected = 0;
rcu_for_each_leaf_node(rnp) {
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH rcu 4/4] rcu: Let dump_cpu_task() be used without preemption disabled
2024-08-16 6:10 [PATCH rcu 0/4] RCU stall updates for v6.12 Neeraj Upadhyay
` (2 preceding siblings ...)
2024-08-16 6:13 ` [PATCH rcu 3/4] rcu: Summarize expedited RCU CPU stall warnings during CSD-lock stalls neeraj.upadhyay
@ 2024-08-16 6:13 ` neeraj.upadhyay
3 siblings, 0 replies; 5+ messages in thread
From: neeraj.upadhyay @ 2024-08-16 6:13 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, kernel-team, rostedt, paulmck, neeraj.upadhyay,
neeraj.upadhyay, boqun.feng, joel, urezki, frederic, Ryo Takakura
From: Ryo Takakura <takakura@valinux.co.jp>
The commit 2d7f00b2f0130 ("rcu: Suppress smp_processor_id() complaint
in synchronize_rcu_expedited_wait()") disabled preemption around
dump_cpu_task() to suppress warning on its usage within preemtible context.
Calling dump_cpu_task() doesn't required to be in non-preemptible context
except for suppressing the smp_processor_id() warning.
As the smp_processor_id() is evaluated along with in_hardirq()
to check if it's in interrupt context, this patch removes the need
for its preemtion disablement by reordering the condition so that
smp_processor_id() only gets evaluated when it's in interrupt context.
Signed-off-by: Ryo Takakura <takakura@valinux.co.jp>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
---
kernel/rcu/tree_exp.h | 2 --
kernel/sched/core.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index d4be644afb50..c5d9a7eb0803 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -597,9 +597,7 @@ static void synchronize_rcu_expedited_stall(unsigned long jiffies_start, unsigne
mask = leaf_node_cpu_bit(rnp, cpu);
if (!(READ_ONCE(rnp->expmask) & mask))
continue;
- preempt_disable(); // For smp_processor_id() in dump_cpu_task().
dump_cpu_task(cpu);
- preempt_enable();
}
rcu_exp_print_detail_task_stall_rnp(rnp);
}
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a9f655025607..78ae888a1fa2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9726,7 +9726,7 @@ struct cgroup_subsys cpu_cgrp_subsys = {
void dump_cpu_task(int cpu)
{
- if (cpu == smp_processor_id() && in_hardirq()) {
+ if (in_hardirq() && cpu == smp_processor_id()) {
struct pt_regs *regs;
regs = get_irq_regs();
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-16 6:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-16 6:10 [PATCH rcu 0/4] RCU stall updates for v6.12 Neeraj Upadhyay
2024-08-16 6:13 ` [PATCH rcu 1/4] rcu: Summarize RCU CPU stall warnings during CSD-lock stalls neeraj.upadhyay
2024-08-16 6:13 ` [PATCH rcu 2/4] rcu: Extract synchronize_rcu_expedited_stall() from synchronize_rcu_expedited_wait() neeraj.upadhyay
2024-08-16 6:13 ` [PATCH rcu 3/4] rcu: Summarize expedited RCU CPU stall warnings during CSD-lock stalls neeraj.upadhyay
2024-08-16 6:13 ` [PATCH rcu 4/4] rcu: Let dump_cpu_task() be used without preemption disabled neeraj.upadhyay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox