aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-trace.c
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2013-09-28 15:13:00 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-10-11 11:17:48 -0400
commit8fb598e5a3b0ac213012e8461a309843ba0f2e74 (patch)
tree811fa5a103e64f77ebde67a9c5e125726831ba4e /tools/perf/builtin-trace.c
parent4bbe5a61f29b13437a6a16467328d3bae8fce9e7 (diff)
perf trace: Fix comm resolution when reading events from file
Task comm's are getting lost when processing events from a file. The problem is that the trace struct used by the live processing has its host machine and the perf-session used for file based processing has its host machine. Fix by having both references point to the same machine. Before: 0.030 ( 0.001 ms): :27743/27743 brk( ... 0.057 ( 0.004 ms): :27743/27743 mmap(len: 4096, prot: READ|WRITE, flags: ... 0.075 ( 0.006 ms): :27743/27743 access(filename: 0x7f3809fbce00, mode: R ... 0.091 ( 0.005 ms): :27743/27743 open(filename: 0x7f3809fba14c, flags: CLOEXEC ... ... After: 0.030 ( 0.001 ms): make/27743 brk( ... 0.057 ( 0.004 ms): make/27743 mmap(len: 4096, prot: READ|WRITE, flags: ... 0.075 ( 0.006 ms): make/27743 access(filename: 0x7f3809fbce00, mode: R ... 0.091 ( 0.005 ms): make/27743 open(filename: 0x7f3809fba14c, flags: CLOEXEC ... ... Signed-off-by: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1380395584-9025-4-git-send-email-dsahern@gmail.com [ Moved creation of new host machine to a separate constructor: machine__new_host() ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-trace.c')
-rw-r--r--tools/perf/builtin-trace.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index fcc157fce6c6..5776b5f829e1 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -906,7 +906,7 @@ struct trace {
906 struct syscall *table; 906 struct syscall *table;
907 } syscalls; 907 } syscalls;
908 struct perf_record_opts opts; 908 struct perf_record_opts opts;
909 struct machine host; 909 struct machine *host;
910 u64 base_time; 910 u64 base_time;
911 bool full_time; 911 bool full_time;
912 FILE *output; 912 FILE *output;
@@ -1083,16 +1083,17 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
1083 if (err) 1083 if (err)
1084 return err; 1084 return err;
1085 1085
1086 machine__init(&trace->host, "", HOST_KERNEL_ID); 1086 trace->host = machine__new_host();
1087 machine__create_kernel_maps(&trace->host); 1087 if (trace->host == NULL)
1088 return -ENOMEM;
1088 1089
1089 if (perf_target__has_task(&trace->opts.target)) { 1090 if (perf_target__has_task(&trace->opts.target)) {
1090 err = perf_event__synthesize_thread_map(&trace->tool, evlist->threads, 1091 err = perf_event__synthesize_thread_map(&trace->tool, evlist->threads,
1091 trace__tool_process, 1092 trace__tool_process,
1092 &trace->host); 1093 trace->host);
1093 } else { 1094 } else {
1094 err = perf_event__synthesize_threads(&trace->tool, trace__tool_process, 1095 err = perf_event__synthesize_threads(&trace->tool, trace__tool_process,
1095 &trace->host); 1096 trace->host);
1096 } 1097 }
1097 1098
1098 if (err) 1099 if (err)
@@ -1304,8 +1305,7 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
1304 if (sc->filtered) 1305 if (sc->filtered)
1305 return 0; 1306 return 0;
1306 1307
1307 thread = machine__findnew_thread(&trace->host, sample->pid, 1308 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
1308 sample->tid);
1309 ttrace = thread__trace(thread, trace->output); 1309 ttrace = thread__trace(thread, trace->output);
1310 if (ttrace == NULL) 1310 if (ttrace == NULL)
1311 return -1; 1311 return -1;
@@ -1357,8 +1357,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
1357 if (sc->filtered) 1357 if (sc->filtered)
1358 return 0; 1358 return 0;
1359 1359
1360 thread = machine__findnew_thread(&trace->host, sample->pid, 1360 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
1361 sample->tid);
1362 ttrace = thread__trace(thread, trace->output); 1361 ttrace = thread__trace(thread, trace->output);
1363 if (ttrace == NULL) 1362 if (ttrace == NULL)
1364 return -1; 1363 return -1;
@@ -1414,7 +1413,7 @@ static int trace__sched_stat_runtime(struct trace *trace, struct perf_evsel *evs
1414{ 1413{
1415 u64 runtime = perf_evsel__intval(evsel, sample, "runtime"); 1414 u64 runtime = perf_evsel__intval(evsel, sample, "runtime");
1416 double runtime_ms = (double)runtime / NSEC_PER_MSEC; 1415 double runtime_ms = (double)runtime / NSEC_PER_MSEC;
1417 struct thread *thread = machine__findnew_thread(&trace->host, 1416 struct thread *thread = machine__findnew_thread(trace->host,
1418 sample->pid, 1417 sample->pid,
1419 sample->tid); 1418 sample->tid);
1420 struct thread_trace *ttrace = thread__trace(thread, trace->output); 1419 struct thread_trace *ttrace = thread__trace(thread, trace->output);
@@ -1597,7 +1596,7 @@ again:
1597 trace->base_time = sample.time; 1596 trace->base_time = sample.time;
1598 1597
1599 if (type != PERF_RECORD_SAMPLE) { 1598 if (type != PERF_RECORD_SAMPLE) {
1600 trace__process_event(trace, &trace->host, event); 1599 trace__process_event(trace, trace->host, event);
1601 continue; 1600 continue;
1602 } 1601 }
1603 1602
@@ -1681,6 +1680,8 @@ static int trace__replay(struct trace *trace)
1681 if (session == NULL) 1680 if (session == NULL)
1682 return -ENOMEM; 1681 return -ENOMEM;
1683 1682
1683 trace->host = &session->machines.host;
1684
1684 err = perf_session__set_tracepoints_handlers(session, handlers); 1685 err = perf_session__set_tracepoints_handlers(session, handlers);
1685 if (err) 1686 if (err)
1686 goto out; 1687 goto out;
@@ -1728,7 +1729,7 @@ static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp)
1728 size_t printed = trace__fprintf_threads_header(fp); 1729 size_t printed = trace__fprintf_threads_header(fp);
1729 struct rb_node *nd; 1730 struct rb_node *nd;
1730 1731
1731 for (nd = rb_first(&trace->host.threads); nd; nd = rb_next(nd)) { 1732 for (nd = rb_first(&trace->host->threads); nd; nd = rb_next(nd)) {
1732 struct thread *thread = rb_entry(nd, struct thread, rb_node); 1733 struct thread *thread = rb_entry(nd, struct thread, rb_node);
1733 struct thread_trace *ttrace = thread->priv; 1734 struct thread_trace *ttrace = thread->priv;
1734 const char *color; 1735 const char *color;