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

Configure Feed

Select the types of activity you want to include in your feed.

perf test: Fix inet_pton probe failure and unroll call graph

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>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
c7fe4e56 97ab8968

+4 -4
+4 -4
tools/perf/tests/shell/record+probe_libc_inet_pton.sh
··· 22 22 23 23 add_libc_inet_pton_event() { 24 24 25 - event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | tail -n +2 | head -n -5 | \ 25 + event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | \ 26 26 awk -v ep="$event_pattern" -v l="$libc" '$0 ~ ep && $0 ~ \ 27 - ("\\(on inet_pton in " l "\\)") {print $1}') 27 + ("\\(on inet_pton in " l "\\)") {print $1}' | head -n 1) 28 28 29 29 if [ $? -ne 0 ] || [ -z "$event_name" ] ; then 30 30 printf "FAIL: could not add event\n" ··· 40 40 echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected 41 41 case "$(uname -m)" in 42 42 s390x) 43 - eventattr='call-graph=dwarf,max-stack=4' 43 + eventattr='call-graph=dwarf,max-stack=8' 44 44 echo "((__GI_)?getaddrinfo|text_to_binary_address)\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected 45 45 echo "(gaih_inet|main)\+0x[[:xdigit:]]+[[:space:]]\(inlined|.*/bin/ping.*\)$" >> $expected 46 46 ;; 47 47 *) 48 - eventattr='max-stack=4' 48 + eventattr='call-graph=dwarf,max-stack=8' 49 49 echo ".*(\+0x[[:xdigit:]]+|\[unknown\])[[:space:]]\(.*/bin/ping.*\)$" >> $expected 50 50 ;; 51 51 esac