brintos

brintos / linux-shallow public Read only

0
0
Text · 1.8 KiB · 3dfa918 Raw
79 lines · bash
1#!/bin/bash2# Test data symbol3 4# SPDX-License-Identifier: GPL-2.05# Leo Yan <leo.yan@linaro.org>, 20226 7shelldir=$(dirname "$0")8# shellcheck source=lib/waiting.sh9. "${shelldir}"/lib/waiting.sh10 11# shellcheck source=lib/perf_has_symbol.sh12. "${shelldir}"/lib/perf_has_symbol.sh13 14skip_if_no_mem_event() {15	perf mem record -e list 2>&1 | grep -E -q 'available' && return 016	return 217}18 19skip_if_no_mem_event || exit 220 21skip_test_missing_symbol buf122 23TEST_PROGRAM="perf test -w datasym"24PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX)25ERR_FILE=$(mktemp /tmp/__perf_test.stderr.XXXXX)26 27check_result() {28	# The memory report format is as below:29	#    99.92%  ...  [.] buf1+0x3830	result=$(perf mem report -i ${PERF_DATA} -s symbol_daddr -q 2>&1 |31		 awk '/buf1/ { print $4 }')32 33	# Testing is failed if has no any sample for "buf1"34	[ -z "$result" ] && return 135 36	while IFS= read -r line; do37		# The "data1" and "data2" fields in structure "buf1" have38		# offset "0x0" and "0x38", returns failure if detect any39		# other offset value.40		if [ "$line" != "buf1+0x0" ] && [ "$line" != "buf1+0x38" ]; then41			return 142		fi43	done <<< "$result"44 45	return 046}47 48cleanup_files()49{50	echo "Cleaning up files..."51	rm -f ${PERF_DATA}52}53 54trap cleanup_files exit term int55 56echo "Recording workload..."57 58# perf mem/c2c internally uses IBS PMU on AMD CPU which doesn't support59# user/kernel filtering and per-process monitoring, spin program on60# specific CPU and test in per-CPU mode.61is_amd=$(grep -E -c 'vendor_id.*AuthenticAMD' /proc/cpuinfo)62if (($is_amd >= 1)); then63	perf mem record -vvv -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM 2>"${ERR_FILE}" &64else65	perf mem record -vvv --all-user -o ${PERF_DATA} -- $TEST_PROGRAM 2>"${ERR_FILE}" &66fi67 68PERFPID=$!69 70wait_for_perf_to_start ${PERFPID} "${ERR_FILE}"71 72sleep 173 74kill $PERFPID75wait $PERFPID76 77check_result78exit $?79