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 | |
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')
-rw-r--r-- | tools/perf/builtin-annotate.c | 6 | ||||
-rw-r--r-- | tools/perf/builtin-diff.c | 7 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 26 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 4 | ||||
-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 |
8 files changed, 41 insertions, 44 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 96db5248e995..fd20670ce986 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -61,11 +61,9 @@ static int hists__add_entry(struct hists *self, struct addr_location *al) | |||
61 | static int process_sample_event(event_t *event, struct perf_session *session) | 61 | static int process_sample_event(event_t *event, struct perf_session *session) |
62 | { | 62 | { |
63 | struct addr_location al; | 63 | struct addr_location al; |
64 | struct sample_data data; | ||
64 | 65 | ||
65 | dump_printf("(IP, %d): %d: %#Lx\n", event->header.misc, | 66 | if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) { |
66 | event->ip.pid, event->ip.ip); | ||
67 | |||
68 | if (event__preprocess_sample(event, session, &al, NULL) < 0) { | ||
69 | pr_warning("problem processing %d event, skipping it.\n", | 67 | pr_warning("problem processing %d event, skipping it.\n", |
70 | event->header.type); | 68 | event->header.type); |
71 | return -1; | 69 | return -1; |
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index a6e2fdc7a04e..39e6627ebb96 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -35,10 +35,7 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi | |||
35 | struct addr_location al; | 35 | struct addr_location al; |
36 | struct sample_data data = { .period = 1, }; | 36 | struct sample_data data = { .period = 1, }; |
37 | 37 | ||
38 | dump_printf("(IP, %d): %d: %#Lx\n", event->header.misc, | 38 | if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) { |
39 | event->ip.pid, event->ip.ip); | ||
40 | |||
41 | if (event__preprocess_sample(event, session, &al, NULL) < 0) { | ||
42 | pr_warning("problem processing %d event, skipping it.\n", | 39 | pr_warning("problem processing %d event, skipping it.\n", |
43 | event->header.type); | 40 | event->header.type); |
44 | return -1; | 41 | return -1; |
@@ -47,8 +44,6 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi | |||
47 | if (al.filtered || al.sym == NULL) | 44 | if (al.filtered || al.sym == NULL) |
48 | return 0; | 45 | return 0; |
49 | 46 | ||
50 | event__parse_sample(event, session->sample_type, &data); | ||
51 | |||
52 | if (hists__add_entry(&session->hists, &al, data.period)) { | 47 | if (hists__add_entry(&session->hists, &al, data.period)) { |
53 | pr_warning("problem incrementing symbol period, skipping event\n"); | 48 | pr_warning("problem incrementing symbol period, skipping event\n"); |
54 | return -1; | 49 | return -1; |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 207da1849800..371a3c995806 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -155,31 +155,7 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
155 | struct addr_location al; | 155 | struct addr_location al; |
156 | struct perf_event_attr *attr; | 156 | struct perf_event_attr *attr; |
157 | 157 | ||
158 | event__parse_sample(event, session->sample_type, &data); | 158 | if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) { |
159 | |||
160 | dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld cpu:%d\n", | ||
161 | event->header.misc, data.pid, data.tid, data.ip, | ||
162 | data.period, data.cpu); | ||
163 | |||
164 | if (session->sample_type & PERF_SAMPLE_CALLCHAIN) { | ||
165 | unsigned int i; | ||
166 | |||
167 | dump_printf("... chain: nr:%Lu\n", data.callchain->nr); | ||
168 | |||
169 | if (!ip_callchain__valid(data.callchain, event)) { | ||
170 | pr_debug("call-chain problem with event, " | ||
171 | "skipping it.\n"); | ||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | if (dump_trace) { | ||
176 | for (i = 0; i < data.callchain->nr; i++) | ||
177 | dump_printf("..... %2d: %016Lx\n", | ||
178 | i, data.callchain->ips[i]); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | if (event__preprocess_sample(event, session, &al, NULL) < 0) { | ||
183 | fprintf(stderr, "problem processing %d event, skipping it.\n", | 159 | fprintf(stderr, "problem processing %d event, skipping it.\n", |
184 | event->header.type); | 160 | event->header.type); |
185 | return -1; | 161 | return -1; |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 45014ef11059..1e8e92e317b9 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -983,6 +983,7 @@ static void event__process_sample(const event_t *self, | |||
983 | u64 ip = self->ip.ip; | 983 | u64 ip = self->ip.ip; |
984 | struct sym_entry *syme; | 984 | struct sym_entry *syme; |
985 | struct addr_location al; | 985 | struct addr_location al; |
986 | struct sample_data data; | ||
986 | struct machine *machine; | 987 | struct machine *machine; |
987 | u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 988 | u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
988 | 989 | ||
@@ -1025,7 +1026,8 @@ static void event__process_sample(const event_t *self, | |||
1025 | if (self->header.misc & PERF_RECORD_MISC_EXACT_IP) | 1026 | if (self->header.misc & PERF_RECORD_MISC_EXACT_IP) |
1026 | exact_samples++; | 1027 | exact_samples++; |
1027 | 1028 | ||
1028 | if (event__preprocess_sample(self, session, &al, symbol_filter) < 0 || | 1029 | if (event__preprocess_sample(self, session, &al, &data, |
1030 | symbol_filter) < 0 || | ||
1029 | al.filtered) | 1031 | al.filtered) |
1030 | return; | 1032 | return; |
1031 | 1033 | ||
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 | ||