Skip to content

perf symbols: skip livepatch symbols

Joe Lawrence linux-perf-users live-patching lkml 2 versions – Applied

Status from this message: Applied to perf-tools-next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 4 repliesApplied
  2. v11 patch 1 replySuperseded

Changes in v2 from the cover letter

- 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()").

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/2perf symbols: skip livepatch symbols when loading kallsymstools/perf/util/symbol.c tools/perf/util/symbol.h+14 -20 replies
2/2perf symbols: skip livepatch symbols in kcore_copy kallsyms processingtools/perf/util/symbol-elf.c+4 -00 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchBen ProcknowPetr Mladek
SeriesA-b
1/2Reported-and-tested-by
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

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

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()").

v1: https://lore.kernel.org/linux-perf-users/[email protected]/T/#t

Joe Lawrence (2):
perf symbols: skip livepatch symbols when loading kallsyms perf symbols: skip livepatch symbols in kcore_copy kallsyms processing

 tools/perf/util/symbol-elf.c |  4 ++++
 tools/perf/util/symbol.c     |  4 ++--
 tools/perf/util/symbol.h     | 12 ++++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)
Signature · 1 line
2.54.0