aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.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/util/session.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/util/session.c')
-rw-r--r--tools/perf/util/session.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index c68cf40764f9..caa224522fea 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -280,6 +280,15 @@ static int process_event_synth_stub(union perf_event *event __used,
280 return 0; 280 return 0;
281} 281}
282 282
283static int process_event_sample_stub(union perf_event *event __used,
284 struct perf_sample *sample __used,
285 struct perf_evsel *evsel __used,
286 struct perf_session *session __used)
287{
288 dump_printf(": unhandled!\n");
289 return 0;
290}
291
283static int process_event_stub(union perf_event *event __used, 292static int process_event_stub(union perf_event *event __used,
284 struct perf_sample *sample __used, 293 struct perf_sample *sample __used,
285 struct perf_session *session __used) 294 struct perf_session *session __used)
@@ -303,7 +312,7 @@ static int process_finished_round(union perf_event *event,
303static void perf_event_ops__fill_defaults(struct perf_event_ops *handler) 312static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
304{ 313{
305 if (handler->sample == NULL) 314 if (handler->sample == NULL)
306 handler->sample = process_event_stub; 315 handler->sample = process_event_sample_stub;
307 if (handler->mmap == NULL) 316 if (handler->mmap == NULL)
308 handler->mmap = process_event_stub; 317 handler->mmap = process_event_stub;
309 if (handler->comm == NULL) 318 if (handler->comm == NULL)
@@ -698,12 +707,19 @@ static int perf_session_deliver_event(struct perf_session *session,
698 struct perf_event_ops *ops, 707 struct perf_event_ops *ops,
699 u64 file_offset) 708 u64 file_offset)
700{ 709{
710 struct perf_evsel *evsel;
711
701 dump_event(session, event, file_offset, sample); 712 dump_event(session, event, file_offset, sample);
702 713
703 switch (event->header.type) { 714 switch (event->header.type) {
704 case PERF_RECORD_SAMPLE: 715 case PERF_RECORD_SAMPLE:
705 dump_sample(session, event, sample); 716 dump_sample(session, event, sample);
706 return ops->sample(event, sample, session); 717 evsel = perf_evlist__id2evsel(session->evlist, sample->id);
718 if (evsel == NULL) {
719 ++session->hists.stats.nr_unknown_id;
720 return -1;
721 }
722 return ops->sample(event, sample, evsel, session);
707 case PERF_RECORD_MMAP: 723 case PERF_RECORD_MMAP:
708 return ops->mmap(event, sample, session); 724 return ops->mmap(event, sample, session);
709 case PERF_RECORD_COMM: 725 case PERF_RECORD_COMM:
@@ -845,6 +861,11 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
845 session->hists.stats.nr_unknown_events); 861 session->hists.stats.nr_unknown_events);
846 } 862 }
847 863
864 if (session->hists.stats.nr_unknown_id != 0) {
865 ui__warning("%u samples with id not present in the header\n",
866 session->hists.stats.nr_unknown_id);
867 }
868
848 if (session->hists.stats.nr_invalid_chains != 0) { 869 if (session->hists.stats.nr_invalid_chains != 0) {
849 ui__warning("Found invalid callchains!\n\n" 870 ui__warning("Found invalid callchains!\n\n"
850 "%u out of %u events were discarded for this reason.\n\n" 871 "%u out of %u events were discarded for this reason.\n\n"