Skip to content

Commit 0e71bcd

Browse files
namhyungacmel
authored andcommitted
perf test: Add AMD IBS sw filter test
The kernel v6.14 added 'swfilt' to support privilege filtering in software so that IBS can be used by regular users. Add a test case in x86 to verify the behavior. $ sudo perf test -vv 'IBS software filter' 113: AMD IBS software filtering: --- start --- test child forked, pid 178826 check availability of IBS swfilt run perf record with modifier and swfilt [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 0.000 MB /dev/null ] [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 0.000 MB /dev/null ] [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 0.000 MB /dev/null ] [ perf record: Woken up 0 times to write data ] [ perf record: Captured and wrote 0.000 MB /dev/null ] check number of samples with swfilt [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 0.037 MB - ] [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 0.041 MB - ] ---- end(0) ---- 113: AMD IBS software filtering : Ok Reviewed-by: Ravi Bangoria <[email protected]> Signed-off-by: Namhyung Kim <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> # On a 9950x3d Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent fa9b357 commit 0e71bcd

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/sh
2+
# AMD IBS software filtering
3+
4+
echo "check availability of IBS swfilt"
5+
6+
# check if IBS PMU is available
7+
if [ ! -d /sys/bus/event_source/devices/ibs_op ]; then
8+
echo "[SKIP] IBS PMU does not exist"
9+
exit 2
10+
fi
11+
12+
# check if IBS PMU has swfilt format
13+
if [ ! -f /sys/bus/event_source/devices/ibs_op/format/swfilt ]; then
14+
echo "[SKIP] IBS PMU does not have swfilt"
15+
exit 2
16+
fi
17+
18+
echo "run perf record with modifier and swfilt"
19+
20+
# setting any modifiers should fail
21+
perf record -B -e ibs_op//u -o /dev/null true 2> /dev/null
22+
if [ $? -eq 0 ]; then
23+
echo "[FAIL] IBS PMU should not accept exclude_kernel"
24+
exit 1
25+
fi
26+
27+
# setting it with swfilt should be fine
28+
perf record -B -e ibs_op/swfilt/u -o /dev/null true
29+
if [ $? -ne 0 ]; then
30+
echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_kernel"
31+
exit 1
32+
fi
33+
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+
fi
40+
41+
# check ibs_fetch PMU as well
42+
perf record -B -e ibs_fetch/swfilt/u -o /dev/null true
43+
if [ $? -ne 0 ]; then
44+
echo "[FAIL] IBS fetch PMU cannot handle swfilt for exclude_kernel"
45+
exit 1
46+
fi
47+
48+
# 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
53+
fi
54+
55+
echo "check number of samples with swfilt"
56+
57+
kernel_sample=$(perf record -e ibs_op/swfilt/u -o- true | perf script -i- -F misc | grep -c ^K)
58+
if [ ${kernel_sample} -ne 0 ]; then
59+
echo "[FAIL] unexpected kernel samples: " ${kernel_sample}
60+
exit 1
61+
fi
62+
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
67+
fi

0 commit comments

Comments
 (0)