linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Stephane Eranian <eranian@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andi Kleen <andi@firstfloor.org>, Ian Rogers <irogers@google.com>
Subject: Re: [PATCH 1/9] perf evlist: Fix cpu/thread map leak
Date: Mon, 7 Sep 2020 13:32:01 +0200	[thread overview]
Message-ID: <20200907113201.GK1199773@krava> (raw)
In-Reply-To: <20200907112925.GJ1199773@krava>

On Mon, Sep 07, 2020 at 01:29:29PM +0200, Jiri Olsa wrote:
> On Mon, Sep 07, 2020 at 12:44:54PM +0900, Namhyung Kim wrote:
> > Asan reported leak of cpu and thread maps as they have one more
> > refcount than released.  I found that after setting evlist maps it
> > should release it's refcount.
> > 
> > It seems to be broken from the beginning so I chose the original
> > commit as the culprit.  But not sure how it's applied to stable trees
> > since there are many changes in the code after that.
> > 
> > Fixes: 7e2ed097538c5 ("perf evlist: Store pointer to the cpu and thread maps")
> > Fixes: 4112eb1899c0e ("perf evlist: Default to syswide target when no thread/cpu maps set")
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> >  tools/perf/util/evlist.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> > index e3fa3bf7498a..c0768c61eb43 100644
> > --- a/tools/perf/util/evlist.c
> > +++ b/tools/perf/util/evlist.c
> > @@ -946,6 +946,10 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)
> >  
> >  	perf_evlist__set_maps(&evlist->core, cpus, threads);
> >  
> > +	/* as evlist now has references, put count here */
> > +	perf_cpu_map__put(cpus);
> > +	perf_thread_map__put(threads);
> 
> nice catch, I checked perf_evlist__create_syswide_maps is doing this

because you fixed that :))) missed the rest of the patch.. sry

jirka

> correctly, but I think we might have the same issue in script's
> set_maps function
> 
> thanks,
> jirka
> 
> > +
> >  	return 0;
> >  
> >  out_delete_threads:
> > @@ -1273,11 +1277,12 @@ static int perf_evlist__create_syswide_maps(struct evlist *evlist)
> >  		goto out_put;
> >  
> >  	perf_evlist__set_maps(&evlist->core, cpus, threads);
> > -out:
> > -	return err;
> > +
> > +	perf_thread_map__put(threads);
> >  out_put:
> >  	perf_cpu_map__put(cpus);
> > -	goto out;
> > +out:
> > +	return err;
> >  }
> >  
> >  int evlist__open(struct evlist *evlist)
> > -- 
> > 2.28.0.526.ge36021eeef-goog
> > 


  reply	other threads:[~2020-09-07 11:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-07  3:44 [PATCHSET 0/9] perf tools: Fix various memory leaks Namhyung Kim
2020-09-07  3:44 ` [PATCH 1/9] perf evlist: Fix cpu/thread map leak Namhyung Kim
2020-09-07 11:29   ` Jiri Olsa
2020-09-07 11:32     ` Jiri Olsa [this message]
2020-09-07 13:22       ` Namhyung Kim
2020-09-07  3:44 ` [PATCH 2/9] perf parse-event: Fix cpu map leaks Namhyung Kim
2020-09-07  3:44 ` [PATCH 3/9] perf parse-event: Fix memory leak in evsel->unit Namhyung Kim
2020-09-07  3:44 ` [PATCH 4/9] perf test: Fix memory leaks in parse-metric test Namhyung Kim
2020-09-07  3:44 ` [PATCH 5/9] perf metric: Release expr_parse_ctx after testing Namhyung Kim
2020-09-07  3:44 ` [PATCH 6/9] perf metric: Free metric when it failed to resolve Namhyung Kim
2020-09-07  3:45 ` [PATCH 7/9] perf metric: Do not free metric when " Namhyung Kim
2020-09-07  3:45 ` [PATCH 8/9] perf test: Free aliases for PMU event map aliases test Namhyung Kim
2020-09-07 10:28   ` John Garry
2020-09-07 13:20     ` Namhyung Kim
2020-09-07 13:47       ` John Garry
2020-09-07  3:45 ` [PATCH 9/9] perf test: Free formats for perf pmu parse test Namhyung Kim
2020-09-07 11:35 ` [PATCHSET 0/9] perf tools: Fix various memory leaks Jiri Olsa

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=20200907113201.GK1199773@krava \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.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).