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, steve@abita.co, rishil1999@outlook.com,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH perf-tools-next v3 0/4] perf trace: Symbolise kernel virtual addresses and function pointers
Date: Thu, 20 Aug 2026 17:10:56 -0400 [thread overview]
Message-ID: <20260820211100.649142-1-atomlin@atomlin.com> (raw)
When inspecting kernel execution flows using perf trace (e.g., when
monitoring workqueues, delayed work items, timer callbacks, etc.),
tracepoint payload arguments containing raw kernel virtual addresses are
currently rendered as hexadecimal values (e.g., 0xffffffff81234567).
This requires manual symbol lookups against /proc/kallsyms or vmlinux to
identify the underlying kernel function being executed.
This patch series enhances perf trace by introducing kernel virtual address
and function pointer symbolisation using perf's native symbol engine (i.e.,
machine__find_kernel_symbol()).
Before:
workqueue:workqueue_execute_end(work: 0xffffffffab2f1420, function: 0xffffffffa8046b50)
After:
workqueue:workqueue_execute_end(work: 0xffff8ac2c420f270, function: wb_update_bandwidth_workfn)
Patch 1 introduces the syscall_arg__scnprintf_ksym() (SCA_KSYM) beautifier,
which resolves virtual addresses via machine__find_kernel_symbol(),
formatting them as symbol_name+offset (or "NULL", with a graceful
hexadecimal fallback upon lookup failure).
Patch 2 updates event format initialisation in
syscall_arg_fmt__init_array() to automatically assign SCA_KSYM to
tracepoint fields typed as function pointers (such as typedefs ending in
"_func_t" or "_fn", or function prototypes matching "(*)"). It also
registers common function pointer, callback, and callsite field names
(e.g., "func", "function", "callback", "action", "handler", "caller",
"location", "call_site") in syscall_arg_fmts__by_name[], and removes the
legacy trace__field_is_ip() hex override in trace__fprintf_tp_fields().
Patch 3 extends BTF pretty-printing in trace__btf_scnprintf() with
btf_is_func_ptr() to automatically traverse BTF type hierarchies (including
nested typedefs and qualifiers) and route kernel function pointer arguments
to SCA_KSYM when BTF metadata is available, with negative caching to
prevent redundant BTF scans.
Patch 4 adds an automated regression test script, trace_ksym_beautifier.sh,
under tools/perf/tests/shell/ to verify symbolisation across both default
kallsyms and BTF routing paths.
Changes since v2:
- Populated syscall_arg_fmts__by_name[] with common function pointer,
callback, handler, and callsite field names ("action", "call_site",
"callback", "caller", "callsite", "cb", "fn", "func", "function",
"handler", "location")
- Checked syscall_arg_fmt__find_by_name() prior to generic pointer
fallbacks in syscall_arg_fmt__init_array(), and dropped the inline
64-bit size check to ensure 32-bit and cross-platform compatibility
- Removed legacy trace__field_is_ip() in trace__fprintf_tp_fields() to
allow "call_site" and "caller_ip" to be beautified with SCA_KSYM rather
than being forced to raw hexadecimal
- Simplified btf_is_func_ptr() to remove the internal pointer requirement,
correctly identifying bare prototype typedefs as function pointers
- Prevented pointer enums (e.g., "enum foo *") from being misclassified
and formatted as scalar enum values in
syscall_arg_fmt__cache_btf_type(), trace__btf_scnprintf(), and
syscall_arg__strtoul_btf_type()
- Added negative caching (btf_type_cached) to struct syscall_arg_fmt to
avoid repeated BTF searches on every event for unresolvable or primitive
types
- Widened btf_enum_scnprintf() to accept unsigned long val, eliminating
narrowing truncation of 64-bit values to 32-bit signed integers
- Fixed trace_ksym_beautifier.sh:
- Quoted "$0" to support directory paths containing spaces
- Captured output in memory to eliminate temporary file leaks on early
skip
- Hardened regex validation to require valid C symbol identifiers and
reject raw hexadecimal addresses
- Used '%s' format specifiers in printf to prevent format string
injection
- Link to v2: https://lore.kernel.org/lkml/20260816205921.576365-1-atomlin@atomlin.com/
Changes since v1:
- Fixed reference leak of struct map in syscall_arg__scnprintf_ksym() by
calling map__put() prior to returning Removed unreachable and erroneous
entries ("action", "callsite", "call_site", "fn", "function", "work")
from syscall_arg_fmts__by_name[]
- Restricted name-based SCA_KSYM auto-assignment in
syscall_arg_fmt__init_array() to pointer or 64-bit address fields,
preventing misclassification of non-pointer integer fields
- Updated btf_is_func_ptr() to fully unwrap typedefs and type modifiers
below pointer targets
- Fixed BTF type name matching in syscall_arg_fmt__cache_btf_type() to
handle leading modifiers and strip trailing pointer asterisks before
lookup
- Synchronised arg->val with val in trace__btf_scnprintf() and widened val
to unsigned long, fixing erroneous "NULL" output
- Added shell test script,
tools/perf/tests/shell/trace_ksym_beautifier.sh, to verify kernel symbol
beautification for both default kallsyms and BTF routing
- Link to v1: https://lore.kernel.org/lkml/20260815233651.527936-1-atomlin@atomlin.com/
Aaron Tomlin (4):
perf trace: Introduce kernel symbol beautifier for virtual addresses
perf trace: Auto-assign kernel symbol beautifier to function pointer
fields
perf trace: Enhance BTF type formatting to symbolise kernel function
pointers
perf tests: Add shell test for kernel symbol beautifier
tools/perf/builtin-trace.c | 187 ++++++++++++------
tools/perf/tests/shell/trace_btf_general.sh | 2 +-
.../perf/tests/shell/trace_ksym_beautifier.sh | 43 ++++
tools/perf/trace/beauty/beauty.h | 3 +
4 files changed, 178 insertions(+), 57 deletions(-)
create mode 100755 tools/perf/tests/shell/trace_ksym_beautifier.sh
--
2.55.0
next reply other threads:[~2026-08-20 21:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 21:10 Aaron Tomlin [this message]
2026-08-20 21:10 ` [PATCH perf-tools-next v3 1/4] perf trace: Introduce kernel symbol beautifier for virtual addresses Aaron Tomlin
2026-08-20 21:10 ` [PATCH perf-tools-next v3 2/4] perf trace: Auto-assign kernel symbol beautifier to function pointer fields Aaron Tomlin
2026-08-20 21:10 ` [PATCH perf-tools-next v3 3/4] perf trace: Enhance BTF type formatting to symbolise kernel function pointers Aaron Tomlin
2026-08-20 21:11 ` [PATCH perf-tools-next v3 4/4] perf tests: Add shell test for kernel symbol beautifier 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=20260820211100.649142-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=rishil1999@outlook.com \
--cc=sean@ashe.io \
--cc=steve@abita.co \
/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