All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sangmoon Kim <sangmoon.kim@samsung.com>
To: urezki@gmail.com
Cc: jiangshanlai@gmail.com, joel@joelfernandes.org,
	josh@joshtriplett.org, mathieu.desnoyers@efficios.com,
	neeraju@codeaurora.org, paulmck@kernel.org, rcu@vger.kernel.org,
	rostedt@goodmis.org, sangmoon.kim@samsung.com
Subject: [PATCH v3] rcu/tree: Add a trace event for RCU stall warnings
Date: Tue,  2 Mar 2021 20:55:15 +0900	[thread overview]
Message-ID: <20210302115515.14239-1-sangmoon.kim@samsung.com> (raw)
In-Reply-To: <20210228194700.GA55724@pc638.lan>

The event allows us to trace the RCU stall when
sysctl_panic_on_rcu_stall is disabled.

The first parameter is the name of RCU flavour like other trace
events. The second one shows us which function detected stalls.

The RCU stall is mainly caused by external factors such as interrupt
handling or task scheduling or something else. Therefore, this event
uses TRACE_EVENT macro, not dedicated one, so that someone interested
in the RCU stall can use it without CONFIG_RCU_TRACE.

Signed-off-by: Sangmoon Kim <sangmoon.kim@samsung.com>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
Thank you for reviewing this.

Changes in v2:
 - Move the tracepoints before printing out stall messages.

Changes in v3:
 - Rebase on dev in linux-rcu.git

 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 5fc29400e1a2..c7711e9b6900 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 6c6ff06d4ae6..2796084ef85a 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 475b26171b20..59b95cc5cbdf 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.17.1


  parent reply	other threads:[~2021-03-03  4:54 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210215090241epcas1p17b1319d38de5a09a9d65a06ebf936866@epcas1p1.samsung.com>
2021-02-15  8:53 ` [PATCH] rcu/tree: Add a trace event for RCU stall warnings Sangmoon Kim
2021-02-16 17:50   ` Paul E. McKenney
     [not found]     ` <CGME20210217135813epcas1p2b3bd79ca06ac847472b048b889100978@epcas1p2.samsung.com>
2021-02-17 13:49       ` Sangmoon Kim
2021-02-17 18:17         ` Neeraj Upadhyay
     [not found]           ` <CGME20210218130056epcas1p21e5b2e873f8c3cb0aa6953473d4c416c@epcas1p2.samsung.com>
2021-02-18 12:52             ` Sangmoon Kim
2021-02-18 14:17               ` Mathieu Desnoyers
2021-02-18 15:06                 ` Paul E. McKenney
2021-02-18 15:50                   ` Mathieu Desnoyers
2021-02-18 16:58                     ` Uladzislau Rezki
2021-02-18 17:24                       ` Mathieu Desnoyers
2021-02-18 18:43                         ` Uladzislau Rezki
2021-02-18 17:00                     ` Paul E. McKenney
2021-02-18 17:56                       ` Mathieu Desnoyers
2021-02-18 18:13                         ` Paul E. McKenney
2021-02-18 18:24                       ` Steven Rostedt
2021-02-18 18:59                         ` Paul E. McKenney
     [not found]                           ` <CGME20210222083416epcas1p2c4d51fc7a793729c08e424f13077954a@epcas1p2.samsung.com>
2021-02-22  8:25                             ` Sangmoon Kim
2021-02-24  9:18                               ` Neeraj Upadhyay
     [not found]                                 ` <CGME20210224152605epcas1p2170c2d6c0567c47e72559faa3148ddee@epcas1p2.samsung.com>
2021-02-24 15:17                                   ` Sangmoon Kim
     [not found]                                     ` <CGME20210225041622epcas1p159a1f427882a90a4ca815b31114c52b6@epcas1p1.samsung.com>
2021-02-25  4:06                                       ` [PATCH v2] " Sangmoon Kim
2021-02-28 19:47                                         ` Uladzislau Rezki
     [not found]                                           ` <CGME20210302120418epcas1p17e7f55d9c380ae864d2a6afab5fd3b1b@epcas1p1.samsung.com>
2021-03-02 11:55                                             ` Sangmoon Kim [this message]
2021-03-02 17:04                                               ` [PATCH v3] " Neeraj Upadhyay
2021-03-02 19:20                                                 ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210302115515.14239-1-sangmoon.kim@samsung.com \
    --to=sangmoon.kim@samsung.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=neeraju@codeaurora.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.