2 # Check Arm SPE doesn't hang when there are forks
4 # SPDX-License-Identifier: GPL-2.0
5 # German Gomez <german.gomez@arm.com>, 2022
7 skip_if_no_arm_spe_event() {
8 perf list | egrep -q 'arm_spe_[0-9]+//' && return 0
12 skip_if_no_arm_spe_event || exit 2
14 # skip if there's no compiler
15 if ! [ -x "$(command -v cc)" ]; then
16 echo "failed: no compiler, install gcc"
20 TEST_PROGRAM_SOURCE=$(mktemp /tmp/__perf_test.program.XXXXX.c)
21 TEST_PROGRAM=$(mktemp /tmp/__perf_test.program.XXXXX)
22 PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
23 PERF_RECORD_LOG=$(mktemp /tmp/__perf_test.log.XXXXX)
27 echo "Cleaning up files..."
28 rm -f ${PERF_RECORD_LOG}
30 rm -f ${TEST_PROGRAM_SOURCE}
34 trap cleanup_files exit term int
36 # compile test program
37 cat << EOF > $TEST_PROGRAM_SOURCE
63 echo "Compiling test program..."
65 cc $TEST_PROGRAM_SOURCE $CFLAGS -o $TEST_PROGRAM || exit 1
67 echo "Recording workload..."
68 perf record -o ${PERF_DATA} -e arm_spe/period=65536/ -vvv -- $TEST_PROGRAM > ${PERF_RECORD_LOG} 2>&1 &
71 # Check if perf hangs by checking the perf-record logs.
73 log0=$(wc -l $PERF_RECORD_LOG)
74 echo Log lines = $log0
76 log1=$(wc -l $PERF_RECORD_LOG)
77 echo Log lines after 1 second = $log1
81 # test program may leave an orphan process running the workload
82 killall $(basename $TEST_PROGRAM)
84 if [ "$log0" = "$log1" ];
86 echo "SPE hang test: FAIL"
89 echo "SPE hang test: PASS"