From: Riccardo Mancini <rickyman7@gmail.com>
To: Ian Rogers <irogers@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] perf script: delete evlist when deleting session
Date: Tue, 22 Jun 2021 09:44:39 +0200 [thread overview]
Message-ID: <d4921abf8dcff02245ccf7ad8edfd8048e926936.camel@gmail.com> (raw)
In-Reply-To: <CAP-5=fUGRdj=G6=srwoATWMimK5tB4X2Sxa64tTVk_JRwMJdWg@mail.gmail.com>
Hi,
thanks for your comments.
On Mon, 2021-06-21 at 22:14 -0700, Ian Rogers wrote:
> On Mon, Jun 21, 2021 at 4:44 PM Riccardo Mancini <rickyman7@gmail.com> wrote:
> >
> > ASan reports a memory leak related to session->evlist never being deleted.
> > The evlist member is not deleted in perf_session__delete, so it should be
> > deleted separately.
> > This patch adds the missing deletion in perf-script.
> >
> > Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
> > ---
> > tools/perf/builtin-script.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > index 1280cbfad4db..635a1d9cfc88 100644
> > --- a/tools/perf/builtin-script.c
> > +++ b/tools/perf/builtin-script.c
> > @@ -3991,7 +3991,7 @@ int cmd_script(int argc, const char **argv)
> > zfree(&script.ptime_range);
> > }
> >
> > - evlist__free_stats(session->evlist);
>
> Should this be removed?
Probably not. I originally thought this was already taken care of by
evlist__delete, but it's not.
Oddly, this issue is not causing a memory leak in my simple test.
>
> > + evlist__delete(session->evlist);
>
> If the perf session "owns" the evlist, would it be cleaner to add this
> to perf_session__delete?
I thought about that too, but that's not always true.
E.g., in perf-record, __cmd_record calls perf_session__delete,then cmd_record
calls evlist__delete on rec->evlist, which points to the same location to which
session->evlist pointed.
Thanks,
Riccardo
>
> Thanks,
> Ian
>
> > perf_session__delete(session);
> >
> > if (script_started)
> > --
> > 2.31.1
> >
next prev parent reply other threads:[~2021-06-22 7:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-21 23:43 [PATCH 0/2] perf: add missing evlist__delete when deleting Riccardo Mancini
2021-06-21 23:43 ` [PATCH 1/2] perf report: delete evlist when deleting session Riccardo Mancini
2021-06-21 23:43 ` [PATCH 2/2] perf script: " Riccardo Mancini
2021-06-22 5:14 ` Ian Rogers
2021-06-22 7:44 ` Riccardo Mancini [this message]
2021-06-22 16:33 ` Ian Rogers
2021-06-22 17:42 ` Arnaldo Carvalho de Melo
2021-06-22 18:28 ` Ian Rogers
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=d4921abf8dcff02245ccf7ad8edfd8048e926936.camel@gmail.com \
--to=rickyman7@gmail.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).