* [PATCH v1] perf test: Fix inet_pton probe failure due to multiple probes
@ 2026-04-10 0:23 Ian Rogers
2026-04-11 19:37 ` [PATCH v2] perf test: Fix inet_pton probe failure and unroll call graph Ian Rogers
0 siblings, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2026-04-10 0:23 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, James Clark, Collin Funk, Chun-Tse Shao,
linux-perf-users, linux-kernel
When adding a probe for libc's inet_pton, perf probe may create multiple
probe points (e.g., due to inlining or multiple symbol resolutions),
resulting in multiple identical event names being output (e.g.,
`probe_libc:inet_pton_1`).
The script previously used a brittle pipeline (`tail -n +2 | head -n -5`)
and an awk script to extract the event name. When multiple probes were
added, awk would output the event name multiple times, which expanded
to multiple words in bash. This broke the subsequent `perf record` and
`perf probe -d` commands, causing the test to fail with:
`Error: another command except --add is set.`
Fix this by removing the brittle `tail/head` commands and appending
`| sort -u` to the awk extraction. This ensures that only a single,
unique event name is captured, regardless of how many probe points
are created.
Assisted-by: Gemini:gemini-3.1-pro-preview
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index ab99bef556bf..b717063f70c2 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -22,9 +22,9 @@ event_pattern='probe_libc:inet_pton(_[[:digit:]]+)?'
add_libc_inet_pton_event() {
- event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | tail -n +2 | head -n -5 | \
+ event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | \
awk -v ep="$event_pattern" -v l="$libc" '$0 ~ ep && $0 ~ \
- ("\\(on inet_pton in " l "\\)") {print $1}')
+ ("\\(on inet_pton in " l "\\)") {print $1}' | sort -u)
if [ $? -ne 0 ] || [ -z "$event_name" ] ; then
printf "FAIL: could not add event\n"
--
2.53.0.1213.gd9a14994de-goog
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2] perf test: Fix inet_pton probe failure and unroll call graph
2026-04-10 0:23 [PATCH v1] perf test: Fix inet_pton probe failure due to multiple probes Ian Rogers
@ 2026-04-11 19:37 ` Ian Rogers
2026-04-13 12:11 ` Thomas Richter
2026-04-14 17:11 ` Namhyung Kim
0 siblings, 2 replies; 4+ messages in thread
From: Ian Rogers @ 2026-04-11 19:37 UTC (permalink / raw)
To: acme, namhyung
Cc: irogers, adrian.hunter, alexander.shishkin, collin.funk1, ctshao,
james.clark, jolsa, linux-kernel, linux-perf-users, mingo,
peterz
When adding a probe for libc's inet_pton, perf probe may create multiple
probe points (e.g., due to inlining or multiple symbol resolutions),
resulting in multiple identical event names being output (e.g.,
`probe_libc:inet_pton_1`).
The script previously used a brittle pipeline (`tail -n +2 | head -n -5`)
and an awk script to extract the event name. When multiple probes were
added, awk would output the event name multiple times, which expanded
to multiple words in bash. This broke the subsequent `perf record` and
`perf probe -d` commands, causing the test to fail with:
`Error: another command except --add is set.`
Fix this by removing the brittle `tail/head` commands and appending
`| head -n 1` to the awk extraction. This ensures that only a single,
unique event name is captured, regardless of how many probe points
are created.
Additionally, the test artificially limited the backtrace size via
`max-stack=4` and did not specify dwarf call graphs for non-s390x
architectures. In newer libc versions where `inet_pton` is nested
deeper or compiled without frame pointers, `perf script` failed to resolve
the backtrace up to `/bin/ping`. Fix this by explicitly collecting
dwarf call-graphs for all architectures and increasing `max-stack` to 8.
Assisted-by: Gemini:gemini-3.1-pro-preview
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index ab99bef556bf..eca629ee83f0 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -22,9 +22,9 @@ event_pattern='probe_libc:inet_pton(_[[:digit:]]+)?'
add_libc_inet_pton_event() {
- event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | tail -n +2 | head -n -5 | \
+ event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | \
awk -v ep="$event_pattern" -v l="$libc" '$0 ~ ep && $0 ~ \
- ("\\(on inet_pton in " l "\\)") {print $1}')
+ ("\\(on inet_pton in " l "\\)") {print $1}' | head -n 1)
if [ $? -ne 0 ] || [ -z "$event_name" ] ; then
printf "FAIL: could not add event\n"
@@ -40,12 +40,12 @@ trace_libc_inet_pton_backtrace() {
echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
case "$(uname -m)" in
s390x)
- eventattr='call-graph=dwarf,max-stack=4'
+ eventattr='call-graph=dwarf,max-stack=8'
echo "((__GI_)?getaddrinfo|text_to_binary_address)\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
echo "(gaih_inet|main)\+0x[[:xdigit:]]+[[:space:]]\(inlined|.*/bin/ping.*\)$" >> $expected
;;
*)
- eventattr='max-stack=4'
+ eventattr='call-graph=dwarf,max-stack=8'
echo ".*(\+0x[[:xdigit:]]+|\[unknown\])[[:space:]]\(.*/bin/ping.*\)$" >> $expected
;;
esac
--
2.53.0.1213.gd9a14994de-goog
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] perf test: Fix inet_pton probe failure and unroll call graph
2026-04-11 19:37 ` [PATCH v2] perf test: Fix inet_pton probe failure and unroll call graph Ian Rogers
@ 2026-04-13 12:11 ` Thomas Richter
2026-04-14 17:11 ` Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Richter @ 2026-04-13 12:11 UTC (permalink / raw)
To: Ian Rogers, acme, namhyung
Cc: adrian.hunter, alexander.shishkin, collin.funk1, ctshao,
james.clark, jolsa, linux-kernel, linux-perf-users, mingo,
peterz
On 4/11/26 21:37, Ian Rogers wrote:
> When adding a probe for libc's inet_pton, perf probe may create multiple
> probe points (e.g., due to inlining or multiple symbol resolutions),
> resulting in multiple identical event names being output (e.g.,
> `probe_libc:inet_pton_1`).
>
> The script previously used a brittle pipeline (`tail -n +2 | head -n -5`)
> and an awk script to extract the event name. When multiple probes were
> added, awk would output the event name multiple times, which expanded
> to multiple words in bash. This broke the subsequent `perf record` and
> `perf probe -d` commands, causing the test to fail with:
> `Error: another command except --add is set.`
>
> Fix this by removing the brittle `tail/head` commands and appending
> `| head -n 1` to the awk extraction. This ensures that only a single,
> unique event name is captured, regardless of how many probe points
> are created.
>
> Additionally, the test artificially limited the backtrace size via
> `max-stack=4` and did not specify dwarf call graphs for non-s390x
> architectures. In newer libc versions where `inet_pton` is nested
> deeper or compiled without frame pointers, `perf script` failed to resolve
> the backtrace up to `/bin/ping`. Fix this by explicitly collecting
> dwarf call-graphs for all architectures and increasing `max-stack` to 8.
>
> Assisted-by: Gemini:gemini-3.1-pro-preview
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> index ab99bef556bf..eca629ee83f0 100755
> --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> @@ -22,9 +22,9 @@ event_pattern='probe_libc:inet_pton(_[[:digit:]]+)?'
>
> add_libc_inet_pton_event() {
>
> - event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | tail -n +2 | head -n -5 | \
> + event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | \
> awk -v ep="$event_pattern" -v l="$libc" '$0 ~ ep && $0 ~ \
> - ("\\(on inet_pton in " l "\\)") {print $1}')
> + ("\\(on inet_pton in " l "\\)") {print $1}' | head -n 1)
>
> if [ $? -ne 0 ] || [ -z "$event_name" ] ; then
> printf "FAIL: could not add event\n"
> @@ -40,12 +40,12 @@ trace_libc_inet_pton_backtrace() {
> echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
> case "$(uname -m)" in
> s390x)
> - eventattr='call-graph=dwarf,max-stack=4'
> + eventattr='call-graph=dwarf,max-stack=8'
> echo "((__GI_)?getaddrinfo|text_to_binary_address)\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
> echo "(gaih_inet|main)\+0x[[:xdigit:]]+[[:space:]]\(inlined|.*/bin/ping.*\)$" >> $expected
> ;;
> *)
> - eventattr='max-stack=4'
> + eventattr='call-graph=dwarf,max-stack=8'
> echo ".*(\+0x[[:xdigit:]]+|\[unknown\])[[:space:]]\(.*/bin/ping.*\)$" >> $expected
> ;;
> esac
for s390:
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
--
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] perf test: Fix inet_pton probe failure and unroll call graph
2026-04-11 19:37 ` [PATCH v2] perf test: Fix inet_pton probe failure and unroll call graph Ian Rogers
2026-04-13 12:11 ` Thomas Richter
@ 2026-04-14 17:11 ` Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2026-04-14 17:11 UTC (permalink / raw)
To: acme, Ian Rogers
Cc: adrian.hunter, alexander.shishkin, collin.funk1, ctshao,
james.clark, jolsa, linux-kernel, linux-perf-users, mingo,
peterz
On Sat, 11 Apr 2026 12:37:05 -0700, Ian Rogers wrote:
> When adding a probe for libc's inet_pton, perf probe may create multiple
> probe points (e.g., due to inlining or multiple symbol resolutions),
> resulting in multiple identical event names being output (e.g.,
> `probe_libc:inet_pton_1`).
>
> The script previously used a brittle pipeline (`tail -n +2 | head -n -5`)
> and an awk script to extract the event name. When multiple probes were
> added, awk would output the event name multiple times, which expanded
> to multiple words in bash. This broke the subsequent `perf record` and
> `perf probe -d` commands, causing the test to fail with:
> `Error: another command except --add is set.`
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-14 17:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-10 0:23 [PATCH v1] perf test: Fix inet_pton probe failure due to multiple probes Ian Rogers
2026-04-11 19:37 ` [PATCH v2] perf test: Fix inet_pton probe failure and unroll call graph Ian Rogers
2026-04-13 12:11 ` Thomas Richter
2026-04-14 17:11 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®