1#!/bin/sh 2# AMD IBS software filtering 3 4echo "check availability of IBS swfilt" 5 6# check if IBS PMU is available 7if [ ! -d /sys/bus/event_source/devices/ibs_op ]; then 8 echo "[SKIP] IBS PMU does not exist" 9 exit 2 10fi 11 12# check if IBS PMU has swfilt format 13if [ ! -f /sys/bus/event_source/devices/ibs_op/format/swfilt ]; then 14 echo "[SKIP] IBS PMU does not have swfilt" 15 exit 2 16fi 17 18echo "run perf record with modifier and swfilt" 19 20# setting any modifiers should fail 21perf record -B -e ibs_op//u -o /dev/null true 2> /dev/null 22if [ $? -eq 0 ]; then 23 echo "[FAIL] IBS PMU should not accept exclude_kernel" 24 exit 1 25fi 26 27# setting it with swfilt should be fine 28perf record -B -e ibs_op/swfilt/u -o /dev/null true 29if [ $? -ne 0 ]; then 30 echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_kernel" 31 exit 1 32fi 33 34# setting it with swfilt=1 should be fine 35perf record -B -e ibs_op/swfilt=1/k -o /dev/null true 36if [ $? -ne 0 ]; then 37 echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_user" 38 exit 1 39fi 40 41# check ibs_fetch PMU as well 42perf record -B -e ibs_fetch/swfilt/u -o /dev/null true 43if [ $? -ne 0 ]; then 44 echo "[FAIL] IBS fetch PMU cannot handle swfilt for exclude_kernel" 45 exit 1 46fi 47 48# check system wide recording 49perf record -aB --synth=no -e ibs_op/swfilt/k -o /dev/null true 50if [ $? -ne 0 ]; then 51 echo "[FAIL] IBS op PMU cannot handle swfilt in system-wide mode" 52 exit 1 53fi 54 55echo "check number of samples with swfilt" 56 57kernel_sample=$(perf record -e ibs_op/swfilt/u -o- true | perf script -i- -F misc | grep -c ^K) 58if [ ${kernel_sample} -ne 0 ]; then 59 echo "[FAIL] unexpected kernel samples: " ${kernel_sample} 60 exit 1 61fi 62 63user_sample=$(perf record -e ibs_fetch/swfilt/k -o- true | perf script -i- -F misc | grep -c ^U) 64if [ ${user_sample} -ne 0 ]; then 65 echo "[FAIL] unexpected user samples: " ${user_sample} 66 exit 1 67fi 68