RCU Archive mirror
 help / color / mirror / Atom feed
From: Zqiang <qiang.zhang1211@gmail.com>
To: paulmck@kernel.org, frederic@kernel.org,
	neeraj.upadhyay@kernel.org, joel@joelfernandes.org
Cc: qiang.zhang1211@gmail.com, rcu@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] rcutorture: Make rcutorture support print rcu-tasks gp state
Date: Tue, 12 Mar 2024 15:23:57 +0800	[thread overview]
Message-ID: <20240312072357.23517-1-qiang.zhang1211@gmail.com> (raw)

This commit make rcu-tasks related rcutorture test support rcu-tasks
gp state printing when the writer stall occurs or the at the end of
rcutorture test.

The test is as follows:
[ 3872.548702] tasks-tracing:  Start-test grace-period state: g4560 f0x0
[ 4332.661283] tasks-tracing:  End-test grace-period state: g41540 f0x0 total-gps=36980

[ 4401.381138] tasks:  Start-test grace-period state: g8 f0x0
[ 4565.619354] tasks:  End-test grace-period state: g1732 f0x0 total-gps=1724

[ 4589.006917] tasks-rude:  Start-test grace-period state: g8 f0x0
[ 5059.379321] tasks-rude:  End-test grace-period state: g8508 f0x0 total-gps=8500

Signed-off-by: Zqiang <qiang.zhang1211@gmail.com>
---
 kernel/rcu/rcu.h        |  8 ++++++++
 kernel/rcu/rcutorture.c |  3 +++
 kernel/rcu/tasks.h      | 25 +++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index 86fce206560e..3353e3697645 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -556,6 +556,14 @@ static inline unsigned long rcu_get_jiffies_lazy_flush(void) { return 0; }
 static inline void rcu_set_jiffies_lazy_flush(unsigned long j) { }
 #endif
 
+#ifdef CONFIG_TASKS_RCU_GENERIC
+void rcutaskstorture_get_gp_data(enum rcutorture_type test_type, int *flags,
+				unsigned long *gp_seq);
+#else
+static inline void rcutaskstorture_get_gp_data(enum rcutorture_type test_type, int *flags,
+				unsigned long *gp_seq) { }
+#endif
+
 #if defined(CONFIG_TREE_RCU)
 void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
 			    unsigned long *gp_seq);
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index dd7d5ba45740..91c03f37fd97 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -2267,6 +2267,7 @@ rcu_torture_stats_print(void)
 				       &flags, &gp_seq);
 		srcutorture_get_gp_data(cur_ops->ttype, srcu_ctlp,
 					&flags, &gp_seq);
+		rcutaskstorture_get_gp_data(cur_ops->ttype, &flags, &gp_seq);
 		wtp = READ_ONCE(writer_task);
 		pr_alert("??? Writer stall state %s(%d) g%lu f%#x ->state %#x cpu %d\n",
 			 rcu_torture_writer_state_getname(),
@@ -3391,6 +3392,7 @@ rcu_torture_cleanup(void)
 
 	rcutorture_get_gp_data(cur_ops->ttype, &flags, &gp_seq);
 	srcutorture_get_gp_data(cur_ops->ttype, srcu_ctlp, &flags, &gp_seq);
+	rcutaskstorture_get_gp_data(cur_ops->ttype, &flags, &gp_seq);
 	pr_alert("%s:  End-test grace-period state: g%ld f%#x total-gps=%ld\n",
 		 cur_ops->name, (long)gp_seq, flags,
 		 rcutorture_seq_diff(gp_seq, start_gp_seq));
@@ -3763,6 +3765,7 @@ rcu_torture_init(void)
 	rcu_torture_print_module_parms(cur_ops, "Start of test");
 	rcutorture_get_gp_data(cur_ops->ttype, &flags, &gp_seq);
 	srcutorture_get_gp_data(cur_ops->ttype, srcu_ctlp, &flags, &gp_seq);
+	rcutaskstorture_get_gp_data(cur_ops->ttype, &flags, &gp_seq);
 	start_gp_seq = gp_seq;
 	pr_alert("%s:  Start-test grace-period state: g%ld f%#x\n",
 		 cur_ops->name, (long)gp_seq, flags);
diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index e83adcdb49b5..b1254cf3c210 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -2149,6 +2149,31 @@ late_initcall(rcu_tasks_verify_schedule_work);
 static void rcu_tasks_initiate_self_tests(void) { }
 #endif /* #else #ifdef CONFIG_PROVE_RCU */
 
+void rcutaskstorture_get_gp_data(enum rcutorture_type test_type, int *flags,
+				unsigned long *gp_seq)
+{
+	switch (test_type) {
+	case RCU_TASKS_FLAVOR:
+#ifdef CONFIG_TASKS_RCU
+		*gp_seq = rcu_seq_current(&rcu_tasks.tasks_gp_seq);
+#endif
+		break;
+	case RCU_TASKS_RUDE_FLAVOR:
+#ifdef CONFIG_TASKS_RUDE_RCU
+		*gp_seq = rcu_seq_current(&rcu_tasks_rude.tasks_gp_seq);
+#endif
+		break;
+	case RCU_TASKS_TRACING_FLAVOR:
+#ifdef CONFIG_TASKS_TRACE_RCU
+		*gp_seq = rcu_seq_current(&rcu_tasks_trace.tasks_gp_seq);
+#endif
+		break;
+	default:
+		break;
+	}
+}
+EXPORT_SYMBOL_GPL(rcutaskstorture_get_gp_data);
+
 void __init tasks_cblist_init_generic(void)
 {
 	lockdep_assert_irqs_disabled();
-- 
2.17.1


             reply	other threads:[~2024-03-12  7:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12  7:23 Zqiang [this message]
2024-03-17  5:11 ` [PATCH] rcutorture: Make rcutorture support print rcu-tasks gp state Paul E. McKenney
2024-03-17  7:16   ` Z qiang
2024-03-17  7:31     ` 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=20240312072357.23517-1-qiang.zhang1211@gmail.com \
    --to=qiang.zhang1211@gmail.com \
    --cc=frederic@kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).