mirror of
https://github.com/torvalds/linux.git
synced 2026-04-28 03:22:27 -04:00
The detection of uncore_imc may happen for free running PMUs and the
clockticks event may be present on uncore_clock. Rewrite the test to
detect duplicated/deduplicated events from perf list, not hardcoded to
uncore_imc.
If perf stat fails then assume it is permissions and skip the test.
Committer testing:
Before:
root@x1:~# perf test -vv uniquifyi
96: perf stat events uniquifying:
--- start ---
test child forked, pid 220851
stat event uniquifying test
grep: Unmatched [, [^, [:, [., or [=
Event is not uniquified [Failed]
perf stat -e clockticks -A -o /tmp/__perf_test.stat_output.X7ChD -- true
# started on Fri Sep 19 16:48:38 2025
Performance counter stats for 'system wide':
CPU0 2,310,956 uncore_clock/clockticks/
0.001746771 seconds time elapsed
---- end(-1) ----
96: perf stat events uniquifying : FAILED!
root@x1:~#
After:
root@x1:~# perf test -vv uniquifyi
96: perf stat events uniquifying:
--- start ---
test child forked, pid 222366
Uniquification of PMU sysfs events test
Testing event uncore_imc_free_running/data_read/ is uniquified to uncore_imc_free_running_0/data_read/
Testing event uncore_imc_free_running/data_total/ is uniquified to uncore_imc_free_running_0/data_total/
Testing event uncore_imc_free_running/data_write/ is uniquified to uncore_imc_free_running_0/data_write/
Testing event uncore_imc_free_running/data_read/ is uniquified to uncore_imc_free_running_1/data_read/
Testing event uncore_imc_free_running/data_total/ is uniquified to uncore_imc_free_running_1/data_total/
Testing event uncore_imc_free_running/data_write/ is uniquified to uncore_imc_free_running_1/data_write/
---- end(0) ----
96: perf stat events uniquifying : Ok
root@x1:~#
Fixes: 070b315333 ("perf test: Restrict uniquifying test to machines with 'uncore_imc'")
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Chun-Tse Shao <ctshao@google.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
67 lines
1.8 KiB
Bash
Executable File
67 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# perf stat events uniquifying
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
set -e
|
|
|
|
err=0
|
|
stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
|
|
|
|
cleanup() {
|
|
rm -f "${stat_output}"
|
|
|
|
trap - EXIT TERM INT
|
|
}
|
|
|
|
trap_cleanup() {
|
|
echo "Unexpected signal in ${FUNCNAME[1]}"
|
|
cleanup
|
|
exit 1
|
|
}
|
|
trap trap_cleanup EXIT TERM INT
|
|
|
|
test_event_uniquifying() {
|
|
echo "Uniquification of PMU sysfs events test"
|
|
|
|
# Read events from perf list with and without -v. With -v the duplicate PMUs
|
|
# aren't deduplicated. Note, json events are listed by perf list without a
|
|
# PMU.
|
|
read -ra pmu_events <<< "$(perf list --raw pmu)"
|
|
read -ra pmu_v_events <<< "$(perf list -v --raw pmu)"
|
|
# For all non-deduplicated events.
|
|
for pmu_v_event in "${pmu_v_events[@]}"; do
|
|
# If the event matches an event in the deduplicated events then it musn't
|
|
# be an event with duplicate PMUs, continue the outer loop.
|
|
for pmu_event in "${pmu_events[@]}"; do
|
|
if [[ "$pmu_v_event" == "$pmu_event" ]]; then
|
|
continue 2
|
|
fi
|
|
done
|
|
# Strip the suffix from the non-deduplicated event's PMU.
|
|
event=$(echo "$pmu_v_event" | sed -E 's/_[0-9]+//')
|
|
for pmu_event in "${pmu_events[@]}"; do
|
|
if [[ "$event" == "$pmu_event" ]]; then
|
|
echo "Testing event ${event} is uniquified to ${pmu_v_event}"
|
|
if ! perf stat -e "$event" -A -o ${stat_output} -- true; then
|
|
echo "Error running perf stat for event '$event' [Skip]"
|
|
if [ $err = 0 ]; then
|
|
err=2
|
|
fi
|
|
continue
|
|
fi
|
|
# Ensure the non-deduplicated event appears in the output.
|
|
if ! grep -q "${pmu_v_event}" "${stat_output}"; then
|
|
echo "Uniquification of PMU sysfs events test [Failed]"
|
|
cat "${stat_output}"
|
|
err=1
|
|
fi
|
|
break
|
|
fi
|
|
done
|
|
done
|
|
}
|
|
|
|
test_event_uniquifying
|
|
cleanup
|
|
exit $err
|