diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-06-04 07:02:07 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-06-05 08:35:19 -0400 |
commit | 41a37e20178b081193b08b228030d8f562bfee62 (patch) | |
tree | 126bc2f2f11231955fad89bf2ef6e83969b6325e /tools/perf/util | |
parent | 45d8e8025a2b2a6996be92d769fb6763bfb3cbae (diff) |
perf tools: Make event__preprocess_sample parse the sample
Simplifying the tools that were using both in sequence and allowing
upcoming simplifications, such as Arun's patch to sort by cpus.
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric 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/util')
-rw-r--r-- | tools/perf/util/callchain.c | 2 | ||||
-rw-r--r-- | tools/perf/util/callchain.h | 2 | ||||
-rw-r--r-- | tools/perf/util/event.c | 33 | ||||
-rw-r--r-- | tools/perf/util/event.h | 5 |
4 files changed, 34 insertions, 8 deletions
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 62b69ad4aa73..e63c997d6c1b 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include "util.h" | 18 | #include "util.h" |
19 | #include "callchain.h" | 19 | #include "callchain.h" |
20 | 20 | ||
21 | bool ip_callchain__valid(struct ip_callchain *chain, event_t *event) | 21 | bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event) |
22 | { | 22 | { |
23 | unsigned int chain_size = event->header.size; | 23 | unsigned int chain_size = event->header.size; |
24 | chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event; | 24 | chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event; |
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 1ca73e4a2723..809850fb75fb 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h | |||
@@ -60,5 +60,5 @@ int register_callchain_param(struct callchain_param *param); | |||
60 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, | 60 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, |
61 | struct map_symbol *syms); | 61 | struct map_symbol *syms); |
62 | 62 | ||
63 | bool ip_callchain__valid(struct ip_callchain *chain, event_t *event); | 63 | bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event); |
64 | #endif /* __PERF_CALLCHAIN_H */ | 64 | #endif /* __PERF_CALLCHAIN_H */ |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 891753255f54..ed3e14ff6df0 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -655,11 +655,36 @@ static void dso__calc_col_width(struct dso *self) | |||
655 | } | 655 | } |
656 | 656 | ||
657 | int event__preprocess_sample(const event_t *self, struct perf_session *session, | 657 | int event__preprocess_sample(const event_t *self, struct perf_session *session, |
658 | struct addr_location *al, symbol_filter_t filter) | 658 | struct addr_location *al, struct sample_data *data, |
659 | symbol_filter_t filter) | ||
659 | { | 660 | { |
660 | u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 661 | u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
661 | struct thread *thread = perf_session__findnew(session, self->ip.pid); | 662 | struct thread *thread; |
663 | |||
664 | event__parse_sample(self, session->sample_type, data); | ||
665 | |||
666 | dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld cpu:%d\n", | ||
667 | self->header.misc, data->pid, data->tid, data->ip, | ||
668 | data->period, data->cpu); | ||
669 | |||
670 | if (session->sample_type & PERF_SAMPLE_CALLCHAIN) { | ||
671 | unsigned int i; | ||
672 | |||
673 | dump_printf("... chain: nr:%Lu\n", data->callchain->nr); | ||
662 | 674 | ||
675 | if (!ip_callchain__valid(data->callchain, self)) { | ||
676 | pr_debug("call-chain problem with event, " | ||
677 | "skipping it.\n"); | ||
678 | goto out_filtered; | ||
679 | } | ||
680 | |||
681 | if (dump_trace) { | ||
682 | for (i = 0; i < data->callchain->nr; i++) | ||
683 | dump_printf("..... %2d: %016Lx\n", | ||
684 | i, data->callchain->ips[i]); | ||
685 | } | ||
686 | } | ||
687 | thread = perf_session__findnew(session, self->ip.pid); | ||
663 | if (thread == NULL) | 688 | if (thread == NULL) |
664 | return -1; | 689 | return -1; |
665 | 690 | ||
@@ -724,9 +749,9 @@ out_filtered: | |||
724 | return 0; | 749 | return 0; |
725 | } | 750 | } |
726 | 751 | ||
727 | int event__parse_sample(event_t *event, u64 type, struct sample_data *data) | 752 | int event__parse_sample(const event_t *event, u64 type, struct sample_data *data) |
728 | { | 753 | { |
729 | u64 *array = event->sample.array; | 754 | const u64 *array = event->sample.array; |
730 | 755 | ||
731 | if (type & PERF_SAMPLE_IP) { | 756 | if (type & PERF_SAMPLE_IP) { |
732 | data->ip = event->ip.ip; | 757 | data->ip = event->ip.ip; |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 8577085db067..887ee63bbb62 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -157,8 +157,9 @@ int event__process_task(event_t *self, struct perf_session *session); | |||
157 | 157 | ||
158 | struct addr_location; | 158 | struct addr_location; |
159 | int event__preprocess_sample(const event_t *self, struct perf_session *session, | 159 | int event__preprocess_sample(const event_t *self, struct perf_session *session, |
160 | struct addr_location *al, symbol_filter_t filter); | 160 | struct addr_location *al, struct sample_data *data, |
161 | int event__parse_sample(event_t *event, u64 type, struct sample_data *data); | 161 | symbol_filter_t filter); |
162 | int event__parse_sample(const event_t *event, u64 type, struct sample_data *data); | ||
162 | 163 | ||
163 | extern const char *event__name[]; | 164 | extern const char *event__name[]; |
164 | 165 | ||