projects/linux·blob master · refs

45 lines · 1.1 KiB

1#!/bin/bash -e
2# CoreSight concurrent threads (exclusive)
3
4# SPDX-License-Identifier: GPL-2.0
5
6# If CoreSight is not available, skip the test
7perf list pmu | grep -q cs_etm || exit 2
8
9tmpdir=$(mktemp -d /tmp/__perf_test.coresight_concurrent_threads.XXXXX)
10
11cleanup() {
12 rm -rf "${tmpdir}"
13 trap - EXIT TERM INT
14}
15
16trap_cleanup() {
17 cleanup
18 exit 1
19}
20trap trap_cleanup EXIT TERM INT
21
22cf="$tmpdir/ctl"
23af="$tmpdir/ack"
24mkfifo "$cf" "$af"
25
26nthreads=10
27
28# Timestamps off to reduce trace size, start disabled and use the control FIFO
29# to only record the workload and not startup.
30perf record -o "$tmpdir/data" -e cs_etm/timestamp=0/u -D -1 --control fifo:"$cf","$af" \
31 -- perf test --record-ctl fifo:"$cf","$af" -w named_threads $nthreads 1 > /dev/null 2>&1
32
33perf script -i "$tmpdir/data" > "$tmpdir/script" 2>/dev/null
34
35# Check all threads were traced and they have the correct thread name and symbol
36for i in $(seq 1 $nthreads); do
37 if ! grep -q "thread${i} .* named_threads_thread${i}" "$tmpdir/script"; then
38 echo "Error: thread${i} missing" >&2
39 cleanup
40 exit 1
41 fi
42done
43
44cleanup
45exit 0