From: Aaron Tomlin <atomlin@atomlin.com>
To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
namhyung@kernel.org
Cc: mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
james.clark@linaro.org, howardchu95@gmail.com,
atomlin@atomlin.com, neelx@suse.com, chjohnst@mail.com,
sean@ashe.io, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] perf trace: Format instruction pointer fields as hexadecimal
Date: Sun, 19 Jul 2026 15:10:00 -0400 [thread overview]
Message-ID: <20260719191000.441985-1-atomlin@atomlin.com> (raw)
Provide a helper function trace__field_is_ip() in
trace__fprintf_tp_fields() to ensure that tracepoint fields representing
instruction pointers such as "__probe_ip", "caller_ip", and
"call_site" are always formatted as hexadecimal memory addresses rather
than signed integers.
For example, when running a kmem:kfree tracepoint:
# perf trace --show-cpu --event kmem:kfree --max-event 1
Before this change, "call_site" was represented as a signed integer:
0.000 [003] xfce4-terminal/2201 kmem:kfree(call_site: -1714572588, ptr: 0xffff8afee0303000)
After this change, "call_site" is correctly represented in hexadecimal:
0.000 [003] xfce4-terminal/2201 kmem:kfree(call_site: 0xffffffff99cf1194, ptr: 0xffff8afee0303000)
This improves the readability of perf trace output by making code
addresses straightforward to parse and map to kernel symbols.
Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
---
tools/perf/builtin-trace.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 0142a16830de..207d46d073c1 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -3223,6 +3223,13 @@ static unsigned char bitmap_byte(const unsigned long *mask, int byte_idx)
return b_val;
}
+static bool trace__field_is_ip(const char *name)
+{
+ return !strcmp(name, "__probe_ip") ||
+ !strcmp(name, "caller_ip") ||
+ !strcmp(name, "call_site");
+}
+
static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sample *sample,
struct thread *thread, void *augmented_args, int augmented_args_size)
{
@@ -3235,6 +3242,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sample *
size_t printed = 0, btf_printed;
unsigned long val;
u8 bit = 1;
+ bool is_probe_ip;
struct syscall_arg syscall_arg = {
.augmented = {
.size = augmented_args_size,
@@ -3322,9 +3330,14 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sample *
* 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.
+ *
+ * caller_ip and call_site are also expected to be instruction
+ * pointers and should always be represented in hexadecimal.
*/
- if (evsel__is_probe(evsel) && !strcmp(field->name, "__probe_ip")) {
- if (!verbose)
+ is_probe_ip = evsel__is_probe(evsel) && !strcmp(field->name, "__probe_ip");
+
+ if (is_probe_ip || trace__field_is_ip(field->name)) {
+ if (is_probe_ip && !verbose)
continue;
printed += scnprintf(bf + printed, size - printed,
base-commit: ef06fd2704cafbcf04e220f2103ca5488508f13e
--
2.54.0
next reply other threads:[~2026-07-19 19:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-19 19:10 Aaron Tomlin [this message]
2026-07-20 1:50 ` [PATCH] perf trace: Format instruction pointer fields as hexadecimal Aaron Tomlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260719191000.441985-1-atomlin@atomlin.com \
--to=atomlin@atomlin.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=chjohnst@mail.com \
--cc=howardchu95@gmail.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=neelx@suse.com \
--cc=peterz@infradead.org \
--cc=sean@ashe.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox