Re: [PATCH v2 0/2] perf symbols: skip livepatch symbols

From
Petr Mladek <pmladek@suse.com>
Date
2026-07-02 07:59:36
Also in
linux-perf-users, lkml
Reply to
Namhyung Kim, 2026-07-01
On Wed 2026-07-01 16:54:02, Namhyung Kim wrote:
Hello,

On Fri, Jun 26, 2026 at 05:21:38PM -0400, Joe Lawrence wrote:
quoted
This patchset fixes two minor perf bugs when livepatches containing
special so-called livepatch symbols are loaded.  In both cases, perf
should ignore these symbols as they resolve as relocations to kernel
addresses and not module space.

- Patch 1 fixes `perf test 1`
- Patch 2 fixes `perf record --kcore` bloat


Testing notes
=============

("perf symbols: skip livepatch symbols when loading kallsyms"):

  Without patch:
  ./tools/perf/perf test 1
    1: vmlinux symtab matches kallsyms                     : FAILED!

  With patch:
  ./tools/perf/perf test 1
    1: vmlinux symtab matches kallsyms                     : Ok

("perf symbols: skip livepatch symbols in kcore_copy")

  1. Baseline = pre-patch perf, no livepatch
  ------------------------------------------
  
  $ ./tools/perf/perf record --kcore -a -o /tmp/baseline.data -- sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.221 MB /tmp/baseline.data (1717 samples) ]
  
  $ tree --noreport -h /tmp/baseline.data
  /tmp/baseline.data
  |-- [ 235K]  data
  `-- [   50]  kcore_dir
      |-- [  11M]  kallsyms
      |-- [  25M]  kcore
      `-- [ 1.7K]  modules
  
  
  2. Bloated kcore = pre-patch perf, with livepatch
  -------------------------------------------------
  
  $ insmod kpatch-5_14_0-570_94_1-1-3.ko
  $ ./tools/perf/perf record --kcore -a -o /tmp/klp-bloated.data -- sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.274 MB /tmp/klp-bloated.data (2757 samples) ]
  
  $ tree --noreport  -h /tmp/klp-bloated.data
  /tmp/klp-bloated.data
  |-- [ 288K]  data
  `-- [   50]  kcore_dir
      |-- [  11M]  kallsyms
      |-- [  68M]  kcore
      `-- [ 1.8K]  modules
  
  
  3. Post-fix = patched perf, with livepatch
  ------------------------------------------
  
  [ kpatch-5_14_0-570_94_1-1-3.ko still loaded from test (2) ]
  
  $ ./tools/perf/perf record --kcore -a -o /tmp/postfix.data -- sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.274 MB /tmp/postfix.data (2763 samples) ]
  
  $ tree --noreport -h /tmp/postfix.data
  /tmp/postfix.data
  |-- [ 289K]  data
  `-- [   50]  kcore_dir
      |-- [  11M]  kallsyms
      |-- [  25M]  kcore
      `-- [ 1.8K]  modules

Changes
=======

v2:
- Move klp symbol check into tools/perf/util/symbol.h alongside similar
  is_ignored_kernel_symbol() check [Petr]
- Use KLP_SYM_PREFIX instead of inlining it [Petr]
- Add similar check to kcore_copy__process_kallsyms() [Sashiko]

- Note: Sashiko flagged a pre-existing off-by-one in kallsyms__parse()
  where the symbol-name loop could write past symbol_name[] on overlong
  entries. That issue is unrelated to livepatch symbols and was already
  fixed by Rui Qi's 68018df3f55e ("perf: Fix off-by-one stack buffer
  overflow in kallsyms__parse()").
Petr, are you ok with this change?
Yup, both changes look good to me. Feel free to use:

Acked-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr
Thread (7 messages) 7 messages, 3 authors, last reply 2026-07-04
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help