* [PATCH] perf llvm: Clean up after a failed disassembly
@ 2026-03-03 23:00 Peter Collingbourne
2026-03-03 23:29 ` Ian Rogers
0 siblings, 1 reply; 4+ messages in thread
From: Peter Collingbourne @ 2026-03-03 23:00 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Collingbourne, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, James Clark,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-perf-users, linux-kernel, llvm
An error returned from a failed backend will cause perf to call the next
backend. If the error happens mid-function, e.g. due to an unrecognized
instruction, we will end up with duplicated instructions in the output
unless the backend that failed deletes any instructions that it created
before failing. The capstone backend was already doing this but the LLVM
backend was not; fix it.
Link: https://linux-review.googlesource.com/id/I377eef3cd662ab98fbcd69e5004a259fa3d7aa06
Signed-off-by: Peter Collingbourne <pcc@google.com>
---
tools/perf/util/llvm.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/perf/util/llvm.c b/tools/perf/util/llvm.c
index 0d126d233c019..87fceae8488a7 100644
--- a/tools/perf/util/llvm.c
+++ b/tools/perf/util/llvm.c
@@ -261,6 +261,15 @@ int symbol__disassemble_llvm(const char *filename, struct symbol *sym,
ret = 0;
err:
+ if (ret != 0) {
+ struct disasm_line *tmp;
+
+ list_for_each_entry_safe(dl, tmp, ¬es->src->source,
+ al.node) {
+ list_del(&dl->al.node);
+ disasm_line__free(dl);
+ }
+ }
LLVMDisasmDispose(disasm);
free(code_buf);
free(line_storage);
--
2.53.0.473.g4a7958ca14-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf llvm: Clean up after a failed disassembly
2026-03-03 23:00 [PATCH] perf llvm: Clean up after a failed disassembly Peter Collingbourne
@ 2026-03-03 23:29 ` Ian Rogers
2026-03-04 21:10 ` Peter Collingbourne
0 siblings, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2026-03-03 23:29 UTC (permalink / raw)
To: Peter Collingbourne
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Adrian Hunter, James Clark, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-perf-users, linux-kernel, llvm
On Tue, Mar 3, 2026 at 3:00 PM Peter Collingbourne <pcc@google.com> wrote:
>
> An error returned from a failed backend will cause perf to call the next
> backend. If the error happens mid-function, e.g. due to an unrecognized
> instruction, we will end up with duplicated instructions in the output
> unless the backend that failed deletes any instructions that it created
> before failing. The capstone backend was already doing this but the LLVM
> backend was not; fix it.
>
> Link: https://linux-review.googlesource.com/id/I377eef3cd662ab98fbcd69e5004a259fa3d7aa06
> Signed-off-by: Peter Collingbourne <pcc@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> tools/perf/util/llvm.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/tools/perf/util/llvm.c b/tools/perf/util/llvm.c
> index 0d126d233c019..87fceae8488a7 100644
> --- a/tools/perf/util/llvm.c
> +++ b/tools/perf/util/llvm.c
> @@ -261,6 +261,15 @@ int symbol__disassemble_llvm(const char *filename, struct symbol *sym,
> ret = 0;
>
> err:
> + if (ret != 0) {
> + struct disasm_line *tmp;
> +
> + list_for_each_entry_safe(dl, tmp, ¬es->src->source,
> + al.node) {
> + list_del(&dl->al.node);
> + disasm_line__free(dl);
> + }
> + }
> LLVMDisasmDispose(disasm);
> free(code_buf);
> free(line_storage);
> --
> 2.53.0.473.g4a7958ca14-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf llvm: Clean up after a failed disassembly
2026-03-03 23:29 ` Ian Rogers
@ 2026-03-04 21:10 ` Peter Collingbourne
2026-03-04 22:05 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 4+ messages in thread
From: Peter Collingbourne @ 2026-03-04 21:10 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Adrian Hunter, James Clark, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-perf-users, linux-kernel, llvm
On Tue, Mar 3, 2026 at 3:29 PM Ian Rogers <irogers@google.com> wrote:
>
> On Tue, Mar 3, 2026 at 3:00 PM Peter Collingbourne <pcc@google.com> wrote:
> >
> > An error returned from a failed backend will cause perf to call the next
> > backend. If the error happens mid-function, e.g. due to an unrecognized
> > instruction, we will end up with duplicated instructions in the output
> > unless the backend that failed deletes any instructions that it created
> > before failing. The capstone backend was already doing this but the LLVM
> > backend was not; fix it.
> >
> > Link: https://linux-review.googlesource.com/id/I377eef3cd662ab98fbcd69e5004a259fa3d7aa06
> > Signed-off-by: Peter Collingbourne <pcc@google.com>
>
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks for the review. I guess this one should have also had
Fixes: 048856817888 ("perf annotate: LLVM-based disassembler")
Peter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf llvm: Clean up after a failed disassembly
2026-03-04 21:10 ` Peter Collingbourne
@ 2026-03-04 22:05 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-03-04 22:05 UTC (permalink / raw)
To: Peter Collingbourne
Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Namhyung Kim,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
James Clark, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, linux-perf-users, linux-kernel, llvm
On Wed, Mar 04, 2026 at 01:10:02PM -0800, Peter Collingbourne wrote:
> On Tue, Mar 3, 2026 at 3:29 PM Ian Rogers <irogers@google.com> wrote:
> >
> > On Tue, Mar 3, 2026 at 3:00 PM Peter Collingbourne <pcc@google.com> wrote:
> > >
> > > An error returned from a failed backend will cause perf to call the next
> > > backend. If the error happens mid-function, e.g. due to an unrecognized
> > > instruction, we will end up with duplicated instructions in the output
> > > unless the backend that failed deletes any instructions that it created
> > > before failing. The capstone backend was already doing this but the LLVM
> > > backend was not; fix it.
> > >
> > > Link: https://linux-review.googlesource.com/id/I377eef3cd662ab98fbcd69e5004a259fa3d7aa06
> > > Signed-off-by: Peter Collingbourne <pcc@google.com>
> >
> > Reviewed-by: Ian Rogers <irogers@google.com>
>
> Thanks for the review. I guess this one should have also had
>
> Fixes: 048856817888 ("perf annotate: LLVM-based disassembler")
Thanks, applied to perf-tools, for v7.0.
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-04 22:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03 23:00 [PATCH] perf llvm: Clean up after a failed disassembly Peter Collingbourne
2026-03-03 23:29 ` Ian Rogers
2026-03-04 21:10 ` Peter Collingbourne
2026-03-04 22:05 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox