* [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations @ 2024-08-13 4:06 Ian Rogers 2024-08-13 4:06 ` [PATCH v1 2/2] perf test annotate: Dump trapping test in trap handler Ian Rogers 2024-08-13 14:53 ` [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations Arnaldo Carvalho de Melo 0 siblings, 2 replies; 9+ messages in thread From: Ian Rogers @ 2024-08-13 4:06 UTC (permalink / raw) To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter, Kan Liang, Thomas Richter, Kajol Jain, Athira Rajeev, linux-perf-users, linux-kernel lock__parse calls disasm_line__parse passing &ops->locked.ins.name. Ensure ops->locked.ins.name is freed in lock__delete. Found with lock/leak sanitizer. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/util/disasm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c index 22289003e16d..226d2181f694 100644 --- a/tools/perf/util/disasm.c +++ b/tools/perf/util/disasm.c @@ -566,6 +566,7 @@ static void lock__delete(struct ins_operands *ops) ins_ops__delete(ops->locked.ops); zfree(&ops->locked.ops); + zfree(&ops->locked.ins.name); zfree(&ops->target.raw); zfree(&ops->target.name); } -- 2.46.0.76.ge559c4bf1a-goog ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 2/2] perf test annotate: Dump trapping test in trap handler 2024-08-13 4:06 [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations Ian Rogers @ 2024-08-13 4:06 ` Ian Rogers 2024-08-13 14:53 ` [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations Arnaldo Carvalho de Melo 1 sibling, 0 replies; 9+ messages in thread From: Ian Rogers @ 2024-08-13 4:06 UTC (permalink / raw) To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter, Kan Liang, Thomas Richter, Kajol Jain, Athira Rajeev, linux-perf-users, linux-kernel Help to better identify the location of test failures but dumping the failing test in the trap handler. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/tests/shell/annotate.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/annotate.sh b/tools/perf/tests/shell/annotate.sh index b072d9b97387..2ccf4f1d46b6 100755 --- a/tools/perf/tests/shell/annotate.sh +++ b/tools/perf/tests/shell/annotate.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # perf annotate basic tests # SPDX-License-Identifier: GPL-2.0 @@ -28,6 +28,7 @@ cleanup() { } trap_cleanup() { + echo "Unexpected signal in ${FUNCNAME[1]}" cleanup exit 1 } -- 2.46.0.76.ge559c4bf1a-goog ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations 2024-08-13 4:06 [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations Ian Rogers 2024-08-13 4:06 ` [PATCH v1 2/2] perf test annotate: Dump trapping test in trap handler Ian Rogers @ 2024-08-13 14:53 ` Arnaldo Carvalho de Melo 2024-08-13 16:04 ` Ian Rogers 1 sibling, 1 reply; 9+ messages in thread From: Arnaldo Carvalho de Melo @ 2024-08-13 14:53 UTC (permalink / raw) To: Ian Rogers Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, Thomas Richter, Kajol Jain, Athira Rajeev, linux-perf-users, linux-kernel On Mon, Aug 12, 2024 at 09:06:12PM -0700, Ian Rogers wrote: > lock__parse calls disasm_line__parse passing > &ops->locked.ins.name. Ensure ops->locked.ins.name is freed in > lock__delete. > > Found with lock/leak sanitizer. Applied both patches to perf-tools-next. Thanks, - Arnaldo > Signed-off-by: Ian Rogers <irogers@google.com> > --- > tools/perf/util/disasm.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c > index 22289003e16d..226d2181f694 100644 > --- a/tools/perf/util/disasm.c > +++ b/tools/perf/util/disasm.c > @@ -566,6 +566,7 @@ static void lock__delete(struct ins_operands *ops) > ins_ops__delete(ops->locked.ops); > > zfree(&ops->locked.ops); > + zfree(&ops->locked.ins.name); > zfree(&ops->target.raw); > zfree(&ops->target.name); > } > -- > 2.46.0.76.ge559c4bf1a-goog ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations 2024-08-13 14:53 ` [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations Arnaldo Carvalho de Melo @ 2024-08-13 16:04 ` Ian Rogers 2024-08-13 18:10 ` Arnaldo Carvalho de Melo 0 siblings, 1 reply; 9+ messages in thread From: Ian Rogers @ 2024-08-13 16:04 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, Thomas Richter, Kajol Jain, Athira Rajeev, linux-perf-users, linux-kernel On Tue, Aug 13, 2024 at 7:53 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > On Mon, Aug 12, 2024 at 09:06:12PM -0700, Ian Rogers wrote: > > lock__parse calls disasm_line__parse passing > > &ops->locked.ins.name. Ensure ops->locked.ins.name is freed in > > lock__delete. > > > > Found with lock/leak sanitizer. Ooops, I meant address/leak sanitizer. > Applied both patches to perf-tools-next. Thanks, could you fix the commit message. Thanks, Ian > Thanks, > > - Arnaldo > > > Signed-off-by: Ian Rogers <irogers@google.com> > > --- > > tools/perf/util/disasm.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c > > index 22289003e16d..226d2181f694 100644 > > --- a/tools/perf/util/disasm.c > > +++ b/tools/perf/util/disasm.c > > @@ -566,6 +566,7 @@ static void lock__delete(struct ins_operands *ops) > > ins_ops__delete(ops->locked.ops); > > > > zfree(&ops->locked.ops); > > + zfree(&ops->locked.ins.name); > > zfree(&ops->target.raw); > > zfree(&ops->target.name); > > } > > -- > > 2.46.0.76.ge559c4bf1a-goog ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations 2024-08-13 16:04 ` Ian Rogers @ 2024-08-13 18:10 ` Arnaldo Carvalho de Melo 2024-08-13 19:11 ` Ian Rogers 0 siblings, 1 reply; 9+ messages in thread From: Arnaldo Carvalho de Melo @ 2024-08-13 18:10 UTC (permalink / raw) To: Ian Rogers Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, Thomas Richter, Kajol Jain, Athira Rajeev, linux-perf-users, linux-kernel On Tue, Aug 13, 2024 at 09:04:57AM -0700, Ian Rogers wrote: > On Tue, Aug 13, 2024 at 7:53 AM Arnaldo Carvalho de Melo > <acme@kernel.org> wrote: > > > > On Mon, Aug 12, 2024 at 09:06:12PM -0700, Ian Rogers wrote: > > > lock__parse calls disasm_line__parse passing > > > &ops->locked.ins.name. Ensure ops->locked.ins.name is freed in > > > lock__delete. > > > > > > Found with lock/leak sanitizer. > > Ooops, I meant address/leak sanitizer. > > > Applied both patches to perf-tools-next. > > Thanks, could you fix the commit message. Sure, - Arnaldo ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations 2024-08-13 18:10 ` Arnaldo Carvalho de Melo @ 2024-08-13 19:11 ` Ian Rogers 2024-08-13 20:41 ` Arnaldo Carvalho de Melo 2024-08-13 22:25 ` Namhyung Kim 0 siblings, 2 replies; 9+ messages in thread From: Ian Rogers @ 2024-08-13 19:11 UTC (permalink / raw) To: Arnaldo Carvalho de Melo, Namhyung Kim Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, Thomas Richter, Kajol Jain, Athira Rajeev, linux-perf-users, linux-kernel On Tue, Aug 13, 2024 at 11:11 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > On Tue, Aug 13, 2024 at 09:04:57AM -0700, Ian Rogers wrote: > > On Tue, Aug 13, 2024 at 7:53 AM Arnaldo Carvalho de Melo > > <acme@kernel.org> wrote: > > > > > > On Mon, Aug 12, 2024 at 09:06:12PM -0700, Ian Rogers wrote: > > > > lock__parse calls disasm_line__parse passing > > > > &ops->locked.ins.name. Ensure ops->locked.ins.name is freed in > > > > lock__delete. > > > > > > > > Found with lock/leak sanitizer. > > > > Ooops, I meant address/leak sanitizer. > > > > > Applied both patches to perf-tools-next. > > > > Thanks, could you fix the commit message. > > Sure, Also, it'd be good if maybe Namhyung could take a look. I did things this way as it made sense to me, but we have nested things going on and potentially the free would be more natural in ins_ops__delete. Thanks, Ian ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations 2024-08-13 19:11 ` Ian Rogers @ 2024-08-13 20:41 ` Arnaldo Carvalho de Melo 2024-08-13 22:25 ` Namhyung Kim 1 sibling, 0 replies; 9+ messages in thread From: Arnaldo Carvalho de Melo @ 2024-08-13 20:41 UTC (permalink / raw) To: Ian Rogers Cc: Namhyung Kim, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, Thomas Richter, Kajol Jain, Athira Rajeev, linux-perf-users, linux-kernel On Tue, Aug 13, 2024 at 12:11:21PM -0700, Ian Rogers wrote: > On Tue, Aug 13, 2024 at 11:11 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > On Tue, Aug 13, 2024 at 09:04:57AM -0700, Ian Rogers wrote: > > > On Tue, Aug 13, 2024 at 7:53 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > > > On Mon, Aug 12, 2024 at 09:06:12PM -0700, Ian Rogers wrote: > > > > > lock__parse calls disasm_line__parse passing > > > > > &ops->locked.ins.name. Ensure ops->locked.ins.name is freed in > > > > > lock__delete. > > > > > Found with lock/leak sanitizer. > > > Ooops, I meant address/leak sanitizer. > > > > Applied both patches to perf-tools-next. > > > Thanks, could you fix the commit message. > > Sure, > Also, it'd be good if maybe Namhyung could take a look. I did things > this way as it made sense to me, but we have nested things going on > and potentially the free would be more natural in ins_ops__delete. ins_ops__delete() would have to look it is operating on a lock operation to access the right member of the unnamed union (locked) to get that string pointer to free. lock__delete() is the 'lock' destructor, that knows these details, so its the right place to do the freeing. I.e.: static struct ins_ops lock_ops = { .free = lock__delete, .parse = lock__parse, .scnprintf = lock__scnprintf, }; When it was introduced: commit c46219ac34f0f365bac700ca6a10ef979c643233 Author: Arnaldo Carvalho de Melo <acme@redhat.com> Date: Sat May 12 13:26:20 2012 -0300 perf annotate: Introduce ->free() method in ins_ops So that we don't special case disasm_line__free, allowing each instruction class to provide a specialized destructor, like is needed for 'lock'. - Arnaldo ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations 2024-08-13 19:11 ` Ian Rogers 2024-08-13 20:41 ` Arnaldo Carvalho de Melo @ 2024-08-13 22:25 ` Namhyung Kim 2024-08-14 0:43 ` Ian Rogers 1 sibling, 1 reply; 9+ messages in thread From: Namhyung Kim @ 2024-08-13 22:25 UTC (permalink / raw) To: Ian Rogers Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, Thomas Richter, Kajol Jain, Athira Rajeev, linux-perf-users, linux-kernel Hi Ian, On Tue, Aug 13, 2024 at 12:11 PM Ian Rogers <irogers@google.com> wrote: > > On Tue, Aug 13, 2024 at 11:11 AM Arnaldo Carvalho de Melo > <acme@kernel.org> wrote: > > > > On Tue, Aug 13, 2024 at 09:04:57AM -0700, Ian Rogers wrote: > > > On Tue, Aug 13, 2024 at 7:53 AM Arnaldo Carvalho de Melo > > > <acme@kernel.org> wrote: > > > > > > > > On Mon, Aug 12, 2024 at 09:06:12PM -0700, Ian Rogers wrote: > > > > > lock__parse calls disasm_line__parse passing > > > > > &ops->locked.ins.name. Ensure ops->locked.ins.name is freed in > > > > > lock__delete. > > > > > > > > > > Found with lock/leak sanitizer. > > > > > > Ooops, I meant address/leak sanitizer. > > > > > > > Applied both patches to perf-tools-next. > > > > > > Thanks, could you fix the commit message. > > > > Sure, > > Also, it'd be good if maybe Namhyung could take a look. I did things > this way as it made sense to me, but we have nested things going on > and potentially the free would be more natural in ins_ops__delete. Looks good to me. Acked-by: Namhyung Kim <namhyung@kernel.org> Thanks, Namhyung ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations 2024-08-13 22:25 ` Namhyung Kim @ 2024-08-14 0:43 ` Ian Rogers 0 siblings, 0 replies; 9+ messages in thread From: Ian Rogers @ 2024-08-14 0:43 UTC (permalink / raw) To: Namhyung Kim Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang, Thomas Richter, Kajol Jain, Athira Rajeev, linux-perf-users, linux-kernel On Tue, Aug 13, 2024 at 3:25 PM Namhyung Kim <namhyung@kernel.org> wrote: > > Hi Ian, > > On Tue, Aug 13, 2024 at 12:11 PM Ian Rogers <irogers@google.com> wrote: > > > > On Tue, Aug 13, 2024 at 11:11 AM Arnaldo Carvalho de Melo > > <acme@kernel.org> wrote: > > > > > > On Tue, Aug 13, 2024 at 09:04:57AM -0700, Ian Rogers wrote: > > > > On Tue, Aug 13, 2024 at 7:53 AM Arnaldo Carvalho de Melo > > > > <acme@kernel.org> wrote: > > > > > > > > > > On Mon, Aug 12, 2024 at 09:06:12PM -0700, Ian Rogers wrote: > > > > > > lock__parse calls disasm_line__parse passing > > > > > > &ops->locked.ins.name. Ensure ops->locked.ins.name is freed in > > > > > > lock__delete. > > > > > > > > > > > > Found with lock/leak sanitizer. > > > > > > > > Ooops, I meant address/leak sanitizer. > > > > > > > > > Applied both patches to perf-tools-next. > > > > > > > > Thanks, could you fix the commit message. > > > > > > Sure, > > > > Also, it'd be good if maybe Namhyung could take a look. I did things > > this way as it made sense to me, but we have nested things going on > > and potentially the free would be more natural in ins_ops__delete. > > Looks good to me. > > Acked-by: Namhyung Kim <namhyung@kernel.org> Thanks Namhyung, thanks Arnaldo. I think git blame said Namhyung because of a refactoring. I'm glad the free is in the correct location. Thanks, Ian ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-08-14 0:43 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-08-13 4:06 [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations Ian Rogers 2024-08-13 4:06 ` [PATCH v1 2/2] perf test annotate: Dump trapping test in trap handler Ian Rogers 2024-08-13 14:53 ` [PATCH v1 1/2] perf disasm: Fix memory leak for locked operations Arnaldo Carvalho de Melo 2024-08-13 16:04 ` Ian Rogers 2024-08-13 18:10 ` Arnaldo Carvalho de Melo 2024-08-13 19:11 ` Ian Rogers 2024-08-13 20:41 ` Arnaldo Carvalho de Melo 2024-08-13 22:25 ` Namhyung Kim 2024-08-14 0:43 ` Ian Rogers
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox