perf test uprobe_from_different_cu: Scope probe name to PID

'perf probe' names the event after the function and binary, so concurrent
runs, as with 'perf test -r3', all add probe_testfile:foo and all but one
fail with 'event "foo" already exists'. Name the event foo_$$.

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>
This commit is contained in:
Ian Rogers 2026-09-28 11:26:05 -07:00 committed by Arnaldo Carvalho de Melo
parent 816737751b
commit 4aa0d84669

View File

@ -17,12 +17,15 @@ fi
temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX)
# Scope to the pid, otherwise every run adds the same probe_testfile:foo.
probe_name="foo_$$"
cleanup()
{
trap - EXIT TERM INT
if [[ "${temp_dir}" =~ ^/tmp/perf-uprobe-different-cu-sh.*$ ]]; then
echo "--- Cleaning up ---"
perf probe -x ${temp_dir}/testfile -d foo || true
perf probe -x ${temp_dir}/testfile -d ${probe_name} || true
rm -f "${temp_dir}/"*
rmdir "${temp_dir}"
fi
@ -83,6 +86,6 @@ gcc -g -Og -c ${temp_dir}/testfile-main.c -o ${temp_dir}/testfile-main.o
gcc -g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o
perf probe -x ${temp_dir}/testfile --funcs foo | grep "foo"
perf probe -x ${temp_dir}/testfile foo
perf probe -x ${temp_dir}/testfile ${probe_name}=foo
cleanup