Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: Speed up some tests using perf list

On my system, perf list is very slow to print the whole events. I think
there's a performance issue in SDT and uprobes event listing. I noticed
this issue while running perf test on x86 but it takes long to check
some CoreSight event which should be skipped quickly.

Anyway, some test uses perf list to check whether the required event is
available before running the test. The perf list command can take an
argument to specify event class or (glob) pattern. But glob pattern is
only to suppress output for unmatched ones after checking all events.

In this case, specifying event class is better to reduce the number of
events it checks and to avoid buggy subsystems entirely.

No functional changes intended.

Reviewed-by: James Clark <james.clark@linaro.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Carsten Haitzler <carsten.haitzler@arm.com>
Cc: Leo Yan <leo.yan@arm.com>
Link: https://lore.kernel.org/r/20241016065654.269994-1-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

+9 -9
+1 -1
tools/perf/tests/shell/lib/coresight.sh
··· 18 18 # If the test tool/binary does not exist and is executable then skip the test 19 19 if ! test -x "$BIN"; then exit 2; fi 20 20 # If CoreSight is not available, skip the test 21 - perf list cs_etm | grep -q cs_etm || exit 2 21 + perf list pmu | grep -q cs_etm || exit 2 22 22 DATD="." 23 23 # If the data dir env is set then make the data dir use that instead of ./ 24 24 if test -n "$PERF_TEST_CORESIGHT_DATADIR"; then
+1 -1
tools/perf/tests/shell/lock_contention.sh
··· 27 27 exit 28 28 fi 29 29 30 - if ! perf list | grep -q lock:contention_begin; then 30 + if ! perf list tracepoint | grep -q lock:contention_begin; then 31 31 echo "[Skip] No lock contention tracepoints" 32 32 err=2 33 33 exit
+1 -1
tools/perf/tests/shell/record.sh
··· 94 94 95 95 test_register_capture() { 96 96 echo "Register capture test" 97 - if ! perf list | grep -q 'br_inst_retired.near_call' 97 + if ! perf list pmu | grep -q 'br_inst_retired.near_call' 98 98 then 99 99 echo "Register capture test [Skipped missing event]" 100 100 return
+1 -1
tools/perf/tests/shell/test_arm_coresight.sh
··· 12 12 glb_err=0 13 13 14 14 skip_if_no_cs_etm_event() { 15 - perf list | grep -q 'cs_etm//' && return 0 15 + perf list pmu | grep -q 'cs_etm//' && return 0 16 16 17 17 # cs_etm event doesn't exist 18 18 return 2
+1 -1
tools/perf/tests/shell/test_arm_coresight_disasm.sh
··· 8 8 # the script. Test all 3 parts are working correctly by running the script. 9 9 10 10 skip_if_no_cs_etm_event() { 11 - perf list | grep -q 'cs_etm//' && return 0 11 + perf list pmu | grep -q 'cs_etm//' && return 0 12 12 13 13 # cs_etm event doesn't exist 14 14 return 2
+1 -1
tools/perf/tests/shell/test_arm_spe.sh
··· 9 9 # German Gomez <german.gomez@arm.com>, 2021 10 10 11 11 skip_if_no_arm_spe_event() { 12 - perf list | grep -E -q 'arm_spe_[0-9]+//' && return 0 12 + perf list pmu | grep -E -q 'arm_spe_[0-9]+//' && return 0 13 13 14 14 # arm_spe event doesn't exist 15 15 return 2
+1 -1
tools/perf/tests/shell/test_arm_spe_fork.sh
··· 5 5 # German Gomez <german.gomez@arm.com>, 2022 6 6 7 7 skip_if_no_arm_spe_event() { 8 - perf list | grep -E -q 'arm_spe_[0-9]+//' && return 0 8 + perf list pmu | grep -E -q 'arm_spe_[0-9]+//' && return 0 9 9 return 2 10 10 } 11 11
+1 -1
tools/perf/tests/shell/test_intel_pt.sh
··· 5 5 set -e 6 6 7 7 # Skip if no Intel PT 8 - perf list | grep -q 'intel_pt//' || exit 2 8 + perf list pmu | grep -q 'intel_pt//' || exit 2 9 9 10 10 shelldir=$(dirname "$0") 11 11 # shellcheck source=lib/waiting.sh
+1 -1
tools/perf/tests/shell/trace+probe_vfs_getname.sh
··· 19 19 . "$(dirname $0)"/lib/probe_vfs_getname.sh 20 20 21 21 trace_open_vfs_getname() { 22 - evts="$(echo "$(perf list syscalls:sys_enter_open* 2>/dev/null | grep -E 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/')" | sed ':a;N;s:\n:,:g')" 22 + evts="$(echo "$(perf list tracepoint 2>/dev/null | grep -E 'syscalls:sys_enter_open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/')" | sed ':a;N;s:\n:,:g')" 23 23 perf trace -e $evts touch $file 2>&1 | \ 24 24 grep -E " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +\"?${file}\"?, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$" 25 25 }