Re: [PATCH perf-tools-next v2 0/4] perf trace: Symbolise kernel virtual addresses and function pointers
Ian Rogers <[email protected]>
| Newsgroups | org.kernel.vger.linux-perf-users,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAP-5=fXfpP_GN=DqeOMrrLUyy6xJ6GEcVo0TVkej9f0KTPfK+Q@mail.gmail.com> |
On Sun, Aug 16, 2026 at 1:59 PM Aaron Tomlin <[email protected]> wrote: > > 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 perfs 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) This looks great and a test! I noticed Sashiko feedback on patches 2, 3 and 4. It looked appropriate and actionable. I'm looking forward to the next version and testing! Thanks, Ian > 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 "(*)"), as well as > pointer or 64-bit address fields named "fn", "function", "callsite", or > "call_site". > > 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. > > 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 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/[email protected]/ > > 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 | 103 ++++++++++++++++-- > tools/perf/tests/shell/trace_btf_general.sh | 2 +- > .../perf/tests/shell/trace_ksym_beautifier.sh | 52 +++++++++ > tools/perf/trace/beauty/beauty.h | 3 + > 4 files changed, 148 insertions(+), 12 deletions(-) > create mode 100755 tools/perf/tests/shell/trace_ksym_beautifier.sh > > -- > 2.55.0 >