public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	Josh Triplett <josh@joshtriplett.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Neeraj Upadhyay <neeraj.upadhyay@amd.com>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Uladzislau Rezki <urezki@gmail.com>, rcu <rcu@vger.kernel.org>,
	Frederic Weisbecker <frederic@kernel.org>
Subject: [PATCH 12/23] rcutorture: Copy out ftrace into its own console file
Date: Tue, 10 Oct 2023 13:59:10 +0200	[thread overview]
Message-ID: <20231010115921.988766-13-frederic@kernel.org> (raw)
In-Reply-To: <20231010115921.988766-1-frederic@kernel.org>

From: "Joel Fernandes (Google)" <joel@joelfernandes.org>

When debugging, it can be difficult to quickly find the ftrace dump
within the console log, which in turn makes it difficult to process it
independent of the rest of the console output.  This commit therefore
copies the contents of the buffers into its own file to make it easier
to locate and process the ftrace dump. The original ftrace dump is still
available in the console log in cases because it can be more convenient
to process it in situ, for example, for scripts that process console
output as well as ftrace-dump data.

Also handle the case of multiple ftrace dumps potentially showing up in the
log. Example for a file like [1], it will extract as [2].

[1]:
foo
foo
Dumping ftrace buffer:
---------------------------------
blah
blah
---------------------------------
more
bar
baz
Dumping ftrace buffer:
---------------------------------
blah2
blah2
---------------------------------
bleh
bleh

[2]:

Ftrace dump 1:
blah
blah

Ftrace dump 2:
blah2
blah2

[ paulmck: Fixed awk indentation, input up front. ]

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 .../selftests/rcutorture/bin/functions.sh     | 29 +++++++++++++++++++
 .../selftests/rcutorture/bin/parse-console.sh |  7 +++++
 2 files changed, 36 insertions(+)
 mode change 100644 => 100755 tools/testing/selftests/rcutorture/bin/functions.sh

diff --git a/tools/testing/selftests/rcutorture/bin/functions.sh b/tools/testing/selftests/rcutorture/bin/functions.sh
old mode 100644
new mode 100755
index b8e2ea23cb3f..6e415ddb206f
--- a/tools/testing/selftests/rcutorture/bin/functions.sh
+++ b/tools/testing/selftests/rcutorture/bin/functions.sh
@@ -331,3 +331,32 @@ specify_qemu_net () {
 		echo $1 -net none
 	fi
 }
+
+# Extract the ftrace output from the console log output
+# The ftrace output in the original logs look like:
+# Dumping ftrace buffer:
+# ---------------------------------
+# [...]
+# ---------------------------------
+extract_ftrace_from_console() {
+	awk < "$1" '
+
+	/Dumping ftrace buffer:/ {
+		buffer_count++
+		print "Ftrace dump " buffer_count ":"
+		capture = 1
+		next
+	}
+
+	/---------------------------------/ {
+		if(capture == 1) {
+			capture = 2
+			next
+		} else if(capture == 2) {
+			capture = 0
+			print ""
+		}
+	}
+
+	capture == 2'
+}
diff --git a/tools/testing/selftests/rcutorture/bin/parse-console.sh b/tools/testing/selftests/rcutorture/bin/parse-console.sh
index 9ab0f6bc172c..e3d2f69ec0fb 100755
--- a/tools/testing/selftests/rcutorture/bin/parse-console.sh
+++ b/tools/testing/selftests/rcutorture/bin/parse-console.sh
@@ -182,3 +182,10 @@ if ! test -s $file.diags
 then
 	rm -f $file.diags
 fi
+
+# Call extract_ftrace_from_console function, if the output is empty,
+# don't create $file.ftrace. Otherwise output the results to $file.ftrace
+extract_ftrace_from_console $file > $file.ftrace
+if [ ! -s $file.ftrace ]; then
+	rm -f $file.ftrace
+fi
-- 
2.34.1


  parent reply	other threads:[~2023-10-10 12:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10 11:58 [PATCH 00/23] RCU/lock torture updates for v6.7 Frederic Weisbecker
2023-10-10 11:58 ` [PATCH 01/23] torture: Share torture_random_state with torture_shuffle_tasks() Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 02/23] torture: Make kvm-recheck.sh use mktemp Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 03/23] torture: Make torture_hrtimeout_ns() take an hrtimer mode parameter Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 04/23] rcu: Include torture_sched_setaffinity() declaration Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 05/23] torture: Move rcutorture_sched_setaffinity() out of rcutorture Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 06/23] locktorture: Add readers_bind and writers_bind module parameters Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 07/23] rcutorture: Add CONFIG_DEBUG_OBJECTS to RCU Tasks testing Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 08/23] rcutorture: Fix stuttering races and other issues Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 09/23] locktorture: Alphabetize torture_param() entries Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 10/23] locktorture: Consolidate "if" statements in lock_torture_writer() Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 11/23] locktorture: Add acq_writer_lim to complain about long acquistion times Frederic Weisbecker
2023-10-10 11:59 ` Frederic Weisbecker [this message]
2023-10-10 11:59 ` [PATCH 13/23] torture: Print out torture module parameters Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 14/23] torture: Make torture.sh refscale testing qualify verbose_batched Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 15/23] locktorture: Add new module parameters to lock_torture_print_module_parms() Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 16/23] locktorture: Add call_rcu_chains module parameter Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 17/23] doc: Catch-up update for locktorture module parameters Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 18/23] locktorture: Rename readers_bind/writers_bind to bind_readers/bind_writers Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 19/23] torture: Add kvm.sh --debug-info argument Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 20/23] rcutorture: Replace schedule_timeout*() 1-jiffy waits with HZ/20 Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 21/23] rcutorture: Traverse possible cpu to set maxcpu in rcu_nocb_toggle() Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 22/23] torture: Convert parse-console.sh to mktemp Frederic Weisbecker
2023-10-10 11:59 ` [PATCH 23/23] locktorture: Check the correct variable for allocation failure Frederic Weisbecker
2023-10-10 13:55   ` Paul E. McKenney
2023-10-10 14:07     ` Dan Carpenter
2023-10-10 15:53       ` Paul E. McKenney
2023-10-11  6:46         ` Dan Carpenter

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=20231010115921.988766-13-frederic@kernel.org \
    --to=frederic@kernel.org \
    --cc=boqun.feng@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=neeraj.upadhyay@amd.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox