From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Chun-Tse Shao <ctshao@google.com>,
James Clark <james.clark@linaro.org>,
Howard Chu <howardchu95@gmail.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 1/4] perf test shell lbr: Avoid failures with perf event paranoia
Date: Tue, 16 Sep 2025 16:00:04 -0300 [thread overview]
Message-ID: <aMmztG_F1KuAKKq9@x1> (raw)
In-Reply-To: <20250821221834.1312002-2-irogers@google.com>
On Thu, Aug 21, 2025 at 03:18:31PM -0700, Ian Rogers wrote:
> When not running as root and with higher perf event paranoia values
> the perf record LBR tests could fail rather than skipping the
> problematic tests. Add the sensitivity to the test and confirm it
> passes with paranoia values from -1 to 2.
Thanks, applied to perf-tools-next,
Committer testing:
Testing with '$ perf test -vv lbr', i.e. as non root, and then comparing
the output shows the mentioned errors before this patch:
acme@x1:~$ grep -m1 "model name" /proc/cpuinfo
model name : 13th Gen Intel(R) Core(TM) i7-1365U
acme@x1:~$
Before:
132: perf record LBR tests : Skip
After:
132: perf record LBR tests : Ok
- Arnaldo
> Fixes: 32559b99e0f5 ("perf test: Add set of perf record LBR tests")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/tests/shell/record_lbr.sh | 26 ++++++++++++++++++++------
> 1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/record_lbr.sh
> index 6fcb5e52b9b4..78a02e90ece1 100755
> --- a/tools/perf/tests/shell/record_lbr.sh
> +++ b/tools/perf/tests/shell/record_lbr.sh
> @@ -4,6 +4,10 @@
>
> set -e
>
> +ParanoidAndNotRoot() {
> + [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
> +}
> +
> if [ ! -f /sys/bus/event_source/devices/cpu/caps/branches ] &&
> [ ! -f /sys/bus/event_source/devices/cpu_core/caps/branches ]
> then
> @@ -23,6 +27,7 @@ cleanup() {
> }
>
> trap_cleanup() {
> + echo "Unexpected signal in ${FUNCNAME[1]}"
> cleanup
> exit 1
> }
> @@ -123,8 +128,11 @@ lbr_test "-j ind_call" "any indirect call" 2
> lbr_test "-j ind_jmp" "any indirect jump" 100
> lbr_test "-j call" "direct calls" 2
> lbr_test "-j ind_call,u" "any indirect user call" 100
> -lbr_test "-a -b" "system wide any branch" 2
> -lbr_test "-a -j any_call" "system wide any call" 2
> +if ! ParanoidAndNotRoot 1
> +then
> + lbr_test "-a -b" "system wide any branch" 2
> + lbr_test "-a -j any_call" "system wide any call" 2
> +fi
>
> # Parallel
> parallel_lbr_test "-b" "parallel any branch" 100 &
> @@ -141,10 +149,16 @@ parallel_lbr_test "-j call" "parallel direct calls" 100 &
> pid6=$!
> parallel_lbr_test "-j ind_call,u" "parallel any indirect user call" 100 &
> pid7=$!
> -parallel_lbr_test "-a -b" "parallel system wide any branch" 100 &
> -pid8=$!
> -parallel_lbr_test "-a -j any_call" "parallel system wide any call" 100 &
> -pid9=$!
> +if ParanoidAndNotRoot 1
> +then
> + pid8=
> + pid9=
> +else
> + parallel_lbr_test "-a -b" "parallel system wide any branch" 100 &
> + pid8=$!
> + parallel_lbr_test "-a -j any_call" "parallel system wide any call" 100 &
> + pid9=$!
> +fi
>
> for pid in $pid1 $pid2 $pid3 $pid4 $pid5 $pid6 $pid7 $pid8 $pid9
> do
> --
> 2.51.0.rc2.233.g662b1ed5c5-goog
next prev parent reply other threads:[~2025-09-16 19:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 22:18 [PATCH v1 0/4] Test/uniquification related fixes Ian Rogers
2025-08-21 22:18 ` [PATCH v1 1/4] perf test shell lbr: Avoid failures with perf event paranoia Ian Rogers
2025-09-16 19:00 ` Arnaldo Carvalho de Melo [this message]
2025-08-21 22:18 ` [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_* Ian Rogers
2025-09-16 19:04 ` Arnaldo Carvalho de Melo
2025-09-16 19:08 ` Ian Rogers
2025-09-17 1:06 ` Arnaldo Carvalho de Melo
2025-09-18 22:17 ` Ian Rogers
2025-08-21 22:18 ` [PATCH v1 3/4] perf evsel: Fix uniquification when PMU given without suffix Ian Rogers
2025-08-21 22:18 ` [PATCH v1 4/4] perf test: Avoid uncore_imc/clockticks in uniquification test Ian Rogers
2025-09-16 19:15 ` Arnaldo Carvalho de Melo
2025-09-16 20:45 ` 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=aMmztG_F1KuAKKq9@x1 \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ctshao@google.com \
--cc=howardchu95@gmail.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).