* [PATCH v2] perf test: AMD IBS swfilt skip kernel tests if paranoia is >1
@ 2025-09-10 15:56 Ian Rogers
2025-09-10 17:39 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2025-09-10 15:56 UTC (permalink / raw)
To: Ravi Bangoria, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
Kan Liang, Collin Funk, James Clark, linux-perf-users,
linux-kernel
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.
Signed-off-by: Ian Rogers <irogers@google.com>
---
Remove incorrect sample count corrections
---
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..ebe1fedb897b 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 1
+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 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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] perf test: AMD IBS swfilt skip kernel tests if paranoia is >1
2025-09-10 15:56 [PATCH v2] perf test: AMD IBS swfilt skip kernel tests if paranoia is >1 Ian Rogers
@ 2025-09-10 17:39 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2025-09-10 17:39 UTC (permalink / raw)
To: Ian Rogers
Cc: Ravi Bangoria, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Adrian Hunter, Kan Liang, Collin Funk, James Clark,
linux-perf-users, linux-kernel
On Wed, Sep 10, 2025 at 08:56:35AM -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.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> Remove incorrect sample count corrections
> ---
> 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..ebe1fedb897b 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 1
Using CPU events (-a) requires paranoid level 0.
Thanks,
Namhyung
> +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 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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-10 17:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-10 15:56 [PATCH v2] perf test: AMD IBS swfilt skip kernel tests if paranoia is >1 Ian Rogers
2025-09-10 17:39 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox