From: Ian Rogers <irogers@google.com>
To: "Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@kernel.org>, "Ian Rogers" <irogers@google.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"James Clark" <james.clark@linaro.org>,
"John Garry" <john.g.garry@oracle.com>,
"Will Deacon" <will@kernel.org>, "Leo Yan" <leo.yan@linux.dev>,
"Guo Ren" <guoren@kernel.org>, "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
"Zecheng Li" <zecheng@google.com>,
"Tianyou Li" <tianyou.li@intel.com>,
"Thomas Falcon" <thomas.falcon@intel.com>,
"Julia Lawall" <Julia.Lawall@inria.fr>,
"Suchit Karunakaran" <suchitkarunakaran@gmail.com>,
"Athira Rajeev" <atrajeev@linux.ibm.com>,
"Aditya Bodkhe" <aditya.b1@linux.ibm.com>,
"Howard Chu" <howardchu95@gmail.com>,
"Krzysztof Łopatowski" <krzysztof.m.lopatowski@gmail.com>,
"Dr. David Alan Gilbert" <linux@treblig.org>,
"Shimin Guo" <shimin.guo@skydio.com>,
"Sergei Trofimovich" <slyich@gmail.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org,
linux-riscv@lists.infradead.org
Subject: [PATCH v3 00/12] perf annotate arch clean up
Date: Thu, 22 Jan 2026 13:35:04 -0800 [thread overview]
Message-ID: <20260122213516.671089-1-irogers@google.com> (raw)
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
<suchitkarunakaran@gmail.com>). Try to repro annotate test crash
(James Clark) but suspect it was addressed in the other reference
count fixes.
https://lore.kernel.org/lkml/20260122165407.561888-1-irogers@google.com/
v1: https://lore.kernel.org/lkml/20260122073127.375139-1-irogers@google.com/
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%)
--
2.52.0.457.g6b5491de43-goog
WARNING: multiple messages have this Message-ID (diff)
From: Ian Rogers <irogers@google.com>
To: "Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@kernel.org>, "Ian Rogers" <irogers@google.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"James Clark" <james.clark@linaro.org>,
"John Garry" <john.g.garry@oracle.com>,
"Will Deacon" <will@kernel.org>, "Leo Yan" <leo.yan@linux.dev>,
"Guo Ren" <guoren@kernel.org>, "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
"Zecheng Li" <zecheng@google.com>,
"Tianyou Li" <tianyou.li@intel.com>,
"Thomas Falcon" <thomas.falcon@intel.com>,
"Julia Lawall" <Julia.Lawall@inria.fr>,
"Suchit Karunakaran" <suchitkarunakaran@gmail.com>,
"Athira Rajeev" <atrajeev@linux.ibm.com>,
"Aditya Bodkhe" <aditya.b1@linux.ibm.com>,
"Howard Chu" <howardchu95@gmail.com>,
"Krzysztof Łopatowski" <krzysztof.m.lopatowski@gmail.com>,
"Dr. David Alan Gilbert" <linux@treblig.org>,
"Shimin Guo" <shimin.guo@skydio.com>,
"Sergei Trofimovich" <slyich@gmail.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org,
linux-riscv@lists.infradead.org
Subject: [PATCH v3 00/12] perf annotate arch clean up
Date: Thu, 22 Jan 2026 13:35:04 -0800 [thread overview]
Message-ID: <20260122213516.671089-1-irogers@google.com> (raw)
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
<suchitkarunakaran@gmail.com>). Try to repro annotate test crash
(James Clark) but suspect it was addressed in the other reference
count fixes.
https://lore.kernel.org/lkml/20260122165407.561888-1-irogers@google.com/
v1: https://lore.kernel.org/lkml/20260122073127.375139-1-irogers@google.com/
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%)
--
2.52.0.457.g6b5491de43-goog
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2026-01-22 21:35 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 21:35 Ian Rogers [this message]
2026-01-22 21:35 ` [PATCH v3 00/12] perf annotate arch clean up Ian Rogers
2026-01-22 21:35 ` [PATCH v3 01/12] perf header: Fix memory leaks in process_cpu_domain_info Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 02/12] perf annotate: Fix args leak of map_symbol Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 03/12] perf maps: Fix reference count leak in maps__find_ams Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 04/12] perf disasm: Constify use of struct arch Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 05/12] perf disasm: Constify use of struct ins_op Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 06/12] perf disasm: Constify use of struct ins Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 07/12] perf disasm: Rework the string arch__is to use the ELF machine Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 08/12] perf disasm: Don't include C files from the arch directory Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 09/12] perf disasm: Refactor ins__is_call/jump to avoid exposing arch ins_ops Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 10/12] perf map_symbol: Switch from holding maps to holding thread Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-22 21:35 ` [PATCH v3 11/12] perf disasm: Refactor arch__find and initialization of arch structs Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-23 17:47 ` Arnaldo Carvalho de Melo
2026-01-23 17:47 ` Arnaldo Carvalho de Melo
2026-01-22 21:35 ` [PATCH v3 12/12] perf disasm: Minor layout tweaks for struct arch Ian Rogers
2026-01-22 21:35 ` Ian Rogers
2026-01-23 11:02 ` [PATCH v3 00/12] perf annotate arch clean up James Clark
2026-01-23 11:02 ` James Clark
2026-01-23 16:30 ` Ian Rogers
2026-01-23 16:30 ` Ian Rogers
2026-01-23 16:47 ` Arnaldo Carvalho de Melo
2026-01-23 16:47 ` Arnaldo Carvalho de Melo
2026-03-24 6:07 ` patchwork-bot+linux-riscv
2026-03-24 6:07 ` patchwork-bot+linux-riscv
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260122213516.671089-1-irogers@google.com \
--to=irogers@google.com \
--cc=Julia.Lawall@inria.fr \
--cc=acme@kernel.org \
--cc=aditya.b1@linux.ibm.com \
--cc=adrian.hunter@intel.com \
--cc=alex@ghiti.fr \
--cc=alexander.shishkin@linux.intel.com \
--cc=aou@eecs.berkeley.edu \
--cc=atrajeev@linux.ibm.com \
--cc=guoren@kernel.org \
--cc=howardchu95@gmail.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=krzysztof.m.lopatowski@gmail.com \
--cc=leo.yan@linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@treblig.org \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=shimin.guo@skydio.com \
--cc=slyich@gmail.com \
--cc=suchitkarunakaran@gmail.com \
--cc=thomas.falcon@intel.com \
--cc=tianyou.li@intel.com \
--cc=will@kernel.org \
--cc=zecheng@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.