public inbox for linux-perf-users@vger.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v4] perf test: Fixes for check branch stack sampling
Date: Thu, 09 Apr 2026 00:15:46 +0000	[thread overview]
Message-ID: <20260409001547.0C3A7C19421@smtp.kernel.org> (raw)
In-Reply-To: <20260409000216.196083-1-irogers@google.com>

Sashiko AI review found 1 potential issue(s):
- [Medium] The regular expression to check for user-space target addresses incorrectly uses `{1,15}`, which excludes single-digit hex addresses like `0x0`.
--

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

perf test: Fixes for check branch stack sampling

This commit modifies the branch stack sampling tests to be more permissive
regarding kernel addresses in user branches and user addresses in kernel
branches. It also adjusts the system call sampling test parameters and
redirects unnecessary output to a temporary file.

> diff --git a/tools/perf/tests/shell/test_brstack.sh b/tools/perf/tests/shell/test_brstack.sh
> index 85233d435be63..eb5837f82e390 100755
> --- a/tools/perf/tests/shell/test_brstack.sh
> +++ b/tools/perf/tests/shell/test_brstack.sh
> @@ -73,59 +79,88 @@ test_user_branches() {
[ ... ]
>  test_kernel_branches() {
[ ... ]
> -		# Look for no source addresses without top bit set
> -		if grep -E -m1 "^0x[0-7][0-9a-f]{0,15}" $TMPDIR/perf.script; then
> -			echo "ERROR: User branches found with kernel filter"
> -			err=1
> -		fi
> +	# 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]{1,15}/" $TMPDIR/perf.script; then

Does the regex "{1,15}" incorrectly exclude single-digit hex addresses like
"0x0"?

Since the commit message notes that Aarch64 may zero out user land
addresses to prevent leaks, a zeroed address would be output as "0x0" by perf
script.

The previous regex used "{0,15}", which would match "0x0", but the
updated regex requires at least two hex digits when starting with 0-7.

Could this cause the test to silently miss zeroed addresses and produce a false
negative?

> +		echo "Testing kernel branch sampling [Failed user branches found]"
> +		err=1
> +	fi
> +	if [ $err -eq 0 ]; then
> +		echo "Testing kernel branch sampling [Passed]"
> +		err=$start_err
>  	else
> -		perf record -o $TMPDIR/perf.data --branch-filter any,k -- \
> -			perf bench syscall basic --loop 1000
> -		perf script -i $TMPDIR/perf.data --fields brstack | \
> -			tr ' ' '\n' > $TMPDIR/perf.script
> -
> -		# Example of branch entries:
> -		#       "0xffffffff93bda241/0xffffffff93bda20f/M/-/-/..."
> -		# Source addresses come first and target address can be either
> -		# userspace or kernel even with k option, as long as the source
> -		# is in kernel.
> -
> -		#Look for source addresses with top bit set
> -		if ! grep -E -m1 "^0x[89a-f][0-9a-f]{15}" $TMPDIR/perf.script; then
> -			echo "ERROR: Kernel branches missing"
> -			err=1
> -		fi
> -		# Look for no source addresses without top bit set
> -		if grep -E -m1 "^0x[0-7][0-9a-f]{0,15}" $TMPDIR/perf.script; then
> -			echo "ERROR: User branches found with kernel filter"
> -			err=1
> -		fi
> +		echo "Testing kernel branch sampling [Failed]"
>  	fi
>  }

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

      reply	other threads:[~2026-04-09  0:15 UTC|newest]

Thread overview: 11+ 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
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
2026-04-08 22:02         ` Ian Rogers
2026-04-09  0:02           ` [PATCH v4] " Ian Rogers
2026-04-09  0:15             ` sashiko-bot [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=20260409001547.0C3A7C19421@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