aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-08-07 08:58:03 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-07 22:43:37 -0400
commitfcf65bf149afa91b875ffde4455967cb63ee0be9 (patch)
tree9b6137e60d4142b1aa00f9e20860bdd8374035d3 /tools/perf/builtin-script.c
parent8b6ee4c5d48d93527dcf6e36c51cbb7703d7fffb (diff)
perf evsel: Cache associated event_format
We already lookup the associated event_format when reading the perf.data header, so that we can cache the tracepoint name in evsel->name, so do it a little further and save the event_format itself, so that we can avoid relookups in tools that need to access it. Change the tools to take the most obvious advantage, when they were using pevent_find_event directly. More work is needed for further removing the need of a pointer to pevent, such as when asking for event field values ("common_pid" and the other common fields and per event_format fields). This is something that was planned but only got actually done when Andrey Wagin needed to do this lookup at perf_tool->sample() time, when we don't have access to pevent (session->pevent) to use with pevent_find_event(). Cc: Andrey Wagin <avagin@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Link: http://lkml.kernel.org/n/tip-txkvew2ckko0b594ae8fbnyk@git.kernel.org 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.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 1e60ab70b2b1..8dba4707b03f 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -262,14 +262,11 @@ static int perf_session__check_output_opt(struct perf_session *session)
262 return 0; 262 return 0;
263} 263}
264 264
265static void print_sample_start(struct pevent *pevent, 265static void print_sample_start(struct perf_sample *sample,
266 struct perf_sample *sample,
267 struct thread *thread, 266 struct thread *thread,
268 struct perf_evsel *evsel) 267 struct perf_evsel *evsel)
269{ 268{
270 int type;
271 struct perf_event_attr *attr = &evsel->attr; 269 struct perf_event_attr *attr = &evsel->attr;
272 struct event_format *event;
273 const char *evname = NULL; 270 const char *evname = NULL;
274 unsigned long secs; 271 unsigned long secs;
275 unsigned long usecs; 272 unsigned long usecs;
@@ -307,20 +304,7 @@ static void print_sample_start(struct pevent *pevent,
307 } 304 }
308 305
309 if (PRINT_FIELD(EVNAME)) { 306 if (PRINT_FIELD(EVNAME)) {
310 if (attr->type == PERF_TYPE_TRACEPOINT) { 307 evname = perf_evsel__name(evsel);
311 /*
312 * XXX Do we really need this here?
313 * perf_evlist__set_tracepoint_names should have done
314 * this already
315 */
316 type = trace_parse_common_type(pevent,
317 sample->raw_data);
318 event = pevent_find_event(pevent, type);
319 if (event)
320 evname = event->name;
321 } else
322 evname = perf_evsel__name(evsel);
323
324 printf("%s: ", evname ? evname : "[unknown]"); 308 printf("%s: ", evname ? evname : "[unknown]");
325 } 309 }
326} 310}
@@ -416,7 +400,7 @@ static void print_sample_bts(union perf_event *event,
416} 400}
417 401
418static void process_event(union perf_event *event __unused, 402static void process_event(union perf_event *event __unused,
419 struct pevent *pevent, 403 struct pevent *pevent __unused,
420 struct perf_sample *sample, 404 struct perf_sample *sample,
421 struct perf_evsel *evsel, 405 struct perf_evsel *evsel,
422 struct machine *machine, 406 struct machine *machine,
@@ -427,7 +411,7 @@ static void process_event(union perf_event *event __unused,
427 if (output[attr->type].fields == 0) 411 if (output[attr->type].fields == 0)
428 return; 412 return;
429 413
430 print_sample_start(pevent, sample, thread, evsel); 414 print_sample_start(sample, thread, evsel);
431 415
432 if (is_bts_event(attr)) { 416 if (is_bts_event(attr)) {
433 print_sample_bts(event, sample, evsel, machine, thread); 417 print_sample_bts(event, sample, evsel, machine, thread);
@@ -435,9 +419,8 @@ static void process_event(union perf_event *event __unused,
435 } 419 }
436 420
437 if (PRINT_FIELD(TRACE)) 421 if (PRINT_FIELD(TRACE))
438 print_trace_event(pevent, sample->cpu, sample->raw_data, 422 event_format__print(evsel->tp_format, sample->cpu,
439 sample->raw_size); 423 sample->raw_data, sample->raw_size);
440
441 if (PRINT_FIELD(ADDR)) 424 if (PRINT_FIELD(ADDR))
442 print_sample_addr(event, sample, machine, thread, attr); 425 print_sample_addr(event, sample, machine, thread, attr);
443 426