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 <namhy...@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

Reply via email to