perf test: Speed up some tests using perf list
authorNamhyung Kim <namhyung@kernel.org>
Wed, 16 Oct 2024 06:56:54 +0000 (23:56 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 17 Oct 2024 16:55:58 +0000 (09:55 -0700)
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>
tools/perf/tests/shell/lib/coresight.sh
tools/perf/tests/shell/lock_contention.sh
tools/perf/tests/shell/record.sh
tools/perf/tests/shell/test_arm_coresight.sh
tools/perf/tests/shell/test_arm_coresight_disasm.sh
tools/perf/tests/shell/test_arm_spe.sh
tools/perf/tests/shell/test_arm_spe_fork.sh
tools/perf/tests/shell/test_intel_pt.sh
tools/perf/tests/shell/trace+probe_vfs_getname.sh

index 11ed2c25ed912649fa6a4d847a634274656f84c4..184d62e7e5bdf9f4139c247048500143e47b460d 100644 (file)
@@ -18,7 +18,7 @@ BIN="$DIR/$TEST"
 # If the test tool/binary does not exist and is executable then skip the test
 if ! test -x "$BIN"; then exit 2; fi
 # If CoreSight is not available, skip the test
-perf list cs_etm | grep -q cs_etm || exit 2
+perf list pmu | grep -q cs_etm || exit 2
 DATD="."
 # If the data dir env is set then make the data dir use that instead of ./
 if test -n "$PERF_TEST_CORESIGHT_DATADIR"; then
index c1ec5762215ba43081fc848243ddf32fe1a82ac0..30d195d4c62f74d09c0b7d02928c28681bcedf10 100755 (executable)
@@ -27,7 +27,7 @@ check() {
                exit
        fi
 
-       if ! perf list | grep -q lock:contention_begin; then
+       if ! perf list tracepoint | grep -q lock:contention_begin; then
                echo "[Skip] No lock contention tracepoints"
                err=2
                exit
index 8d6366d96883edb3b50d26421407a227c660363c..3eee72242290d1fb0c875f5fa133e470a42bc60a 100755 (executable)
@@ -94,7 +94,7 @@ test_per_thread() {
 
 test_register_capture() {
   echo "Register capture test"
-  if ! perf list | grep -q 'br_inst_retired.near_call'
+  if ! perf list pmu | grep -q 'br_inst_retired.near_call'
   then
     echo "Register capture test [Skipped missing event]"
     return
index 3302ea0b96723b1a1267613e960a520f47a36a2d..6b8c4831eedc6f10f46bc7a714830fad18fa830a 100755 (executable)
@@ -12,7 +12,7 @@
 glb_err=0
 
 skip_if_no_cs_etm_event() {
-       perf list | grep -q 'cs_etm//' && return 0
+       perf list pmu | grep -q 'cs_etm//' && return 0
 
        # cs_etm event doesn't exist
        return 2
index af63e3757cb0a93067fff5d75940fce6bfe03e25..dba086a40d8467219c19a03935e6bfc72d3e6254 100755 (executable)
@@ -8,7 +8,7 @@
 # the script. Test all 3 parts are working correctly by running the script.
 
 skip_if_no_cs_etm_event() {
-       perf list | grep -q 'cs_etm//' && return 0
+       perf list pmu | grep -q 'cs_etm//' && return 0
 
        # cs_etm event doesn't exist
        return 2
index 03d5c7d12ee53d07eb917d51a6d7f01141d360ad..6c21fb1f10d8f1293a03d8c23e190b53bc8f4eac 100755 (executable)
@@ -9,7 +9,7 @@
 # German Gomez <german.gomez@arm.com>, 2021
 
 skip_if_no_arm_spe_event() {
-       perf list | grep -E -q 'arm_spe_[0-9]+//' && return 0
+       perf list pmu | grep -E -q 'arm_spe_[0-9]+//' && return 0
 
        # arm_spe event doesn't exist
        return 2
index 1a7e6a82d0e34124954ccf302ab0ab5490d41e46..8efeef9fb9564a563c37fc717c716ec7f6f54808 100755 (executable)
@@ -5,7 +5,7 @@
 # German Gomez <german.gomez@arm.com>, 2022
 
 skip_if_no_arm_spe_event() {
-       perf list | grep -E -q 'arm_spe_[0-9]+//' && return 0
+       perf list pmu | grep -E -q 'arm_spe_[0-9]+//' && return 0
        return 2
 }
 
index 723ec501f99abe036d8cee1cd7d1182ea6aee52c..bf9017b812aa6ed9a1819a8f86374d3619c24c6f 100755 (executable)
@@ -5,7 +5,7 @@
 set -e
 
 # Skip if no Intel PT
-perf list | grep -q 'intel_pt//' || exit 2
+perf list pmu | grep -q 'intel_pt//' || exit 2
 
 shelldir=$(dirname "$0")
 # shellcheck source=lib/waiting.sh
index 3146a1eece0789ae7e75e0ccf12a42951441a12a..97b4b9cd23784c8933170689145da54d78ea80f9 100755 (executable)
@@ -19,7 +19,7 @@ skip_if_no_perf_trace || exit 2
 . "$(dirname $0)"/lib/probe_vfs_getname.sh
 
 trace_open_vfs_getname() {
-       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')"
+       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')"
        perf trace -e $evts touch $file 2>&1 | \
        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]+$"
 }