All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Riccardo Mancini <rickyman7@gmail.com>
Cc: Ian Rogers <irogers@google.com>,
	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>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Leo Yan <leo.yan@linaro.org>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] perf session: add missing evlist__delete when deleting a session
Date: Sun, 27 Jun 2021 19:29:26 +0200	[thread overview]
Message-ID: <YNi1dspuN/cdNAKr@krava> (raw)
In-Reply-To: <4725ef2249540b6876daea3714a38a6be59223e6.camel@gmail.com>

On Fri, Jun 25, 2021 at 05:45:59PM +0200, Riccardo Mancini wrote:
> Hi,
> 
> thank you both for your comments.
> 
> On Fri, 2021-06-25 at 13:54 +0200, Jiri Olsa wrote:
> > On Thu, Jun 24, 2021 at 10:39:34PM -0700, Ian Rogers wrote:
> > > On Thu, Jun 24, 2021 at 4:20 PM Riccardo Mancini <rickyman7@gmail.com>
> > > wrote:
> > > > 
> > > > ASan reports a memory leak caused by evlist not being deleted on exit in
> > > > perf-report, perf-script and perf-data.
> > > > The problem is caused by evlist->session not being deleted, which is
> > > > allocated in perf_session__read_header, called in perf_session__new if
> > > > perf_data is in read mode.
> > > > In case of write mode, the session->evlist is filled by the caller.
> > > > This patch solves the problem by calling evlist__delete in
> > > > perf_session__delete if perf_data is in read mode.
> > 
> > ugh, I'm surprised we did not free that.. and can't find
> > in git log we ever did ;-) I briefly check commands using
> > sessions and looks like it's correct
> > 
> > Acked-by: Jiri Olsa <jolsa@redhat.com>
> > 
> > > 
> > > Acked-by: Ian Rogers <irogers@google.com>
> > > 
> > > It is messy that in read mode the session owns the evlist, but
> > > otherwise not. Imo, it'd be nice to make the ownership unconditional.
> > 
> > yep, would be nice
> 
> I think the root problem is that perf_session__new has different behaviours
> depending on perf_data and perf_tool and that it probably does too many things
> for a __new function.
> If we split it into multiple functions and then, say, we create two helpers
> perf_session__init_read and perf_session__init_write, with the corresponding
> perf_session__fini_read and perf_session__fini_write, then the conditional
> ownership won't be a big problem due to having these two cases clearly
> separated.
> What do you think?

yes, interesting idea, let's see how the code looks like ;-)

thanks,
jirka


  reply	other threads:[~2021-06-27 17:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 23:19 [PATCH v2] perf session: add missing evlist__delete when deleting a session Riccardo Mancini
2021-06-25  5:39 ` Ian Rogers
2021-06-25 11:54   ` Jiri Olsa
2021-06-25 15:45     ` Riccardo Mancini
2021-06-27 17:29       ` Jiri Olsa [this message]
2021-07-01 18:04     ` Arnaldo Carvalho de Melo

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=YNi1dspuN/cdNAKr@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=kan.liang@linux.intel.com \
    --cc=leo.yan@linaro.org \
    --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 \
    --cc=rickyman7@gmail.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.