[PATCH v4 0/2] perf: Add is_ignored_kernel_symbol() for kernel symbol filtering

Rui Qi posted 2 patches 2 days, 9 hours ago
tools/perf/util/machine.c    | 18 +++++++++++++++++-
tools/perf/util/symbol-elf.c | 10 ++++++++--
tools/perf/util/symbol.c     |  4 ++--
tools/perf/util/symbol.h     | 15 +++++++++++++++
4 files changed, 42 insertions(+), 5 deletions(-)
[PATCH v4 0/2] perf: Add is_ignored_kernel_symbol() for kernel symbol filtering
Posted by Rui Qi 2 days, 9 hours ago
The perf tool currently has ad-hoc logic to filter out ELF mapping
symbols scattered across multiple files. ARM, AArch64 and RISC-V each
have their own inline checks in dso__load_sym_internal(), and kallsym
processing has yet another check for ARM module symbols.

This patch series introduces a single is_ignored_kernel_symbol() inline
helper in symbol.h and converts the kernel symbol handling paths to use it.
The helper covers the existing "$" prefix used by ARM, AArch64 and RISC-V,
and also adds the x86 local symbol prefixes so that perf stays consistent
with the kernel's own is_mapping_symbol() logic.

Changes in v4:
  - Rename the helper from is_mapping_symbol() to is_ignored_kernel_symbol()
    to make its purpose clearer.
  - Split the single patch into two logical patches:
    - Patch 1 introduces the helper and applies it to kallsyms and ksymbol events.
    - Patch 2 applies the helper to the ELF loading path for kernel DSOs.

Link (v3): https://lore.kernel.org/all/20260507071103.2772577-1-qirui.001@bytedance.com/

Changes in v3:
  - Add is_mapping_symbol() check for kernel modules in dso__load_sym_internal()
  - Add is_mapping_symbol() check in machine__process_ksymbol_unregister()

Link (v2): https://lore.kernel.org/all/20260506073820.2419087-1-qirui.001@bytedance.com/

Changes in v2:
  - Only apply is_mapping_symbol() filtering to kernel symbols (kallsyms
    and ksymbol events), not to user-space symbols from ELF files,
    BFD libraries, or perf map files.  This avoids incorrectly
    discarding valid user-space function names that start with '$',
    which is a legal character in identifiers for many languages
    (e.g., Java, Scala) and compilers (GCC).
  - Move the mapping symbol check in machine__process_ksymbol_register()
    to the beginning of the function, before any map/dso allocation
    or insertion, to avoid leaving empty maps in the kernel map tree.

Link (v1): https://lore.kernel.org/all/20260504090609.1801880-1-qirui.001@bytedance.com/

Rui Qi (2):
  perf: Extract is_ignored_kernel_symbol() for kernel mapping symbol
    filtering
  perf: Apply is_ignored_kernel_symbol() filter in ELF loading path for
    kernel DSOs

 tools/perf/util/machine.c    | 18 +++++++++++++++++-
 tools/perf/util/symbol-elf.c | 10 ++++++++--
 tools/perf/util/symbol.c     |  4 ++--
 tools/perf/util/symbol.h     | 15 +++++++++++++++
 4 files changed, 42 insertions(+), 5 deletions(-)

-- 
2.20.1