perf evsel: Fix order of event list deletion

We need to defer calling perf_evsel_list__delete() till after atexit
registered routines, because we need to traverse the events being
recorded at that time at least on 'perf record'.

This fixes the problem reported by Thomas Renninger where cmd_record
called by cmd_timechart would not write the tracing data to the perf.data
file header because the evsel_list at atexit (control+C on 'perf timechart
record') time would be empty, being already deleted by run_builtin(),
and thus 'perf timechart' when trying to process such perf.data file would
die with:

"no trace data in the file"

Problem introduced in 70d544d0.
Reported-by: NThomas Renninger <trenn@suse.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Renninger <trenn@suse.de>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 3d03e2ea
...@@ -480,6 +480,7 @@ static void atexit_header(void) ...@@ -480,6 +480,7 @@ static void atexit_header(void)
process_buildids(); process_buildids();
perf_header__write(&session->header, output, true); perf_header__write(&session->header, output, true);
perf_session__delete(session); perf_session__delete(session);
perf_evsel_list__delete();
symbol__exit(); symbol__exit();
} }
} }
......
...@@ -743,6 +743,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) ...@@ -743,6 +743,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
out_free_fd: out_free_fd:
list_for_each_entry(pos, &evsel_list, node) list_for_each_entry(pos, &evsel_list, node)
perf_evsel__free_stat_priv(pos); perf_evsel__free_stat_priv(pos);
perf_evsel_list__delete();
out: out:
thread_map__delete(threads); thread_map__delete(threads);
threads = NULL; threads = NULL;
......
...@@ -1490,6 +1490,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) ...@@ -1490,6 +1490,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
out_free_fd: out_free_fd:
list_for_each_entry(pos, &evsel_list, node) list_for_each_entry(pos, &evsel_list, node)
perf_evsel__free_mmap(pos); perf_evsel__free_mmap(pos);
perf_evsel_list__delete();
return status; return status;
} }
...@@ -286,8 +286,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) ...@@ -286,8 +286,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
status = p->fn(argc, argv, prefix); status = p->fn(argc, argv, prefix);
exit_browser(status); exit_browser(status);
perf_evsel_list__delete();
if (status) if (status)
return status & 0xff; return status & 0xff;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册