summaryrefslogtreecommitdiff
path: root/tools/perf/tests/shell
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2026-09-28 11:26:00 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2026-10-01 17:48:25 +0200
commitc7525971318aec314e037a9ac0006ecc072bd5e6 (patch)
tree8d4b0d1ec2551d97df8cf926aeb2ea7e2e98145f /tools/perf/tests/shell
parent2e679233920068e1df5820fad830c17f88ac9538 (diff)
downloadlinux-next-c7525971318aec314e037a9ac0006ecc072bd5e6.tar.gz
linux-next-c7525971318aec314e037a9ac0006ecc072bd5e6.zip
perf test probe_vfs_getname: Scope probe name to PID and make non-exclusive
The fixed vfs_getname probe name collides between parallel tests, and the cleanup deletes every probe:vfs_getname* probe. Name the probe getname_flags_$$, match it exactly, and remove it from an exit trap. Not starting with vfs_getname also stops perf trace, which opens every probe:vfs_getname* event, from pinning it. Remove the exclusive tag from probe_vfs_getname.sh and record+script_probe_vfs_getname.sh. trace+probe_vfs_getname.sh needs perf trace to find its probe, so it uses vfs_getname_$$ and stays exclusive. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/shell')
-rw-r--r--tools/perf/tests/shell/lib/probe_vfs_getname.sh25
-rwxr-xr-xtools/perf/tests/shell/probe_vfs_getname.sh3
-rwxr-xr-xtools/perf/tests/shell/record+script_probe_vfs_getname.sh16
-rwxr-xr-xtools/perf/tests/shell/trace+probe_vfs_getname.sh5
4 files changed, 39 insertions, 10 deletions
diff --git a/tools/perf/tests/shell/lib/probe_vfs_getname.sh b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
index a4230a83bcae..57a59ae7d4ae 100644
--- a/tools/perf/tests/shell/lib/probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/lib/probe_vfs_getname.sh
@@ -1,15 +1,32 @@
#!/bin/bash
# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
-perf probe -l 2>&1 | grep -q probe:vfs_getname
+# Scoped to the pid for parallel runs, and not "vfs_getname*" so that perf
+# trace's probe:vfs_getname* wildcard doesn't open, and so pin, the probe.
+: "${vfs_getname:=getname_flags_$$}"
+
+# The probes added, including _1, _2... for inlined copies of getname_flags.
+probes_vfs_getname() {
+ perf probe -l 2>/dev/null | awk '{print $1}' |
+ grep -E "^probe:${vfs_getname}(_[[:digit:]]+)?$"
+}
+
+probes_vfs_getname > /dev/null
had_vfs_getname=$?
cleanup_probe_vfs_getname() {
if [ $had_vfs_getname -eq 1 ] ; then
- perf probe -q -d probe:vfs_getname*
+ local probe
+ for probe in $(probes_vfs_getname); do
+ perf probe -q -d "$probe"
+ done
fi
}
+# A pid scoped probe is never reused, so remove it however the test exits.
+trap cleanup_probe_vfs_getname exit
+trap 'exit 1' term int
+
add_probe_vfs_getname() {
add_probe_verbose=$1
if [ $had_vfs_getname -eq 1 ] ; then
@@ -41,8 +58,8 @@ add_probe_vfs_getname() {
return 2
fi
- perf probe -q "vfs_getname=${func}:${line} pathname=result->name:string" || \
- perf probe $add_probe_verbose "vfs_getname=${func}:${line} pathname=filename:ustring" || return 1
+ perf probe -q "${vfs_getname}=${func}:${line} pathname=result->name:string" || \
+ perf probe $add_probe_verbose "${vfs_getname}=${func}:${line} pathname=filename:ustring" || return 1
fi
}
diff --git a/tools/perf/tests/shell/probe_vfs_getname.sh b/tools/perf/tests/shell/probe_vfs_getname.sh
index 36dc319eea0e..c40e5f3f0825 100755
--- a/tools/perf/tests/shell/probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/probe_vfs_getname.sh
@@ -1,6 +1,5 @@
#!/bin/bash
-# Add vfs_getname probe to get syscall args filenames (exclusive)
-
+# Add vfs_getname probe to get syscall args filenames
# SPDX-License-Identifier: GPL-2.0
# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
diff --git a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
index ce20663601dc..16dbbcfc0e40 100755
--- a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Use vfs_getname probe to get syscall args filenames (exclusive)
+# Use vfs_getname probe to get syscall args filenames
# Uses the 'perf test shell' library to add probe:vfs_getname to the system
# then use it with 'perf record' using 'touch' to write to a temp file, then
@@ -15,22 +15,30 @@ skip_if_no_perf_probe || exit 2
[ "$(id -u)" = 0 ] || exit 2
. "$(dirname "$0")/lib/probe_vfs_getname.sh"
+# shellcheck disable=SC2154 # vfs_getname is assigned in lib/probe_vfs_getname.sh
record_open_file() {
echo "Recording open file:"
# Check presence of libtraceevent support to run perf record
- skip_no_probe_record_support "probe:vfs_getname*"
+ skip_no_probe_record_support
if [ $? -eq 2 ]; then
echo "WARN: Skipping test record_open_file. No libtraceevent support"
return 2
fi
- perf record -o ${perfdata} -e probe:vfs_getname\* touch $file
+ # Name the probes, a "${vfs_getname}*" glob would match longer pids.
+ local events
+ events=$(probes_vfs_getname | paste -sd, -)
+ if [ -z "${events}" ] ; then
+ echo "FAIL: no ${vfs_getname} probe to record"
+ return 1
+ fi
+ perf record -o ${perfdata} -e "${events}" touch $file
}
perf_script_filenames() {
echo "Looking at perf.data file for vfs_getname records for the file we touched:"
perf script -i ${perfdata} | \
- grep -E " +touch +[0-9]+ +\[[0-9]+\] +[0-9]+\.[0-9]+: +probe:vfs_getname[_0-9]*: +\([[:xdigit:]]+\) +pathname=\"${file}\""
+ grep -E " +touch +[0-9]+ +\[[0-9]+\] +[0-9]+\.[0-9]+: +probe:${vfs_getname}(_[0-9]+)?: +\([[:xdigit:]]+\) +pathname=\"${file}\""
}
add_probe_vfs_getname
diff --git a/tools/perf/tests/shell/trace+probe_vfs_getname.sh b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
index 28d3aa8a9e33..ab13801d9e99 100755
--- a/tools/perf/tests/shell/trace+probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
@@ -10,12 +10,17 @@
# SPDX-License-Identifier: GPL-2.0
# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
+# Exclusive as, without BPF, any perf trace opens all probe:vfs_getname* events
+# and so would pin this test's probe.
+
. "$(dirname $0)"/lib/probe.sh
skip_if_no_perf_probe || exit 2
skip_if_no_perf_trace || exit 2
[ "$(id -u)" = 0 ] || exit 2
+# shellcheck disable=SC2034 # consumed by lib/probe_vfs_getname.sh
+vfs_getname="vfs_getname_$$"
. "$(dirname $0)"/lib/probe_vfs_getname.sh
trace_open_vfs_getname() {