|
| 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