diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-03-15 14:44:01 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-03-23 18:28:58 -0400 |
commit | 9e69c210822c4035708a6111567c96364ca244d5 (patch) | |
tree | 3bae4b7f4309ec18bf4628b81cf85bb1570f6a31 /tools/perf/builtin-script.c | |
parent | 880f57318450dbead6a03f9e31a1468924d6dd88 (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-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 9f5fc5492141..ac574ea23917 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -162,19 +162,11 @@ static void print_sample_start(struct perf_sample *sample, | |||
162 | 162 | ||
163 | static void process_event(union perf_event *event __unused, | 163 | static void process_event(union perf_event *event __unused, |
164 | struct perf_sample *sample, | 164 | struct perf_sample *sample, |
165 | struct perf_evsel *evsel, | ||
165 | struct perf_session *session, | 166 | struct perf_session *session, |
166 | struct thread *thread) | 167 | struct thread *thread) |
167 | { | 168 | { |
168 | struct perf_event_attr *attr; | 169 | struct perf_event_attr *attr = &evsel->attr; |
169 | struct perf_evsel *evsel; | ||
170 | |||
171 | evsel = perf_evlist__id2evsel(session->evlist, sample->id); | ||
172 | if (evsel == NULL) { | ||
173 | pr_err("Invalid data. Contains samples with id not in " | ||
174 | "its header!\n"); | ||
175 | return; | ||
176 | } | ||
177 | attr = &evsel->attr; | ||
178 | 170 | ||
179 | if (output_fields[attr->type] == 0) | 171 | if (output_fields[attr->type] == 0) |
180 | return; | 172 | return; |
@@ -244,6 +236,7 @@ static char const *input_name = "perf.data"; | |||
244 | 236 | ||
245 | static int process_sample_event(union perf_event *event, | 237 | static int process_sample_event(union perf_event *event, |
246 | struct perf_sample *sample, | 238 | struct perf_sample *sample, |
239 | struct perf_evsel *evsel, | ||
247 | struct perf_session *session) | 240 | struct perf_session *session) |
248 | { | 241 | { |
249 | struct thread *thread = perf_session__findnew(session, event->ip.pid); | 242 | struct thread *thread = perf_session__findnew(session, event->ip.pid); |
@@ -264,7 +257,7 @@ static int process_sample_event(union perf_event *event, | |||
264 | last_timestamp = sample->time; | 257 | last_timestamp = sample->time; |
265 | return 0; | 258 | return 0; |
266 | } | 259 | } |
267 | scripting_ops->process_event(event, sample, session, thread); | 260 | scripting_ops->process_event(event, sample, evsel, session, thread); |
268 | 261 | ||
269 | session->hists.stats.total_period += sample->period; | 262 | session->hists.stats.total_period += sample->period; |
270 | return 0; | 263 | return 0; |