diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-07 08:58:03 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-07 22:43:37 -0400 |
commit | fcf65bf149afa91b875ffde4455967cb63ee0be9 (patch) | |
tree | 9b6137e60d4142b1aa00f9e20860bdd8374035d3 /tools/perf/util/scripting-engines/trace-event-perl.c | |
parent | 8b6ee4c5d48d93527dcf6e36c51cbb7703d7fffb (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/util/scripting-engines/trace-event-perl.c')
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-perl.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index 02dfa19a467f..c26628116593 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c | |||
@@ -237,16 +237,16 @@ static void define_event_symbols(struct event_format *event, | |||
237 | define_event_symbols(event, ev_name, args->next); | 237 | define_event_symbols(event, ev_name, args->next); |
238 | } | 238 | } |
239 | 239 | ||
240 | static inline | 240 | static inline struct event_format *find_cache_event(struct perf_evsel *evsel) |
241 | struct event_format *find_cache_event(struct pevent *pevent, int type) | ||
242 | { | 241 | { |
243 | static char ev_name[256]; | 242 | static char ev_name[256]; |
244 | struct event_format *event; | 243 | struct event_format *event; |
244 | int type = evsel->attr.config; | ||
245 | 245 | ||
246 | if (events[type]) | 246 | if (events[type]) |
247 | return events[type]; | 247 | return events[type]; |
248 | 248 | ||
249 | events[type] = event = pevent_find_event(pevent, type); | 249 | events[type] = event = evsel->tp_format; |
250 | if (!event) | 250 | if (!event) |
251 | return NULL; | 251 | return NULL; |
252 | 252 | ||
@@ -269,7 +269,6 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused, | |||
269 | unsigned long long val; | 269 | unsigned long long val; |
270 | unsigned long s, ns; | 270 | unsigned long s, ns; |
271 | struct event_format *event; | 271 | struct event_format *event; |
272 | int type; | ||
273 | int pid; | 272 | int pid; |
274 | int cpu = sample->cpu; | 273 | int cpu = sample->cpu; |
275 | void *data = sample->raw_data; | 274 | void *data = sample->raw_data; |
@@ -281,11 +280,9 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused, | |||
281 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) | 280 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) |
282 | return; | 281 | return; |
283 | 282 | ||
284 | type = trace_parse_common_type(pevent, data); | 283 | event = find_cache_event(evsel); |
285 | |||
286 | event = find_cache_event(pevent, type); | ||
287 | if (!event) | 284 | if (!event) |
288 | die("ug! no event found for type %d", type); | 285 | die("ug! no event found for type %d", evsel->attr.config); |
289 | 286 | ||
290 | pid = trace_parse_common_pid(pevent, data); | 287 | pid = trace_parse_common_pid(pevent, data); |
291 | 288 | ||