tools/perf/tests/shell/lib/coresight.sh

Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/lib/coresight.sh

File Facts

System
Linux kernel
Corpus path
tools/perf/tests/shell/lib/coresight.sh
Extension
.sh
Size
4755 bytes
Lines
135
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

# SPDX-License-Identifier: GPL-2.0
# Carsten Haitzler <carsten.haitzler@arm.com>, 2021

# This is sourced from a driver script so no need for #!/bin... etc. at the
# top - the assumption below is that it runs as part of sourcing after the
# test sets up some basic env vars to say what it is.

# This currently works with ETMv4 / ETF not any other packet types at thi
# point. This will need changes if that changes.

# perf record options for the perf tests to use
PERFRECMEM="-m ,16M"
PERFRECOPT="$PERFRECMEM -e cs_etm//u"

TOOLS=$(dirname $0)
DIR="$TOOLS/$TEST"
BIN="$DIR/$TEST"
# If the test tool/binary does not exist and is executable then skip the test
if ! test -x "$BIN"; then exit 2; fi
# If CoreSight is not available, skip the test
perf list pmu | grep -q cs_etm || exit 2
DATD="."
# If the data dir env is set then make the data dir use that instead of ./
if test -n "$PERF_TEST_CORESIGHT_DATADIR"; then
	DATD="$PERF_TEST_CORESIGHT_DATADIR";
fi
# If the stat dir env is set then make the data dir use that instead of ./
STATD="."
if test -n "$PERF_TEST_CORESIGHT_STATDIR"; then
	STATD="$PERF_TEST_CORESIGHT_STATDIR";
fi

# Called if the test fails - error code 1
err() {
	echo "$1"
	exit 1
}

# Check that some statistics from our perf
check_val_min() {
	STATF="$4"
	if test "$2" -lt "$3"; then
		echo ", FAILED" >> "$STATF"
		err "Sanity check number of $1 is too low ($2 < $3)"
	fi
}

perf_dump_aux_verify() {
	# Some basic checking that the AUX chunk contains some sensible data
	# to see that we are recording something and at least a minimum
	# amount of it. We should almost always see Fn packets in just about
	# anything but certainly we will see some trace info and async
	# packets
	DUMP="$DATD/perf-tmp-aux-dump.txt"
	perf report --stdio --dump -i "$1" | \
		grep -o -e I_ATOM_F -e I_ASYNC -e I_TRACE_INFO > "$DUMP"
	# Simply count how many of these packets we find to see that we are
	# producing a reasonable amount of data - exact checks are not sane
	# as this is a lossy process where we may lose some blocks and the
	# compiler may produce different code depending on the compiler and
	# optimization options, so this is rough just to see if we're
	# either missing almost all the data or all of it
	ATOM_FX_NUM=$(grep -c I_ATOM_F "$DUMP")
	ASYNC_NUM=$(grep -c I_ASYNC "$DUMP")
	TRACE_INFO_NUM=$(grep -c I_TRACE_INFO "$DUMP")
	rm -f "$DUMP"

	# Arguments provide minimums for a pass
	CHECK_FX_MIN="$2"
	CHECK_ASYNC_MIN="$3"

Annotation

Implementation Notes