[PATCH v2 2/2] perf cs-etm: Test sparse CPU maps

James Clark posted 2 patches 3 weeks ago
[PATCH v2 2/2] perf cs-etm: Test sparse CPU maps
Posted by James Clark 3 weeks ago
We only currently test with default (all CPUs) or --per-thread mode.
Different permutations of the "-C" option can affect decoding so add
tests for some of them.

Signed-off-by: James Clark <james.clark@linaro.org>
---
 tools/perf/tests/shell/test_arm_coresight.sh | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/tests/shell/test_arm_coresight.sh
index 1c750b67d141..bbf89e944e7b 100755
--- a/tools/perf/tests/shell/test_arm_coresight.sh
+++ b/tools/perf/tests/shell/test_arm_coresight.sh
@@ -198,6 +198,58 @@ arm_cs_etm_basic_test() {
 	arm_cs_report "CoreSight basic testing with '$*'" $err
 }
 
+arm_cs_etm_test_cpu_list() {
+	echo "Testing sparse CPU list: $1"
+	perf record -o ${perfdata} -e cs_etm//u -C $1 \
+		-- taskset --cpu-list $1 true > /dev/null 2>&1
+	perf_script_branch_samples true
+	err=$?
+	arm_cs_report "CoreSight sparse CPUs with '$*'" $err
+}
+
+arm_cs_etm_sparse_cpus_test() {
+	# Iterate for every ETM device
+	cpus=()
+	for dev in /sys/bus/event_source/devices/cs_etm/cpu*; do
+		# Canonicalize the path
+		dev=`readlink -f $dev`
+
+		# Find the ETM device belonging to which CPU
+		cpus+=("$(cat $dev/cpu)")
+	done
+
+	mapfile -t cpus < <(printf '%s\n' "${cpus[@]}" | sort -n)
+	total=${#cpus[@]}
+
+	# Need more than 1 to test
+	if [ $total -le 1 ]; then
+		return 0
+	fi
+
+	half=$((total / 2))
+
+	# First half
+	first_half=$(IFS=,; echo "${cpus[*]:0:$half}")
+	arm_cs_etm_test_cpu_list $first_half
+
+	# Second half
+	second_half=$(IFS=,; echo "${cpus[*]:$half}")
+	arm_cs_etm_test_cpu_list $second_half
+
+	# Odd list is the same as halves unless >= 4 CPUs
+	if [ $total -lt 4 ]; then
+		return 0
+	fi
+
+	# Odd indices
+	odd_cpus=()
+	for ((i=1; i<total; i+=2)); do
+		odd_cpus+=("${cpus[$i]}")
+	done
+	odd_list=$(IFS=,; echo "${odd_cpus[*]}")
+	arm_cs_etm_test_cpu_list $odd_list
+}
+
 arm_cs_etm_traverse_path_test
 arm_cs_etm_system_wide_test
 arm_cs_etm_snapshot_test
@@ -211,4 +263,6 @@ arm_cs_etm_basic_test -e cs_etm/timestamp=1/ -a
 arm_cs_etm_basic_test -e cs_etm/timestamp=0/
 arm_cs_etm_basic_test -e cs_etm/timestamp=1/
 
+arm_cs_etm_sparse_cpus_test
+
 exit $glb_err

-- 
2.34.1
Re: [PATCH v2 2/2] perf cs-etm: Test sparse CPU maps
Posted by Leo Yan 2 weeks, 6 days ago
On Mon, Jan 19, 2026 at 10:18:36AM +0000, Coresight ML wrote:
> We only currently test with default (all CPUs) or --per-thread mode.
> Different permutations of the "-C" option can affect decoding so add
> tests for some of them.
> 
> Signed-off-by: James Clark <james.clark@linaro.org>

LGTM and verified on Juno board:

Tested-by: Leo Yan <leo.yan@arm.com>
Re: [PATCH v2 2/2] perf cs-etm: Test sparse CPU maps
Posted by Arnaldo Carvalho de Melo 2 weeks, 6 days ago
On Tue, Jan 20, 2026 at 11:22:38AM +0000, Leo Yan wrote:
> On Mon, Jan 19, 2026 at 10:18:36AM +0000, Coresight ML wrote:
> > We only currently test with default (all CPUs) or --per-thread mode.
> > Different permutations of the "-C" option can affect decoding so add
> > tests for some of them.

> > Signed-off-by: James Clark <james.clark@linaro.org>
 
> LGTM and verified on Juno board:
 
> Tested-by: Leo Yan <leo.yan@arm.com>

Thanks, applied both patches to perf-tools-next,

- Arnaldo