[lkml]   [2020]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 5.8 061/118] perf evlist: Fix cpu/thread map leak
From: Namhyung Kim <>

[ Upstream commit bfd1b83d75e44a9f65de30accb3dd3b5940bd3ac ]

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 <>
Acked-by: Jiri Olsa <>
Cc: Alexander Shishkin <>
Cc: Andi Kleen <>
Cc: Ian Rogers <>
Cc: Mark Rutland <>
Cc: Peter Zijlstra <>
Cc: Stephane Eranian <>
Signed-off-by: Arnaldo Carvalho de Melo <>
Signed-off-by: Sasha Levin <>
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 ab48be4cf2584..b279888bb1aab 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);
return 0;

@@ -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);
- return err;
+ perf_thread_map__put(threads);
- goto out;
+ return err;

int evlist__open(struct evlist *evlist)

 \ /
  Last update: 2020-09-21 18:55    [W:0.325 / U:3.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site