Skip to content

Commit faf3ac3

Browse files
Manciukicacmel
authored andcommitted
perf script: Fix memory 'threads' and 'cpus' leaks on exit
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 <[email protected]> Fixes: cfc8874 ("perf script: Process cpu/threads maps") Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/5ee73b19791c6fa9d24c4d57f4ac1a23609400d7.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 1b1f57c commit faf3ac3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/perf/builtin-script.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,6 +2601,12 @@ static void perf_script__exit_per_event_dump_stats(struct perf_script *script)
26012601
}
26022602
}
26032603

2604+
static void perf_script__exit(struct perf_script *script)
2605+
{
2606+
perf_thread_map__put(script->threads);
2607+
perf_cpu_map__put(script->cpus);
2608+
}
2609+
26042610
static int __cmd_script(struct perf_script *script)
26052611
{
26062612
int ret;
@@ -4146,6 +4152,7 @@ int cmd_script(int argc, const char **argv)
41464152
zstd_fini(&(session->zstd_data));
41474153
evlist__free_stats(session->evlist);
41484154
perf_session__delete(session);
4155+
perf_script__exit(&script);
41494156

41504157
if (script_started)
41514158
cleanup_scripting();

0 commit comments

Comments
 (0)