Skip to content

perf annotate arch clean up

Ian Rogers linux-arm-kernel linux-csky linux-perf-users linux-riscv lkml 3 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest12 patches 4 repliesIn review 11 of 12 applied
  2. v212 patches 2 repliesSuperseded
  3. v111 patches 5 repliesSuperseded

Patches in v3 11 of 12 applied

#Subject and filesSizeRepliesApplied
1/12perf header: Fix memory leaks in process_cpu_domain_infotools/perf/util/header.c+4 -130 repliesApplied
2/12perf annotate: Fix args leak of map_symboltools/perf/arch/loongarch/annotate/instructions.c tools/perf/arch/s390/annotate/instructions.c tools/perf/util/annotate.c +4 more+47 -380 repliesApplied
3/12perf maps: Fix reference count leak in maps__find_amstools/perf/util/maps.c+1 -00 repliesApplied
4/12perf disasm: Constify use of struct archtools/perf/arch/arm64/annotate/instructions.c tools/perf/arch/loongarch/annotate/instructions.c tools/perf/arch/s390/annotate/instructions.c +8 more+67 -580 repliesApplied
5/12perf disasm: Constify use of struct ins_optools/perf/arch/arm/annotate/instructions.c tools/perf/arch/arm64/annotate/instructions.c tools/perf/arch/csky/annotate/instructions.c +8 more+51 -510 repliesApplied
6/12perf disasm: Constify use of struct instools/perf/arch/arm64/annotate/instructions.c tools/perf/arch/x86/annotate/instructions.c tools/perf/util/disasm.c +1 more+40 -240 repliesApplied
7/12perf disasm: Rework the string arch__is to use the ELF machinetools/perf/util/annotate-data.c tools/perf/util/annotate.c tools/perf/util/capstone.c +3 more+27 -210 repliesApplied
8/12perf disasm: Don't include C files from the arch directorytools/perf/util/Build tools/perf/util/annotate-arch/Build tools/perf/util/annotate-arch/annotate-arc.c +12 more+289 -2380 repliesApplied
9/12perf disasm: Refactor ins__is_call/jump to avoid exposing arch ins_opstools/perf/util/annotate-arch/annotate-loongarch.c tools/perf/util/annotate-arch/annotate-s390.c tools/perf/util/disasm.c +1 more+12 -80 repliesApplied
10/12perf map_symbol: Switch from holding maps to holding threadtools/perf/ui/browsers/annotate.c tools/perf/ui/browsers/hists.c tools/perf/util/addr_location.c +15 more+47 -440 repliesApplied
11/12perf disasm: Refactor arch__find and initialization of arch structstools/perf/ui/browsers/annotate.c tools/perf/util/annotate-arch/annotate-arc.c tools/perf/util/annotate-arch/annotate-arm.c +13 more+279 -2421 reply
12/12perf disasm: Minor layout tweaks for struct archtools/perf/util/disasm.h+4 -40 repliesApplied

Reviews trailers per patch

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

PatchJames Clark
SeriesR-b
1/12
2/12
3/12
4/12
5/12
6/12
7/12
8/12
9/12
10/12
11/12
12/12

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

Read the v3 thread

Cover letter [PATCH v3 00/12] perf annotate arch clean up

3 initial memory leak fix patches for perf annotate.

Move the disasm.c #included arch files into a new util/annotate-arch directory. Make the code compile standalone. Try to better encapsulate architecture specific code within the files and with a arch__new_<arch> function that allows additional data to be associated with the struct arch using the standard container_of trick.

Make the lookup of struct arch use the ELF machine gather from a thread rather than an evsel. For example, the evsel can't determine the difference between EM_386 and EM_X86_64 so generally the latter has currently been used. This means the dwarf registers are off as register 1 is CX with EM_386 and DX with EM_X86_64. To facilitate this change map_symbol is refactored to use a struct thread rather than a struct maps, the maps being obtainable from the thread.

To make in and out arguments clearer, for safety, etc. try to constify struct arch and its related structs.

v3: Fix arch initialization on arm, arm64, powerpc and sparc as spotted by Suchit
Karunakaranw.

v2: Add a patch to fix a domain info memory leak that was blocking
leak sanitizer analysis. Fix more map_symbol leaks or uses after reference count put (Suchit Karunakaranw <[email protected]>). Try to repro annotate test crash (James Clark) but suspect it was addressed in the other reference count fixes.
https://lore.kernel.org/lkml/[email protected]/

v1: https://lore.kernel.org/lkml/[email protected]/

Ian Rogers (12):
perf header: Fix memory leaks in process_cpu_domain_info perf annotate: Fix args leak of map_symbol
perf maps: Fix reference count leak in maps__find_ams
perf disasm: Constify use of struct arch
perf disasm: Constify use of struct ins_op
perf disasm: Constify use of struct ins
perf disasm: Rework the string arch__is to use the ELF machine perf disasm: Don't include C files from the arch directory perf disasm: Refactor ins__is_call/jump to avoid exposing arch ins_ops perf map_symbol: Switch from holding maps to holding thread perf disasm: Refactor arch__find and initialization of arch structs perf disasm: Minor layout tweaks for struct arch

 tools/perf/arch/arc/annotate/instructions.c   |  11 -
 .../perf/arch/riscv64/annotate/instructions.c |  36 --
 tools/perf/ui/browsers/annotate.c             |   6 +-
 tools/perf/ui/browsers/hists.c                |   3 +-
 tools/perf/util/Build                         |   1 +
 tools/perf/util/addr_location.c               |   4 -
 tools/perf/util/addr_location.h               |   1 -
 tools/perf/util/annotate-arch/Build           |  11 +
 tools/perf/util/annotate-arch/annotate-arc.c  |  18 +
 .../annotate-arch/annotate-arm.c}             |  50 +-
 .../annotate-arch/annotate-arm64.c}           |  59 +--
 .../annotate-arch/annotate-csky.c}            |  29 +-
 .../annotate-arch/annotate-loongarch.c}       |  71 +--
 .../annotate-arch/annotate-mips.c}            |  29 +-
 .../annotate-arch/annotate-powerpc.c}         | 127 +++++-
 .../util/annotate-arch/annotate-riscv64.c     |  41 ++
 .../annotate-arch/annotate-s390.c}            |  70 +--
 .../annotate-arch/annotate-sparc.c}           |  28 +-
 .../annotate-arch/annotate-x86.c}             |  89 ++--
 tools/perf/util/annotate-data.c               |  12 +-
 tools/perf/util/annotate-data.h               |   2 +-
 tools/perf/util/annotate.c                    |  88 ++--
 tools/perf/util/annotate.h                    |  10 +-
 tools/perf/util/callchain.c                   |  12 +-
 tools/perf/util/capstone.c                    |  18 +-
 tools/perf/util/db-export.c                   |   1 -
 tools/perf/util/disasm.c                      | 428 +++++++-----------
 tools/perf/util/disasm.h                      |  95 ++--
 tools/perf/util/event.c                       |   2 -
 tools/perf/util/header.c                      |  17 +-
 tools/perf/util/hist.c                        |  18 +-
 tools/perf/util/llvm.c                        |   8 +-
 tools/perf/util/machine.c                     |  13 +-
 tools/perf/util/map_symbol.c                  |   5 +-
 tools/perf/util/map_symbol.h                  |   3 +-
 tools/perf/util/maps.c                        |   1 +
 tools/perf/util/sort.c                        |   2 +-
 tools/perf/util/unwind-libdw.c                |   2 +-
 tools/perf/util/unwind-libunwind-local.c      |   2 +-
 39 files changed, 775 insertions(+), 648 deletions(-)
 delete mode 100644 tools/perf/arch/arc/annotate/instructions.c
 delete mode 100644 tools/perf/arch/riscv64/annotate/instructions.c
 create mode 100644 tools/perf/util/annotate-arch/Build
 create mode 100644 tools/perf/util/annotate-arch/annotate-arc.c
 rename tools/perf/{arch/arm/annotate/instructions.c => util/annotate-arch/annotate-arm.c} (59%)
 rename tools/perf/{arch/arm64/annotate/instructions.c => util/annotate-arch/annotate-arm64.c} (70%)
 rename tools/perf/{arch/csky/annotate/instructions.c => util/annotate-arch/annotate-csky.c} (67%)
 rename tools/perf/{arch/loongarch/annotate/instructions.c => util/annotate-arch/annotate-loongarch.c} (60%)
 rename tools/perf/{arch/mips/annotate/instructions.c => util/annotate-arch/annotate-mips.c} (59%)
 rename tools/perf/{arch/powerpc/annotate/instructions.c => util/annotate-arch/annotate-powerpc.c} (73%)
 create mode 100644 tools/perf/util/annotate-arch/annotate-riscv64.c
 rename tools/perf/{arch/s390/annotate/instructions.c => util/annotate-arch/annotate-s390.c} (66%)
 rename tools/perf/{arch/sparc/annotate/instructions.c => util/annotate-arch/annotate-sparc.c} (85%)
 rename tools/perf/{arch/x86/annotate/instructions.c => util/annotate-arch/annotate-x86.c} (93%)
Signature · 1 line
2.52.0.457.g6b5491de43-goog