public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@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 <ak@linux.intel.com>, Ian Rogers <irogers@google.com>
Subject: Re: [PATCH v2 1/2] perf parse-event: Release cpu_map if evsel alloc failed
Date: Thu, 17 Sep 2020 13:30:31 -0300	[thread overview]
Message-ID: <20200917163031.GD1322686@kernel.org> (raw)
In-Reply-To: <20200917131058.GA2514666@krava>

Em Thu, Sep 17, 2020 at 03:10:58PM +0200, Jiri Olsa escreveu:
> On Thu, Sep 17, 2020 at 03:02:18PM +0900, Namhyung Kim wrote:
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> >  tools/perf/util/parse-events.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> > index 667cbca1547a..176a51698a64 100644
> > --- a/tools/perf/util/parse-events.c
> > +++ b/tools/perf/util/parse-events.c
> > @@ -360,8 +360,10 @@ __add_event(struct list_head *list, int *idx,
> >  		event_attr_init(attr);
> >  
> >  	evsel = evsel__new_idx(attr, *idx);
> > -	if (!evsel)
> > +	if (!evsel) {
> > +		perf_cpu_map__put(cpus);
> 
> if there's pmu defined, we don't we get on perf_cpu_map:
> 
>         struct perf_cpu_map *cpus = pmu ? pmu->cpus :
>                                cpu_list ? perf_cpu_map__new(cpu_list) : NULL;

Yeah, I fixed this up by applying first the patch that grabs the
pmu->cpus refcount and makes the first attribution of evsel->core.cpus
be directly to 'cpus', as it will either have the refcount for pmu->cpus
or the newly created, refcount set at 1 cpu map.o

Then the error path fix goes in, just dropping the reference to whatever
cpu map we have a refcount for.

- Arnaldo
 
> jirka
> 
> >  		return NULL;
> > +	}
> >  
> >  	(*idx)++;
> >  	evsel->core.cpus   = perf_cpu_map__get(cpus);
> > -- 
> > 2.28.0.618.gf4bc123cb7-goog
> > 
> 

-- 

- Arnaldo

  parent reply	other threads:[~2020-09-17 16:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17  6:02 [PATCH v2 1/2] perf parse-event: Release cpu_map if evsel alloc failed Namhyung Kim
2020-09-17  6:02 ` [PATCH v2 2/2] perf parse-event: Fix cpu map leaks Namhyung Kim
2020-09-17 16:27   ` Arnaldo Carvalho de Melo
2020-09-17 13:10 ` [PATCH v2 1/2] perf parse-event: Release cpu_map if evsel alloc failed Jiri Olsa
2020-09-17 13:27   ` Namhyung Kim
2020-09-17 16:30   ` Arnaldo Carvalho de Melo [this message]
2020-09-18  1:51     ` Namhyung Kim

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=20200917163031.GD1322686@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.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