From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@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>,
Collin Funk <collin.funk1@gmail.com>,
James Clark <james.clark@linaro.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] perf test: AMD IBS swfilt skip kernel tests if paranoia is >1
Date: Fri, 12 Sep 2025 17:41:31 -0700 [thread overview]
Message-ID: <aMS9uykyD5u5gqWf@google.com> (raw)
In-Reply-To: <20250913000350.1306948-1-irogers@google.com>
Hi Ian,
On Fri, Sep 12, 2025 at 05:03:50PM -0700, Ian Rogers wrote:
> If not root and the perf_event_paranoid is set >1 swfilt will fail to
> open the event failing the test. Add check to skip the test in that
> case.
>
Fixes: 0e71bcdcf1f0b10b ("perf test: Add AMD IBS sw filter test")
> Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> tools/perf/tests/shell/amd-ibs-swfilt.sh | 51 ++++++++++++++++++------
> 1 file changed, 38 insertions(+), 13 deletions(-)
>
> diff --git a/tools/perf/tests/shell/amd-ibs-swfilt.sh b/tools/perf/tests/shell/amd-ibs-swfilt.sh
> index 7045ec72ba4c..e7f66df05c4b 100755
> --- a/tools/perf/tests/shell/amd-ibs-swfilt.sh
> +++ b/tools/perf/tests/shell/amd-ibs-swfilt.sh
> @@ -1,6 +1,10 @@
> #!/bin/bash
> # AMD IBS software filtering
>
> +ParanoidAndNotRoot() {
> + [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
> +}
> +
> echo "check availability of IBS swfilt"
>
> # check if IBS PMU is available
> @@ -16,6 +20,7 @@ if [ ! -f /sys/bus/event_source/devices/ibs_op/format/swfilt ]; then
> fi
>
> echo "run perf record with modifier and swfilt"
> +err=0
>
> # setting any modifiers should fail
> perf record -B -e ibs_op//u -o /dev/null true 2> /dev/null
> @@ -31,11 +36,17 @@ if [ $? -ne 0 ]; then
> exit 1
> fi
>
> -# setting it with swfilt=1 should be fine
> -perf record -B -e ibs_op/swfilt=1/k -o /dev/null true
> -if [ $? -ne 0 ]; then
> - echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_user"
> - exit 1
> +if ! ParanoidAndNotRoot 1
> +then
> + # setting it with swfilt=1 should be fine
> + perf record -B -e ibs_op/swfilt=1/k -o /dev/null true
> + if [ $? -ne 0 ]; then
> + echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_user"
> + exit 1
> + fi
> +else
> + echo "[SKIP] not root and perf_event_paranoid too high for exclude_user"
> + err=2
> fi
>
> # check ibs_fetch PMU as well
> @@ -46,10 +57,16 @@ if [ $? -ne 0 ]; then
> fi
>
> # check system wide recording
> -perf record -aB --synth=no -e ibs_op/swfilt/k -o /dev/null true
> -if [ $? -ne 0 ]; then
> - echo "[FAIL] IBS op PMU cannot handle swfilt in system-wide mode"
> - exit 1
> +if ! ParanoidAndNotRoot 0
> +then
> + perf record -aB --synth=no -e ibs_op/swfilt/k -o /dev/null true
> + if [ $? -ne 0 ]; then
> + echo "[FAIL] IBS op PMU cannot handle swfilt in system-wide mode"
> + exit 1
> + fi
> +else
> + echo "[SKIP] not root and perf_event_paranoid too high for system-wide/exclude_user"
> + err=2
> fi
>
> echo "check number of samples with swfilt"
> @@ -60,8 +77,16 @@ if [ ${kernel_sample} -ne 0 ]; then
> exit 1
> fi
>
> -user_sample=$(perf record -e ibs_fetch/swfilt/k -o- true | perf script -i- -F misc | grep -c ^U)
> -if [ ${user_sample} -ne 0 ]; then
> - echo "[FAIL] unexpected user samples: " ${user_sample}
> - exit 1
> +if ! ParanoidAndNotRoot 1
> +then
> + user_sample=$(perf record -e ibs_fetch/swfilt/k -o- true | perf script -i- -F misc | grep -c ^U)
> + if [ ${user_sample} -ne 0 ]; then
> + echo "[FAIL] unexpected user samples: " ${user_sample}
> + exit 1
> + fi
> +else
> + echo "[SKIP] not root and perf_event_paranoid too high for exclude_user"
> + err=2
> fi
> +
> +exit $err
> --
> 2.51.0.384.g4c02a37b29-goog
>
next prev parent reply other threads:[~2025-09-13 0:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-13 0:03 [PATCH v3] perf test: AMD IBS swfilt skip kernel tests if paranoia is >1 Ian Rogers
2025-09-13 0:41 ` Namhyung Kim [this message]
2025-09-13 14:44 ` Arnaldo Carvalho de Melo
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=aMS9uykyD5u5gqWf@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=collin.funk1@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=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
/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.