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/trace-event-parse.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/trace-event-parse.c')
-rw-r--r-- | tools/perf/util/trace-event-parse.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 0715c843c2e7..12088348ac02 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
@@ -167,20 +167,11 @@ unsigned long long read_size(struct pevent *pevent, void *ptr, int size) | |||
167 | return pevent_read_number(pevent, ptr, size); | 167 | return pevent_read_number(pevent, ptr, size); |
168 | } | 168 | } |
169 | 169 | ||
170 | void print_trace_event(struct pevent *pevent, int cpu, void *data, int size) | 170 | void event_format__print(struct event_format *event, |
171 | int cpu, void *data, int size) | ||
171 | { | 172 | { |
172 | struct event_format *event; | ||
173 | struct pevent_record record; | 173 | struct pevent_record record; |
174 | struct trace_seq s; | 174 | struct trace_seq s; |
175 | int type; | ||
176 | |||
177 | type = trace_parse_common_type(pevent, data); | ||
178 | |||
179 | event = pevent_find_event(pevent, type); | ||
180 | if (!event) { | ||
181 | warning("ug! no event found for type %d", type); | ||
182 | return; | ||
183 | } | ||
184 | 175 | ||
185 | memset(&record, 0, sizeof(record)); | 176 | memset(&record, 0, sizeof(record)); |
186 | record.cpu = cpu; | 177 | record.cpu = cpu; |
@@ -192,6 +183,19 @@ void print_trace_event(struct pevent *pevent, int cpu, void *data, int size) | |||
192 | trace_seq_do_printf(&s); | 183 | trace_seq_do_printf(&s); |
193 | } | 184 | } |
194 | 185 | ||
186 | void print_trace_event(struct pevent *pevent, int cpu, void *data, int size) | ||
187 | { | ||
188 | int type = trace_parse_common_type(pevent, data); | ||
189 | struct event_format *event = pevent_find_event(pevent, type); | ||
190 | |||
191 | if (!event) { | ||
192 | warning("ug! no event found for type %d", type); | ||
193 | return; | ||
194 | } | ||
195 | |||
196 | event_format__print(event, cpu, data, size); | ||
197 | } | ||
198 | |||
195 | void print_event(struct pevent *pevent, int cpu, void *data, int size, | 199 | void print_event(struct pevent *pevent, int cpu, void *data, int size, |
196 | unsigned long long nsecs, char *comm) | 200 | unsigned long long nsecs, char *comm) |
197 | { | 201 | { |