In case anyone else might find this useful.
Compile perf with Coresight Embedded Trace Extension.
Quoting https://docs.nvidia.com/jetson/archives/r38.4/DeveloperGuide/AT/JetsonLinuxDevelopmentTools/DebuggingOnJetsonPlatforms.html#debugging-on-jetson-platforms-hsstp
"Coresight Embedded Trace Extension (ETE) is the trace architecture for Armv9-A PEs. ETE has many
similarities with the Arm ETMv4 architecture. On Jetson Thor, the trace from the Coresight ETE module
in each CCPLEX core is routed to system memory via Trace Buffer Extension (TRBE).
The Linux kernel tool perf built with the OpenCSD library can be used to decode Coresight trace packets."
# 1. Install build prerequisites or to confirm they're installed
sudo apt update
sudo apt install -y build-essential git make cmake pkg-config \
libelf-dev libdw-dev libunwind-dev libssl-dev zlib1g-dev \
bison flex bc
# 2. Clone, build and install OpenCSD (CoreSight trace stream decoder)
git clone https://github.com/Linaro/OpenCSD.git
cd OpenCSD
git checkout v1.8.0
make -j10 -C decoder/build/linux
sudo make -C decoder/build/linux install
sudo ldconfig
# 3. Go to your Jetson kernel source tree
cd Linux_for_Tegra/source/kernel/kernel-noble
# 4. Add OpenCSD to perf's cs-etm decoder.
perl -0pi -e 's/case OCSD_GEN_TRC_ELEM_SWTRACE:\n#if \(OCSD_VER_NUM >= 0x010400\)/case OCSD_GEN_TRC_ELEM_SWTRACE:\n\t\tcase OCSD_GEN_TRC_ELEM_ITMTRACE:\n#if (OCSD_VER_NUM >= 0x010400)/' \
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
# 5. Verify the edit
grep -n 'OCSD_GEN_TRC_ELEM_SWTRACE\|OCSD_GEN_TRC_ELEM_ITMTRACE\|OCSD_GEN_TRC_ELEM_INSTRUMENTATION' \
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
# 6. Build perf with CoreSight/OpenCSD support
make -C tools/perf VF=1 CORESIGHT=1
# 7. Install perf
sudo make -C tools/perf CORESIGHT=1 install prefix=/usr/local
# 8. Load the Coresight ETE driver. coresight and coresight_trbe are default loaded; if not on your Thor, add them
sudo modprobe coresight-etm4x
# 9. Make that module load automatically on boot
printf 'coresight-etm4x\n' | sudo tee /etc/modules-load.d/coresight-etm4x.conf
# 10. Confirm the 14 ETE devices now exist
ls /sys/bus/coresight/devices
# 11. Record a test trace on Thor
sudo perf record -e cs_etm/contextid=0,timestamp=0/u --per-thread -- ls
# 12. Decode/report the trace
sudo perf report --stdio --dump -i ./perf.data 2>&1 | tee dump.log
A brief overview https://github.com/Linaro/OpenCSD/blob/master/HOWTO.md
See attachment for related commands.
perf_coresight_commands.txt (5.0 KB)