Skip to content

Commit 2ae8f40

Browse files
Manciukicgregkh
authored andcommitted
perf script: Fix memory 'threads' and 'cpus' leaks on exit
[ Upstream commit faf3ac3 ] ASan reports several memory leaks while running: # perf test "82: Use vfs_getname probe to get syscall args filenames" Two of these are caused by some refcounts not being decreased on perf-script exit, namely script.threads and script.cpus. This patch adds the missing __put calls in a new perf_script__exit function, which is called at the end of cmd_script. This patch concludes the fixes of all remaining memory leaks in perf test "82: Use vfs_getname probe to get syscall args filenames". Signed-off-by: Riccardo Mancini <rickyman7@gmail.com> Fixes: cfc8874 ("perf script: Process cpu/threads maps") Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/5ee73b19791c6fa9d24c4d57f4ac1a23609400d7.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 51077d3 commit 2ae8f40

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎tools/perf/builtin-script.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,12 @@ static void perf_script__exit_per_event_dump_stats(struct perf_script *script)
24832483
}
24842484
}
24852485

2486+
static void perf_script__exit(struct perf_script *script)
2487+
{
2488+
perf_thread_map__put(script->threads);
2489+
perf_cpu_map__put(script->cpus);
2490+
}
2491+
24862492
static int __cmd_script(struct perf_script *script)
24872493
{
24882494
int ret;
@@ -3937,6 +3943,7 @@ int cmd_script(int argc, const char **argv)
39373943

39383944
perf_evlist__free_stats(session->evlist);
39393945
perf_session__delete(session);
3946+
perf_script__exit(&script);
39403947

39413948
if (script_started)
39423949
cleanup_scripting();

0 commit comments

Comments
 (0)