From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 04/12] perf tests: Add robust record retry helper and use subsecond workloads
Date: Tue, 16 Jun 2026 06:27:30 +0000 [thread overview]
Message-ID: <20260616062731.05AAA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260616061404.41929-5-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] GNU `mktemp` syntax error breaks the recording loop for all tests.
- [Medium] Local variable shadowing in `perf_record_with_retry` breaks `test_uid`'s permission check.
- [Medium] `perf_record_cleanup` uses a global wildcard deletion that clobbers log files of concurrently executing tests.
--
commit d3b4c0d4db4697b810bf2709918c20b98619d0e1
Author: Ian Rogers <irogers@google.com>
perf tests: Add robust record retry helper and use subsecond workloads
Introduce perf_record_with_retry and perf_record_cleanup in a shared
library tests/shell/lib/perf_record.sh to prevent record test failures
caused by transient recording or workload delays.
> diff --git a/tools/perf/tests/shell/lib/perf_record.sh b/tools/perf/tests/shell/lib/perf_record.sh
> new file mode 100644
> --- /dev/null
> +++ b/tools/perf/tests/shell/lib/perf_record.sh
> @@ -0,0 +1,47 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +perf_record_with_retry() {
> + local perfdata="$1"
> + local check_cmd="$2"
> + local testprog_base="$3"
> + shift 3
> +
> + local logfile
> + logfile=$(mktemp /tmp/__perf_record_retry.XXXXXX.log)
[Severity: Medium]
Will this mktemp invocation fail because the X's are not at the end of the
template?
GNU mktemp requires the X characters to be at the absolute end of the template
string (unless the --suffix option is used). Since this fails with 'too few
X's in template', the logfile variable is left empty.
[ ... ]
> + local duration
> + local first_run=true
> + local ret=1
> + for duration in 0.01 0.1 0.3 1.0 2.0; do
> + rm -f "${perfdata}".old
> + perf record "$@" -o "${perfdata}" ${testprog_base} ${duration} > "$logfile" 2>&1
[Severity: Medium]
Can the empty logfile variable cause a syntax error here?
Because mktemp failed and logfile is empty, bash attempts to redirect the
output to an empty string. This aborts the command with a 'No such file or
directory' error and prevents perf record from running at all.
[ ... ]
> +perf_record_cleanup() {
> + rm -f /tmp/__perf_record_retry.*.log
[Severity: Medium]
Could this wildcard deletion remove the log files of other concurrently
running tests?
Since perf test can execute tests in parallel, using a global wildcard
deletion like this can clobber the active temporary log files of other tests.
This breaks test isolation and can cause sporadic failures or masked errors.
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
[ ... ]
> @@ -235,16 +240,19 @@ test_uid() {
> echo "Uid sampling test"
> - if ! perf record -aB --synth=no --uid "$(id -u)" -o "${perfdata}" ${testprog} \
> - > "${script_output}" 2>&1
> - then
> - if grep -q "libbpf.*EPERM" "${script_output}"
> + local logfile
> + logfile="/tmp/__perf_record_retry.$(id -u).$BASHPID.log"
> + local ret=0
> + perf_record_with_retry "${perfdata}" "check_uid" "perf test -w thloop" \
> + -aB --synth=no --uid "$(id -u)" || ret=$?
> + if [ $ret -eq 2 ]; then
> + if grep -q -E "libbpf.*EPERM|Access to performance monitoring|Permission denied|Failure to open any events" \
> + "$logfile"
[Severity: Medium]
Is it possible the grep will fail to find the EPERM error because the logs
were written to a different file?
The perf_record_with_retry helper declares its own 'local logfile' and sets it
to a dynamically generated mktemp path. This shadows the caller's logfile
variable without exporting the actual filename used.
When test_uid attempts to grep its own logfile path, it operates on a
non-existent file.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260616061404.41929-1-irogers@google.com?part=4
next prev parent reply other threads:[~2026-06-16 6:27 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 1:27 [PATCH v1 00/12] perf tests: Enhancements, speedups, and flakiness fixes Ian Rogers
2026-06-16 1:27 ` [PATCH v1 01/12] perf parse-events: Restrict core PMU bypass to --cputype option Ian Rogers
2026-06-16 1:44 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 02/12] perf test: Truncate test description to fit terminal width Ian Rogers
2026-06-16 1:38 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 03/12] perf tests workloads: Support sub-second durations in noploop and thloop Ian Rogers
2026-06-16 1:35 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 04/12] perf tests: Add robust record retry helper and use subsecond workloads Ian Rogers
2026-06-16 1:38 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 05/12] perf tests: Skip metrics validation if system-wide recording lacks permission Ian Rogers
2026-06-16 1:41 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 06/12] perf tests: Fix Python JIT dump profiling test failure Ian Rogers
2026-06-16 1:39 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 07/12] perf tests: Fix flakiness in trace record and replay test Ian Rogers
2026-06-16 1:42 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 08/12] perf tests: Fix flakiness in BPF counters test on hybrid systems Ian Rogers
2026-06-16 1:35 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 09/12] perf tests: Fix flakiness in branch stack sampling tests Ian Rogers
2026-06-16 1:27 ` [PATCH v1 10/12] perf tests: Speed up off-cpu profiling tests Ian Rogers
2026-06-16 1:41 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 11/12] perf tests: Speed up lock contention analysis shell test Ian Rogers
2026-06-16 1:27 ` [PATCH v1 12/12] perf tests: Speed up metrics checking shell tests Ian Rogers
2026-06-16 6:13 ` [PATCH v2 00/12] perf tests: Enhance robustness, speed up execution, and fix flakiness Ian Rogers
2026-06-16 6:13 ` [PATCH v2 01/12] perf parse-events: Restrict core PMU bypass to --cputype option Ian Rogers
2026-06-16 6:31 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 02/12] perf test: Truncate test description to fit terminal width Ian Rogers
2026-06-16 6:24 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 03/12] perf tests workloads: Support sub-second durations in noploop and thloop Ian Rogers
2026-06-16 6:22 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 04/12] perf tests: Add robust record retry helper and use subsecond workloads Ian Rogers
2026-06-16 6:27 ` sashiko-bot [this message]
2026-06-16 6:13 ` [PATCH v2 05/12] perf tests: Skip metrics validation if system-wide recording lacks permission Ian Rogers
2026-06-16 6:13 ` [PATCH v2 06/12] perf tests: Fix Python JIT dump profiling test failure Ian Rogers
2026-06-16 6:27 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 07/12] perf tests: Fix flakiness in trace record and replay test Ian Rogers
2026-06-16 6:27 ` sashiko-bot
2026-06-16 6:14 ` [PATCH v2 08/12] perf tests: Fix flakiness in BPF counters test on hybrid systems Ian Rogers
2026-06-16 6:14 ` [PATCH v2 09/12] perf tests: Fix flakiness in branch stack sampling tests Ian Rogers
2026-06-16 6:14 ` [PATCH v2 10/12] perf tests: Speed up off-cpu profiling tests Ian Rogers
2026-06-16 6:25 ` sashiko-bot
2026-06-16 6:14 ` [PATCH v2 11/12] perf tests: Speed up lock contention analysis shell test Ian Rogers
2026-06-16 6:14 ` [PATCH v2 12/12] perf tests: Speed up metrics checking shell tests Ian Rogers
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=20260616062731.05AAA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@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 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.