Skip to content

Commit c7fe4e5

Browse files
captain5050namhyung
authored andcommitted
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>
1 parent 97ab896 commit c7fe4e5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tools/perf/tests/shell/record+probe_libc_inet_pton.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ event_pattern='probe_libc:inet_pton(_[[:digit:]]+)?'
2222

2323
add_libc_inet_pton_event() {
2424

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 | \
2626
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)
2828

2929
if [ $? -ne 0 ] || [ -z "$event_name" ] ; then
3030
printf "FAIL: could not add event\n"
@@ -40,12 +40,12 @@ trace_libc_inet_pton_backtrace() {
4040
echo ".*inet_pton\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
4141
case "$(uname -m)" in
4242
s390x)
43-
eventattr='call-graph=dwarf,max-stack=4'
43+
eventattr='call-graph=dwarf,max-stack=8'
4444
echo "((__GI_)?getaddrinfo|text_to_binary_address)\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
4545
echo "(gaih_inet|main)\+0x[[:xdigit:]]+[[:space:]]\(inlined|.*/bin/ping.*\)$" >> $expected
4646
;;
4747
*)
48-
eventattr='max-stack=4'
48+
eventattr='call-graph=dwarf,max-stack=8'
4949
echo ".*(\+0x[[:xdigit:]]+|\[unknown\])[[:space:]]\(.*/bin/ping.*\)$" >> $expected
5050
;;
5151
esac

0 commit comments

Comments
 (0)