perf trace: Fix noise and signed formatting of __probe_ip in bare dynamic probes
PATCH 1/1 perf trace: Fix noise and signed formatting of __probe_ip in bare dynamic probes
When a dynamic probe is created without explicitly requested arguments via perf probe --add, the Ftrace subsystem automatically appends "__probe_ip" to the tracepoint format to record the instruction pointer.
Currently, perf trace prints this implicit field by default. Furthermore, because the formatting logic defaults to a standard signed integer representation, the kernel space memory address is erroneously displayed as a meaningless negative integer.
❯ sudo ./perf trace --event probe:proc_sys_open --max-events 1
0.000 ps/1316543 probe:proc_sys_open(__probe_ip: -1406056956)This patch addresses the user experience by combining two refinements:
1. "__probe_ip" is now hidden from the standard output, as its presence adds no contextual value for a bare probe.
2. If the user explicitly requests verbose output (--verbose), "__probe_ip" is intercepted and properly formatted as a hexadecimal kernel address, restoring its utility for debugging inline function hits.
❯ sudo ./perf trace --event probe:proc_sys_open --max-events 1
0.000 ps/1314074 probe:proc_sys_open()
❯ sudo ./perf trace --verbose --event probe:proc_sys_open --max-events 1 Using CPUID GenuineIntel-6-8E-C
mmap size 528384B
0.000 ps/1314366 probe:proc_sys_open(__probe_ip: 0xffffffffac314604)
--- tools/perf/builtin-trace.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
tools/perf/builtin-trace.c +17 -0
@@ -3234,6 +3234,23 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,if (val ==0 && !trace->show_zeros && !arg->show_zero && arg->strtoul !=STUL_BTF_TYPE )continue ; +/* +* __probe_ip is implicitly added to bare dynamic probes. +* Suppress it by default to avoid cluttering the output. +* If verbose mode is enabled, ensure it is formatted as a +* hexadecimal memory address rather than a signed integer. +*/ +if (!strcmp (field->name,"__probe_ip" )) { +if (!verbose) +continue ; + + printed +=scnprintf (bf + printed, size - printed, +"%s%s: %#016llx" , printed ? +", " :"" , field->name, + (unsigned long long )val); +continue ; + } + printed +=scnprintf (bf + printed, size - printed,"%s" , printed ?", " :"" );if (trace->show_arg_names)
Signature · 1 line
2.51.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The patch hardcodes the `__probe_ip` argument name in the output format, ignoring the…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch hardcodes the __probe_ip argument name in the output format, ignoring the trace->show_arg_names configuration. --
commit 52fd2385bfe746191bd8b95bc76fff9e349f4450
Author: Aaron Tomlin <[email protected]>
perf trace: Fix noise and signed formatting of __probe_ip in bare dynamic probes
This commit hides the implicit __probe_ip field in bare dynamic probes by default, and formats it as a hexadecimal kernel address when verbose mode is enabled.
Quoted 4 lines
tools/perf/builtin-trace.c +0
-0
[ ... ]
Quoted 8 lines
tools/perf/builtin-trace.c +4
-0@@ -3234,6 +3234,23 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,if (val ==0 && !trace->show_zeros && !arg->show_zero && arg->strtoul !=STUL_BTF_TYPE )continue ; +/* +* __probe_ip is implicitly added to bare dynamic probes. +* Suppress it by default to avoid cluttering the output. +* If verbose mode is enabled, ensure it is formatted as a
tools/perf/builtin-trace.c static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, · line 3250
Quoted 10 lines
tools/perf/builtin-trace.c +10
-0+* hexadecimal memory address rather than a signed integer. +*/ +if (!strcmp (field->name,"__probe_ip" )) { +if (!verbose) +continue ; + + printed +=scnprintf (bf + printed, size - printed, +"%s%s: %#016llx" , printed ? +", " :"" , field->name, + (unsigned long long )val);
[Severity: Medium]
Does this hardcoded format string bypass the trace->show_arg_names configuration?
In trace__fprintf_tp_fields(), other arguments dynamically check if their names should be printed:
if (trace->show_arg_names)
printed += scnprintf(bf + printed, size - printed, "%s: ", field->name);By explicitly formatting "%s%s: %#016llx" using field->name, it looks like __probe_ip will always print its argument name here, even if perf trace is executed with --no-arg-names alongside --verbose.
Quoted 6 lines
tools/perf/builtin-trace.c +3
-0+continue ; + } + printed +=scnprintf (bf + printed, size - printed,"%s" , printed ?", " :"" );if (trace->show_arg_names)
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Arnaldo Carvalho de Melo
maintainerQuoted 46 lines · On Fri, Jun 12, 2026 at 10:16:01PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch hardcodes the__probe_ipargument name in the output format, ignoring thetrace->show_arg_namesconfiguration. --commit
52fd2385bfe746191bd8b95bc76fff9e349f4450
Author: Aaron Tomlin <[email protected]>perf trace: Fix noise and signed formatting of
__probe_ipin bare dynamic probesThis commit hides the implicit
__probe_ipfield in bare dynamic probes by default, and formats it as a hexadecimal kernel address when verbose mode is enabled.Quoted 4 lines
tools/perf/builtin-trace.c +0
-0[ ... ]
Quoted 8 lines
tools/perf/builtin-trace.c +4
-0@@ -3234,6 +3234,23 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,if (val ==0 && !trace->show_zeros && !arg->show_zero && arg->strtoul !=STUL_BTF_TYPE )continue ; +/* +* __probe_ip is implicitly added to bare dynamic probes. +* Suppress it by default to avoid cluttering the output. +* If verbose mode is enabled, ensure it is formatted as a tools/perf/builtin-trace.c static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, · line 3250
Quoted 10 lines
tools/perf/builtin-trace.c +10
-0+* hexadecimal memory address rather than a signed integer. +*/ +if (!strcmp (field->name,"__probe_ip" )) { +if (!verbose) +continue ; + + printed +=scnprintf (bf + printed, size - printed, +"%s%s: %#016llx" , printed ? +", " :"" , field->name, + (unsigned long long )val);[Severity: Medium]
Does this hardcoded format string bypass thetrace->show_arg_namesconfiguration?In
trace__fprintf_tp_fields(), other arguments dynamically check if their names should be printed:
Quoted 6 lines
if (trace->show_arg_names) printed += scnprintf(bf + printed, size - printed, "%s: ", field->name);By explicitly formatting "%s%s: %#016llx" using
field->name, it looks like__probe_ipwill always print its argument name here, even if perf trace is executed with --no-arg-names alongside --verbose.
I think this is a valid concern, please make it follow the trace->show_arg_names for consistency.
This is a nice improvement, thanks for working on it,
- Arnaldo
Quoted 9 lines
Quoted 6 lines
tools/perf/builtin-trace.c +3
-0+continue ; + } + printed +=scnprintf (bf + printed, size - printed,"%s" , printed ?", " :"" );if (trace->show_arg_names)Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 10 lines
[Severity: Medium]
Does this hardcoded format string bypass thetrace->show_arg_namesconfiguration?In
trace__fprintf_tp_fields(), other arguments dynamically check if their names should be printed:if (trace->show_arg_names) printed += scnprintf(bf + printed, size - printed, "%s: ", field->name);
Quoted 8 lines
Quoted 3 lines
By explicitly formatting "%s%s: %#016llx" using
field->name, it looks like__probe_ipwill always print its argument name here, even if perf trace is executed with --no-arg-names alongside --verbose.I think this is a valid concern, please make it follow the
trace->show_arg_namesfor consistency.This is a nice improvement, thanks for working on it,
Hi Arnaldo,
Thanks for the prompt review and feedback.
I've addressed the 'show_arg_names' consistency in the next iteration. You can find the updated version here [1].
[1] https://lore.kernel.org/lkml/[email protected]/
Kind regards,
Signature · 1 line
Aaron Tomlin