From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1] perf test: Fixes for check branch stack sampling
Date: Wed, 08 Apr 2026 06:12:18 +0000 [thread overview]
Message-ID: <20260408061218.9FFAEC19424@smtp.kernel.org> (raw)
In-Reply-To: <20260408060303.51231-1-irogers@google.com>
Sashiko AI review found 3 potential issue(s):
- [Medium] Incorrect regex in `test_user_branches()` renders the test a false negative for leaked kernel addresses.
- [Low] Contradictory test output in `test_syscall()` when skipped.
- [Low] Missing closing bracket in the failure log output of `test_kernel_branches()`.
--
commit 5cc9b2c1d3de6813cdf5dae014b695e4edf82d5d
Author: Ian Rogers <irogers@google.com>
perf test: Fixes for check branch stack sampling
This commit updates the branch stack sampling tests to filter cross-boundary
branches properly and increases the sampling duration to make syscall
sampling more reliable. It also redirects unnecessary test output to
temporary files to unclutter the logs and improves the pass/fail reporting.
> diff --git a/tools/perf/tests/shell/test_brstack.sh b/tools/perf/tests/shell/test_brstack.sh
> index 85233d435be63..d317ed0e063ef 100755
> --- a/tools/perf/tests/shell/test_brstack.sh
> +++ b/tools/perf/tests/shell/test_brstack.sh
[ ... ]
> @@ -73,59 +75,81 @@ test_user_branches() {
> perf script -i "$TMPDIR/perf.data" --fields brstack | \
> tr ' ' '\n' > "$TMPDIR/perf.script"
>
> - # There should be no kernel addresses with the u option, in either
> - # source or target addresses.
> - if grep -E -m1 "0x[89a-f][0-9a-f]{15}" $TMPDIR/perf.script; then
> - echo "ERROR: Kernel address found in user mode"
> + # There should be no kernel addresses in the target with the u option.
> + if grep -q -E -m1 "^0x[0-9a-f]{16}/[89a-f][0-9a-f]{15}/" $TMPDIR/perf.script; then
The perf script output normally prefixes addresses with 0x, but this regex
appears to expect the target address immediately after the slash to lack a
0x prefix.
It also requires the source address to be exactly 16 hex digits, but user
space addresses often lack zero-padding and look like 0x400000.
Does this regex fail to match these output formats, preventing it from
detecting leaked kernel addresses in the test?
> + echo "Testing user branch stack sampling [Failed kernel address found in user mode]"
> err=1
> fi
[ ... ]
> test_kernel_branches() {
> echo "Testing that k option only includes kernel source addresses"
>
[ ... ]
> + # Look for no target addresses without top bit set
> + if grep -q -E -m1 "^0x[0-9a-f]{0,16}/0x[0-7][0-9a-f]{0,15}/" $TMPDIR/perf.script; then
> + echo "Testing that k option [Failed user branches found with kernel filter"
This isn't a bug, but there is a missing closing ] bracket at the end of the
failure string.
> + err=1
> + fi
[ ... ]
> test_syscall() {
> echo "Testing syscalls"
> + start_err=$err
> + err=0
> # skip if perf doesn't have enough privileges
> - if ! perf record --branch-filter any,k -o- -- true > /dev/null; then
> - echo "skip: not enough privileges"
> + if ! perf record --branch-filter any,k -o- -- true > "$TMPDIR/record.txt" 2>&1; then
> + echo "Testing syscalls [Skipped: not enough privileges]"
> else
> perf record -o $TMPDIR/perf.data --branch-filter \
> - any_call,save_type,u,k -c 10000 -- \
> - perf bench syscall basic --loop 1000
> + any_call,save_type,u,k -c 10007 -- \
> + perf bench syscall basic --loop 8000 > "$TMPDIR/record.txt" 2>&1
> perf script -i $TMPDIR/perf.data --fields brstacksym | \
> tr ' ' '\n' > $TMPDIR/perf.script
>
> check_branches "getppid[^ ]*/SYSCALL/"
> fi
> + if [ $err -eq 0 ]; then
> + echo "Testing syscalls [Passed]"
Unlike test_kernel_branches(), there is no early return after the skip
message.
If perf record lacks privileges, will the test execution fall through to here
and incorrectly print that the test passed immediately after printing that
it was skipped?
> + err=$start_err
> + else
> + echo "Testing syscalls [Failed]"
> + fi
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260408060303.51231-1-irogers@google.com?part=1
next prev parent reply other threads:[~2026-04-08 6:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 6:03 [PATCH v1] perf test: Fixes for check branch stack sampling Ian Rogers
2026-04-08 6:12 ` sashiko-bot [this message]
2026-04-08 6:20 ` [PATCH v2] " Ian Rogers
2026-04-08 6:34 ` sashiko-bot
2026-04-08 6:58 ` [PATCH v3] " Ian Rogers
2026-04-08 7:16 ` sashiko-bot
2026-04-08 7:40 ` Ian Rogers
2026-04-08 12:37 ` James Clark
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=20260408061218.9FFAEC19424@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
/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