1#!/bin/sh 2# Miscellaneous Intel PT testing 3# SPDX-License-Identifier: GPL-2.0 4 5set -e 6 7# Skip if no Intel PT 8perf list | grep -q 'intel_pt//' || exit 2 9 10skip_cnt=0 11ok_cnt=0 12err_cnt=0 13 14tmpfile=`mktemp` 15perfdatafile=`mktemp` 16 17can_cpu_wide() 18{ 19 perf record -o ${tmpfile} -B -N --no-bpf-event -e dummy:u -C $1 true 2>&1 >/dev/null || return 2 20 return 0 21} 22 23test_system_wide_side_band() 24{ 25 # Need CPU 0 and CPU 1 26 can_cpu_wide 0 || return $? 27 can_cpu_wide 1 || return $? 28 29 # Record on CPU 0 a task running on CPU 1 30 perf record -B -N --no-bpf-event -o ${perfdatafile} -e intel_pt//u -C 0 -- taskset --cpu-list 1 uname 31 32 # Should get MMAP events from CPU 1 because they can be needed to decode 33 mmap_cnt=`perf script -i ${perfdatafile} --no-itrace --show-mmap-events -C 1 2>/dev/null | grep MMAP | wc -l` 34 35 if [ ${mmap_cnt} -gt 0 ] ; then 36 return 0 37 fi 38 39 echo "Failed to record MMAP events on CPU 1 when tracing CPU 0" 40 return 1 41} 42 43count_result() 44{ 45 if [ $1 -eq 2 ] ; then 46 skip_cnt=`expr ${skip_cnt} \+ 1` 47 return 48 fi 49 if [ $1 -eq 0 ] ; then 50 ok_cnt=`expr ${ok_cnt} \+ 1` 51 return 52 fi 53 err_cnt=`expr ${err_cnt} \+ 1` 54} 55 56test_system_wide_side_band 57 58count_result $? 59 60rm -f ${tmpfile} 61rm -f ${perfdatafile} 62 63if [ ${err_cnt} -gt 0 ] ; then 64 exit 1 65fi 66 67if [ ${ok_cnt} -gt 0 ] ; then 68 exit 0 69fi 70 71exit 2 72