From: Benjamin Peterson <benjamin@engflow.com>
Cc: Benjamin Peterson <benjamin@engflow.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
linux-kernel@vger.kernel.org (open list),
linux-perf-users@vger.kernel.org (open list:PERFORMANCE EVENTS
SUBSYSTEM)
Subject: [PATCH v2 3/3] perf tests: add test for trace output loss
Date: Thu, 7 Nov 2024 23:21:28 +0000 [thread overview]
Message-ID: <20241107232128.108981-3-benjamin@engflow.com> (raw)
In-Reply-To: <20241107232128.108981-1-benjamin@engflow.com>
Add a test that checks that trace output is not lost to races. This is
accomplished by tracing the exit_group syscall of "true" multiple times and
checking for correct output.
Signed-off-by: Benjamin Peterson <benjamin@engflow.com>
---
tools/perf/tests/shell/trace_exit_race.sh | 31 +++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100755 tools/perf/tests/shell/trace_exit_race.sh
diff --git a/tools/perf/tests/shell/trace_exit_race.sh b/tools/perf/tests/shell/trace_exit_race.sh
new file mode 100755
index 000000000000..f9cfe44bce86
--- /dev/null
+++ b/tools/perf/tests/shell/trace_exit_race.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# perf trace exit race
+# SPDX-License-Identifier: GPL-2.0
+
+# Check that the last events of a perf trace'd subprocess are not
+# lost. Specifically, trace the exiting syscall of "true" 10 times and ensure
+# the output contains 10 correct lines.
+
+# shellcheck source=lib/probe.sh
+. "$(dirname $0)"/lib/probe.sh
+
+skip_if_no_perf_trace || exit 2
+
+trace_shutdown_race() {
+ for i in $(seq 10); do
+ perf trace -e syscalls:sys_enter_exit_group true 2>>$file
+ done
+ [ $(grep -c -E " +[0-9]+\.[0-9]+ +true/[0-9]+ syscalls:sys_enter_exit_group\(\)$" $file) = "10" ]
+}
+
+
+file=$(mktemp /tmp/temporary_file.XXXXX)
+
+# Do not use whatever ~/.perfconfig file, it may change the output
+# via trace.{show_timestamp,show_prefix,etc}
+export PERF_CONFIG=/dev/null
+
+trace_shutdown_race
+err=$?
+rm -f ${file}
+exit $err
--
2.39.5
prev parent reply other threads:[~2024-11-07 23:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 23:21 [PATCH v2 1/3] perf trace: do not lose last events in a race Benjamin Peterson
2024-11-07 23:21 ` [PATCH v2 2/3] perf trace: avoid garbage when not printing a syscall's arguments Benjamin Peterson
2024-11-08 16:21 ` Howard Chu
2024-11-14 21:08 ` Arnaldo Carvalho de Melo
2024-11-07 23:21 ` Benjamin Peterson [this message]
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=20241107232128.108981-3-benjamin@engflow.com \
--to=benjamin@engflow.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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 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.