Skip to content

Commit ee3a9fc

Browse files
captain5050gregkh
authored andcommitted
perf test: AMD IBS swfilt skip kernel tests if paranoia is >1
[ Upstream commit 2e35012 ] 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: 0e71bcd ("perf test: Add AMD IBS sw filter test") Reviewed-by: Namhyung Kim <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Collin Funk <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent a0d8871 commit ee3a9fc

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

tools/perf/tests/shell/amd-ibs-swfilt.sh

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22
# AMD IBS software filtering
33

4+
ParanoidAndNotRoot() {
5+
[ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
6+
}
7+
48
echo "check availability of IBS swfilt"
59

610
# check if IBS PMU is available
@@ -16,6 +20,7 @@ if [ ! -f /sys/bus/event_source/devices/ibs_op/format/swfilt ]; then
1620
fi
1721

1822
echo "run perf record with modifier and swfilt"
23+
err=0
1924

2025
# setting any modifiers should fail
2126
perf record -B -e ibs_op//u -o /dev/null true 2> /dev/null
@@ -31,11 +36,17 @@ if [ $? -ne 0 ]; then
3136
exit 1
3237
fi
3338

34-
# setting it with swfilt=1 should be fine
35-
perf record -B -e ibs_op/swfilt=1/k -o /dev/null true
36-
if [ $? -ne 0 ]; then
37-
echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_user"
38-
exit 1
39+
if ! ParanoidAndNotRoot 1
40+
then
41+
# setting it with swfilt=1 should be fine
42+
perf record -B -e ibs_op/swfilt=1/k -o /dev/null true
43+
if [ $? -ne 0 ]; then
44+
echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_user"
45+
exit 1
46+
fi
47+
else
48+
echo "[SKIP] not root and perf_event_paranoid too high for exclude_user"
49+
err=2
3950
fi
4051

4152
# check ibs_fetch PMU as well
@@ -46,10 +57,16 @@ if [ $? -ne 0 ]; then
4657
fi
4758

4859
# check system wide recording
49-
perf record -aB --synth=no -e ibs_op/swfilt/k -o /dev/null true
50-
if [ $? -ne 0 ]; then
51-
echo "[FAIL] IBS op PMU cannot handle swfilt in system-wide mode"
52-
exit 1
60+
if ! ParanoidAndNotRoot 0
61+
then
62+
perf record -aB --synth=no -e ibs_op/swfilt/k -o /dev/null true
63+
if [ $? -ne 0 ]; then
64+
echo "[FAIL] IBS op PMU cannot handle swfilt in system-wide mode"
65+
exit 1
66+
fi
67+
else
68+
echo "[SKIP] not root and perf_event_paranoid too high for system-wide/exclude_user"
69+
err=2
5370
fi
5471

5572
echo "check number of samples with swfilt"
@@ -60,8 +77,16 @@ if [ ${kernel_sample} -ne 0 ]; then
6077
exit 1
6178
fi
6279

63-
user_sample=$(perf record -e ibs_fetch/swfilt/k -o- true | perf script -i- -F misc | grep -c ^U)
64-
if [ ${user_sample} -ne 0 ]; then
65-
echo "[FAIL] unexpected user samples: " ${user_sample}
66-
exit 1
80+
if ! ParanoidAndNotRoot 1
81+
then
82+
user_sample=$(perf record -e ibs_fetch/swfilt/k -o- true | perf script -i- -F misc | grep -c ^U)
83+
if [ ${user_sample} -ne 0 ]; then
84+
echo "[FAIL] unexpected user samples: " ${user_sample}
85+
exit 1
86+
fi
87+
else
88+
echo "[SKIP] not root and perf_event_paranoid too high for exclude_user"
89+
err=2
6790
fi
91+
92+
exit $err

0 commit comments

Comments
 (0)