From: sashiko-bot@kernel.org
To: "Vincent Donnefort" <vdonnefort@google.com>,
linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v10 09/19] tracing/remotes: selftests: Add a test for the dmesg tracefs file
Date: Thu, 03 Dec 2026 19:39:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-248527@kernel.org> (raw)
In-Reply-To: <20261203190007.2431041-10-vdonnefort@google.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] tracing/remotes: selftests: brittle last_ts extraction in
test_dmesg()
- [Low] tracing/remotes: selftests: missing EXIT trap in test_dmesg()
- [Low] tracing/remotes: dmesg.tc requires prevents setup_remote_test()
modprobe
--
commit bc9cb076ab5e60b7619de93702cc7920401a88b8
Author: Vincent Donnefort <vdonnefort@google.com>
tracing/remotes: selftests: Add a test for the dmesg tracefs file
This commit adds ftrace selftests for the trace remote dmesg redirection
tracefs file on both the test and hypervisor remotes, and resets the dmesg
file in setup_remote().
> diff --git a/tools/testing/selftests/ftrace/test.d/remotes/dmesg.tc b/tools/testing/selftests/ftrace/test.d/remotes/dmesg.tc
> new file mode 100644
> index 0000000000000..f667b14556b6a
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/remotes/dmesg.tc
> @@ -0,0 +1,91 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: Test trace remote dmesg redirection
> +# requires: remotes/test remotes/test/dmesg
[Severity: Low]
Does this requires line prevent setup_remote_test() from loading
remote_test.ko on demand?
ftracetest runs check_requires() before sourcing the test script, so when
CONFIG_TRACE_REMOTE_TEST=m and remote_test.ko is not already loaded,
check_requires() exits via exit_unsupported before setup_remote_test() can
run modprobe remote_test.
Removing the module-created paths from requires, having setup_remote_test()
exit via exit_unsupported when remote_test is unavailable, and checking for
dmesg after loading the module would allow the test to run with a modular
build.
[ ... ]
> + #
> + # Test dmesg on/off when tracing is disabled
> + #
> + echo 1 > dmesg
> + test $(cat dmesg) -eq 1
> + assert_loaded
> +
> + echo 0 > dmesg
> + test $(cat dmesg) -eq 0
> + assert_unloaded
[Severity: Low]
Can an early failure in test_dmesg() leave dmesg redirection enabled?
Because test_dmesg() runs under set -e and finish_system() does not reset
remotes/*/dmesg, any failing check while dmesg is 1 skips echo 0 > dmesg.
That leaves the remote buffer pinned loaded and remote->poll_work
rescheduling indefinitely.
Adding an exit trap to write 0 to dmesg (as in remotes/hotplug.tc) would
ensure cleanup on failure paths.
[ ... ]
> + # Timestamp format is '[ XXXX.YYYY]'
> + last_ts=$(dmesg | tail -1 | sed -n 's/^\[ *\([0-9]*.[0-9]*\)\].*/\1/p')
> + if [ -z "$last_ts" ]; then
> + last_ts=0
> + fi
> +
> + # Emit events from the same CPU
> + for cpu in $(get_cpu_ids); do
> + break
> + done
> +
> + nr_events=128
> + for i in $(seq 1 $nr_events); do
> + taskset -c $cpu echo $i > write_event
> + done
> +
> + sleep 1
> + output=$(mktemp $TMPDIR/remote_test.XXXXXX)
> + dmesg | awk -v ts=$last_ts '
> + /^\[ *[0-9]+\.[0-9]+\]/ {
> + t=$0; sub(/^[[ \t]*/, "", t); sub(/].*/, "", t);
> + if (t+0 > ts+0) print $0
> + }' | grep "selftest id=" | sed 's/^.*\(\[[0-9]*\]\s*[0-9]*\.[0-9]*: \)/\1/' > $output
[Severity: Low]
Is this last_ts extraction reliable if the last dmesg line has no timestamp?
Because tail -1 runs before sed, a trailing continuation line without a
bracketed timestamp leaves last_ts empty and falls back to 0. awk then
includes older selftest id= lines from prior runs, causing check_trace to
fail on duplicate sequences.
The sed pattern also uses an unescaped dot and * quantifiers, so bracketed
text with spaces or non-digits can match and break the unquoted -v
ts=$last_ts in awk or evaluate ts+0 to 0. Running a strict sed regex before
tail -1 and quoting "$last_ts" avoids both issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203190007.2431041-1-vdonnefort@google.com?part=9
next prev parent reply other threads:[~2026-12-03 19:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 18:59 [PATCH v10 00/19] tracing/remotes: Add printk, dump_on_panic and boot parameters Vincent Donnefort
2026-12-03 18:59 ` [PATCH v10 01/19] tracing/remotes: Gate tracefs files opening on trace remote registration Vincent Donnefort
2026-12-03 19:20 ` sashiko-bot
2026-12-03 18:59 ` [PATCH v10 02/19] tracing/remotes: Release tracefs,eventfs on registration failure Vincent Donnefort
2026-12-03 19:24 ` sashiko-bot
2026-12-03 18:59 ` [PATCH v10 03/19] tracing/remotes: Use kstrtobool for boolean tracefs files Vincent Donnefort
2026-12-03 18:59 ` [PATCH v10 04/19] tracing/remotes: Initialise pos in trace_start() Vincent Donnefort
2026-12-03 19:18 ` sashiko-bot
2026-12-03 18:59 ` [PATCH v10 05/19] tracing/remotes: Annotate remote shared fields with READ_ONCE/WRITE_ONCE Vincent Donnefort
2026-12-03 19:19 ` sashiko-bot
2026-12-03 18:59 ` [PATCH v10 06/19] tracing/remotes: Use a single per-remote polling work Vincent Donnefort
2026-12-03 18:59 ` [PATCH v10 07/19] tracing/simple_ring_buffer: Add support for compressed length Vincent Donnefort
2026-12-03 18:59 ` [PATCH v10 08/19] tracing/remotes: Add dmesg tracefs file Vincent Donnefort
2026-12-03 18:59 ` [PATCH v10 09/19] tracing/remotes: selftests: Add a test for the " Vincent Donnefort
2026-12-03 19:39 ` sashiko-bot [this message]
2026-12-03 18:59 ` [PATCH v10 10/19] tracing/remotes: selftests: Prefix hypervisor folder Vincent Donnefort
2026-12-03 18:59 ` [PATCH v10 11/19] ring-buffer: Use panic-friendly locking in ring_buffer_iter interface Vincent Donnefort
2026-12-03 19:38 ` sashiko-bot
2026-12-03 19:00 ` [PATCH v10 12/19] ring-buffer: Add kerneldoc for ring_buffer_poll_remote Vincent Donnefort
2026-12-03 19:00 ` [PATCH v10 13/19] tracing/remotes: Use ring_buffer_capacity() in trace_remote_has_cpu() Vincent Donnefort
2026-12-03 19:00 ` [PATCH v10 14/19] tracing/remotes: Add dump_on_panic tracefs file Vincent Donnefort
2026-12-03 19:00 ` [PATCH v10 15/19] tracing/remotes: selftests: Add a test for the " Vincent Donnefort
2026-12-03 19:00 ` [PATCH v10 16/19] tracing/remotes: Add poll_ms " Vincent Donnefort
2026-12-03 19:00 ` [PATCH v10 17/19] tracing/remotes: Add trace_remote cmdline options Vincent Donnefort
2026-12-03 19:00 ` [PATCH v10 18/19] Documentation: tracing/remotes: Add detailed tracefs layout Vincent Donnefort
2026-12-03 19:00 ` [PATCH v10 19/19] Documentation/kernel-parameters: Add trace_remote Vincent Donnefort
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=sashiko-outbox-248527@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vdonnefort@google.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