Re: [PATCH v3] perf test: Fixes for check branch stack sampling

sashiko-bot
2026-04-08T07:16:48Z

Sashiko AI review found 1 potential issue(s):
- [Medium] Incomplete regex in `test_kernel_branches` misses user branch target addresses that don't start with 0-7, causing false negatives.
--

commit 81a20991ebd7cf4f6e494b9b81ee11052acea653
Author: Ian Rogers <irogers@google.com>

perf test: Fixes for check branch stack sampling

This commit fixes and expands the branch stack sampling tests in perf.
It updates user and kernel branch filters to properly check source and target
addresses, increases system call sampling duration for reliability, and cleans
up test output.

> diff --git a/tools/perf/tests/shell/test_brstack.sh b/tools/perf/tests/shell/test_brstack.sh
> index 85233d435be63..025ed9d3d1105 100755
> --- a/tools/perf/tests/shell/test_brstack.sh
> +++ b/tools/perf/tests/shell/test_brstack.sh
[ ... ]
> @@ -73,59 +75,80 @@ test_user_branches() {
[ ... ]
> test_kernel_branches() {
[ ... ]
> + # 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

Does this regex reliably match all user space target addresses?

Because perf script prints brstack addresses without zero-padding, a valid
32-bit user address like 0x8048000 begins with 8 but is much shorter than
16 characters.

Since the regex strictly requires the first character after the prefix to be
between 0 and 7, it seems like it might silently miss shorter user addresses
that start with 8 through f, potentially causing the test to pass when it
should fail.

> + echo "Testing kernel branch sampling [Failed user branches found]"
> + err=1
> + fi

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260408065841.165393-1-irogers@google.com?part=1