brintos

brintos / linux-shallow public Read only

0
0
Text · 4.6 KiB · 11ed2c2 Raw
135 lines · bash
1# SPDX-License-Identifier: GPL-2.02# Carsten Haitzler <carsten.haitzler@arm.com>, 20213 4# This is sourced from a driver script so no need for #!/bin... etc. at the5# top - the assumption below is that it runs as part of sourcing after the6# test sets up some basic env vars to say what it is.7 8# This currently works with ETMv4 / ETF not any other packet types at thi9# point. This will need changes if that changes.10 11# perf record options for the perf tests to use12PERFRECMEM="-m ,16M"13PERFRECOPT="$PERFRECMEM -e cs_etm//u"14 15TOOLS=$(dirname $0)16DIR="$TOOLS/$TEST"17BIN="$DIR/$TEST"18# If the test tool/binary does not exist and is executable then skip the test19if ! test -x "$BIN"; then exit 2; fi20# If CoreSight is not available, skip the test21perf list cs_etm | grep -q cs_etm || exit 222DATD="."23# If the data dir env is set then make the data dir use that instead of ./24if test -n "$PERF_TEST_CORESIGHT_DATADIR"; then25	DATD="$PERF_TEST_CORESIGHT_DATADIR";26fi27# If the stat dir env is set then make the data dir use that instead of ./28STATD="."29if test -n "$PERF_TEST_CORESIGHT_STATDIR"; then30	STATD="$PERF_TEST_CORESIGHT_STATDIR";31fi32 33# Called if the test fails - error code 134err() {35	echo "$1"36	exit 137}38 39# Check that some statistics from our perf40check_val_min() {41	STATF="$4"42	if test "$2" -lt "$3"; then43		echo ", FAILED" >> "$STATF"44		err "Sanity check number of $1 is too low ($2 < $3)"45	fi46}47 48perf_dump_aux_verify() {49	# Some basic checking that the AUX chunk contains some sensible data50	# to see that we are recording something and at least a minimum51	# amount of it. We should almost always see Fn packets in just about52	# anything but certainly we will see some trace info and async53	# packets54	DUMP="$DATD/perf-tmp-aux-dump.txt"55	perf report --stdio --dump -i "$1" | \56		grep -o -e I_ATOM_F -e I_ASYNC -e I_TRACE_INFO > "$DUMP"57	# Simply count how many of these packets we find to see that we are58	# producing a reasonable amount of data - exact checks are not sane59	# as this is a lossy process where we may lose some blocks and the60	# compiler may produce different code depending on the compiler and61	# optimization options, so this is rough just to see if we're62	# either missing almost all the data or all of it63	ATOM_FX_NUM=$(grep -c I_ATOM_F "$DUMP")64	ASYNC_NUM=$(grep -c I_ASYNC "$DUMP")65	TRACE_INFO_NUM=$(grep -c I_TRACE_INFO "$DUMP")66	rm -f "$DUMP"67 68	# Arguments provide minimums for a pass69	CHECK_FX_MIN="$2"70	CHECK_ASYNC_MIN="$3"71	CHECK_TRACE_INFO_MIN="$4"72 73	# Write out statistics, so over time you can track results to see if74	# there is a pattern - for example we have less "noisy" results that75	# produce more consistent amounts of data each run, to see if over76	# time any techinques to  minimize data loss are having an effect or77	# not78	STATF="$STATD/stats-$TEST-$DATV.csv"79	if ! test -f "$STATF"; then80		echo "ATOM Fx Count, Minimum, ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF"81	fi82	echo -n "$ATOM_FX_NUM, $CHECK_FX_MIN, $ASYNC_NUM, $CHECK_ASYNC_MIN, $TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF"83 84	# Actually check to see if we passed or failed.85	check_val_min "ATOM_FX" "$ATOM_FX_NUM" "$CHECK_FX_MIN" "$STATF"86	check_val_min "ASYNC" "$ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF"87	check_val_min "TRACE_INFO" "$TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$STATF"88	echo ", Ok" >> "$STATF"89}90 91perf_dump_aux_tid_verify() {92	# Specifically crafted test will produce a list of Tread ID's to93	# stdout that need to be checked to  see that they have had trace94	# info collected in AUX blocks in the perf data. This will go95	# through all the TID's that are listed as CID=0xabcdef and see96	# that all the Thread IDs the test tool reports are  in the perf97	# data AUX chunks98 99	# The TID test tools will print a TID per stdout line that are being100	# tested101	TIDS=$(cat "$2")102	# Scan the perf report to find the TIDs that are actually CID in hex103	# and build a list of the ones found104	FOUND_TIDS=$(perf report --stdio --dump -i "$1" | \105			grep -o "CID=0x[0-9a-z]\+" | sed 's/CID=//g' | \106			uniq | sort | uniq)107	# No CID=xxx found - maybe your kernel is reporting these as108	# VMID=xxx so look there109	if test -z "$FOUND_TIDS"; then110		FOUND_TIDS=$(perf report --stdio --dump -i "$1" | \111				grep -o "VMID=0x[0-9a-z]\+" | sed 's/VMID=//g' | \112				uniq | sort | uniq)113	fi114 115	# Iterate over the list of TIDs that the test says it has and find116	# them in the TIDs found in the perf report117	MISSING=""118	for TID2 in $TIDS; do119		FOUND=""120		for TIDHEX in $FOUND_TIDS; do121			TID=$(printf "%i" $TIDHEX)122			if test "$TID" -eq "$TID2"; then123				FOUND="y"124				break125			fi126		done127		if test -z "$FOUND"; then128			MISSING="$MISSING $TID"129		fi130	done131	if test -n "$MISSING"; then132		err "Thread IDs $MISSING not found in perf AUX data"133	fi134}135