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/builtin-lock.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/builtin-lock.c')
-rw-r--r-- | tools/perf/builtin-lock.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index b3c428548868..142b3033e4be 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "builtin.h" | 1 | #include "builtin.h" |
2 | #include "perf.h" | 2 | #include "perf.h" |
3 | 3 | ||
4 | #include "util/evsel.h" | ||
4 | #include "util/util.h" | 5 | #include "util/util.h" |
5 | #include "util/cache.h" | 6 | #include "util/cache.h" |
6 | #include "util/symbol.h" | 7 | #include "util/symbol.h" |
@@ -718,14 +719,10 @@ process_lock_release_event(void *data, | |||
718 | trace_handler->release_event(&release_event, event, cpu, timestamp, thread); | 719 | trace_handler->release_event(&release_event, event, cpu, timestamp, thread); |
719 | } | 720 | } |
720 | 721 | ||
721 | static void | 722 | static void process_raw_event(struct perf_evsel *evsel, void *data, int cpu, |
722 | process_raw_event(void *data, int cpu, u64 timestamp, struct thread *thread) | 723 | u64 timestamp, struct thread *thread) |
723 | { | 724 | { |
724 | struct event_format *event; | 725 | struct event_format *event = evsel->tp_format; |
725 | int type; | ||
726 | |||
727 | type = trace_parse_common_type(session->pevent, data); | ||
728 | event = pevent_find_event(session->pevent, type); | ||
729 | 726 | ||
730 | if (!strcmp(event->name, "lock_acquire")) | 727 | if (!strcmp(event->name, "lock_acquire")) |
731 | process_lock_acquire_event(data, event, cpu, timestamp, thread); | 728 | process_lock_acquire_event(data, event, cpu, timestamp, thread); |
@@ -849,7 +846,7 @@ static void dump_info(void) | |||
849 | static int process_sample_event(struct perf_tool *tool __used, | 846 | static int process_sample_event(struct perf_tool *tool __used, |
850 | union perf_event *event, | 847 | union perf_event *event, |
851 | struct perf_sample *sample, | 848 | struct perf_sample *sample, |
852 | struct perf_evsel *evsel __used, | 849 | struct perf_evsel *evsel, |
853 | struct machine *machine) | 850 | struct machine *machine) |
854 | { | 851 | { |
855 | struct thread *thread = machine__findnew_thread(machine, sample->tid); | 852 | struct thread *thread = machine__findnew_thread(machine, sample->tid); |
@@ -860,7 +857,7 @@ static int process_sample_event(struct perf_tool *tool __used, | |||
860 | return -1; | 857 | return -1; |
861 | } | 858 | } |
862 | 859 | ||
863 | process_raw_event(sample->raw_data, sample->cpu, sample->time, thread); | 860 | process_raw_event(evsel, sample->raw_data, sample->cpu, sample->time, thread); |
864 | 861 | ||
865 | return 0; | 862 | return 0; |
866 | } | 863 | } |