aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-03-15 14:44:01 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-03-23 18:28:58 -0400
commit9e69c210822c4035708a6111567c96364ca244d5 (patch)
tree3bae4b7f4309ec18bf4628b81cf85bb1570f6a31 /tools/perf/builtin-report.c
parent880f57318450dbead6a03f9e31a1468924d6dd88 (diff)
perf session: Pass evsel in event_ops->sample()
Resolving the sample->id to an evsel since the most advanced tools, report and annotate, and the others will too when they evolve to properly support multi-event perf.data files. Good also because it does an extra validation, checking that the ID is valid when present. When that is not the case, the overhead is just a branch + function call (perf_evlist__id2evsel). 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: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b1b82009ab9b..498c6f70a747 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -50,12 +50,12 @@ static symbol_filter_t annotate_init;
50 50
51static int perf_session__add_hist_entry(struct perf_session *session, 51static int perf_session__add_hist_entry(struct perf_session *session,
52 struct addr_location *al, 52 struct addr_location *al,
53 struct perf_sample *sample) 53 struct perf_sample *sample,
54 struct perf_evsel *evsel)
54{ 55{
55 struct symbol *parent = NULL; 56 struct symbol *parent = NULL;
56 int err = 0; 57 int err = 0;
57 struct hist_entry *he; 58 struct hist_entry *he;
58 struct perf_evsel *evsel;
59 59
60 if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { 60 if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) {
61 err = perf_session__resolve_callchain(session, al->thread, 61 err = perf_session__resolve_callchain(session, al->thread,
@@ -64,18 +64,6 @@ static int perf_session__add_hist_entry(struct perf_session *session,
64 return err; 64 return err;
65 } 65 }
66 66
67 evsel = perf_evlist__id2evsel(session->evlist, sample->id);
68 if (evsel == NULL) {
69 /*
70 * FIXME: Propagate this back, but at least we're in a builtin,
71 * where exit() is allowed. ;-)
72 */
73 ui__warning("Invalid %s file, contains samples with id %" PRIu64 " not in "
74 "its header!\n", input_name, sample->id);
75 exit_browser(0);
76 exit(1);
77 }
78
79 he = __hists__add_entry(&evsel->hists, al, parent, sample->period); 67 he = __hists__add_entry(&evsel->hists, al, parent, sample->period);
80 if (he == NULL) 68 if (he == NULL)
81 return -ENOMEM; 69 return -ENOMEM;
@@ -113,6 +101,7 @@ out:
113 101
114static int process_sample_event(union perf_event *event, 102static int process_sample_event(union perf_event *event,
115 struct perf_sample *sample, 103 struct perf_sample *sample,
104 struct perf_evsel *evsel,
116 struct perf_session *session) 105 struct perf_session *session)
117{ 106{
118 struct addr_location al; 107 struct addr_location al;
@@ -127,7 +116,7 @@ static int process_sample_event(union perf_event *event,
127 if (al.filtered || (hide_unresolved && al.sym == NULL)) 116 if (al.filtered || (hide_unresolved && al.sym == NULL))
128 return 0; 117 return 0;
129 118
130 if (perf_session__add_hist_entry(session, &al, sample)) { 119 if (perf_session__add_hist_entry(session, &al, sample, evsel)) {
131 pr_debug("problem incrementing symbol period, skipping event\n"); 120 pr_debug("problem incrementing symbol period, skipping event\n");
132 return -1; 121 return -1;
133 } 122 }