Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bfd1b83

Browse files
namhyungacmel
authored andcommittedSep 15, 2020
perf evlist: Fix cpu/thread map leak
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: 7e2ed09 ("perf evlist: Store pointer to the cpu and thread maps") Fixes: 4112eb1 ("perf evlist: Default to syswide target when no thread/cpu maps set") Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lore.kernel.org/lkml/20200915031819.386559-4-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent b033ab1 commit bfd1b83

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

‎tools/perf/util/evlist.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,10 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)
946946

947947
perf_evlist__set_maps(&evlist->core, cpus, threads);
948948

949+
/* as evlist now has references, put count here */
950+
perf_cpu_map__put(cpus);
951+
perf_thread_map__put(threads);
952+
949953
return 0;
950954

951955
out_delete_threads:
@@ -1273,11 +1277,12 @@ static int perf_evlist__create_syswide_maps(struct evlist *evlist)
12731277
goto out_put;
12741278

12751279
perf_evlist__set_maps(&evlist->core, cpus, threads);
1276-
out:
1277-
return err;
1280+
1281+
perf_thread_map__put(threads);
12781282
out_put:
12791283
perf_cpu_map__put(cpus);
1280-
goto out;
1284+
out:
1285+
return err;
12811286
}
12821287

12831288
int evlist__open(struct evlist *evlist)

0 commit comments

Comments
 (0)
Please sign in to comment.