aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-05-14 09:36:42 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-05-14 09:36:42 -0400
commitc8446b9bdabcb0caa61bb341bd73c58f7104b503 (patch)
treeb2530bfbbd893017e9515bd48f2ffa8845860759
parent5d2be7cb198a0a6bc6088d3806fb7261b184ad89 (diff)
perf hist: Make event__totals per hists
This is one more thing that started global but are more useful per hist or per session. Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-annotate.c2
-rw-r--r--tools/perf/builtin-report.c8
-rw-r--r--tools/perf/util/event.c17
-rw-r--r--tools/perf/util/event.h2
-rw-r--r--tools/perf/util/hist.c21
-rw-r--r--tools/perf/util/hist.h6
-rw-r--r--tools/perf/util/session.c36
-rw-r--r--tools/perf/util/session.h8
8 files changed, 62 insertions, 38 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index fd1b786c8f35..77bcc9b130f5 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -365,7 +365,7 @@ static int __cmd_annotate(void)
365 goto out_delete; 365 goto out_delete;
366 366
367 if (dump_trace) { 367 if (dump_trace) {
368 event__print_totals(); 368 perf_session__fprintf_nr_events(session, stdout);
369 goto out_delete; 369 goto out_delete;
370 } 370 }
371 371
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 04de3387de3f..f13cda1ef059 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -139,6 +139,12 @@ static int add_event_total(struct perf_session *session,
139 return -ENOMEM; 139 return -ENOMEM;
140 140
141 hists->stats.total += data->period; 141 hists->stats.total += data->period;
142 /*
143 * FIXME: add_event_total should be moved from here to
144 * perf_session__process_event so that the proper hist is passed to
145 * the event_op methods.
146 */
147 hists__inc_nr_events(hists, PERF_RECORD_SAMPLE);
142 session->hists.stats.total += data->period; 148 session->hists.stats.total += data->period;
143 return 0; 149 return 0;
144} 150}
@@ -293,7 +299,7 @@ static int __cmd_report(void)
293 goto out_delete; 299 goto out_delete;
294 300
295 if (dump_trace) { 301 if (dump_trace) {
296 event__print_totals(); 302 perf_session__fprintf_nr_events(session, stdout);
297 goto out_delete; 303 goto out_delete;
298 } 304 }
299 305
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index cce006ec8f05..3e8fec173041 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -7,6 +7,23 @@
7#include "strlist.h" 7#include "strlist.h"
8#include "thread.h" 8#include "thread.h"
9 9
10const char *event__name[] = {
11 [0] = "TOTAL",
12 [PERF_RECORD_MMAP] = "MMAP",
13 [PERF_RECORD_LOST] = "LOST",
14 [PERF_RECORD_COMM] = "COMM",
15 [PERF_RECORD_EXIT] = "EXIT",
16 [PERF_RECORD_THROTTLE] = "THROTTLE",
17 [PERF_RECORD_UNTHROTTLE] = "UNTHROTTLE",
18 [PERF_RECORD_FORK] = "FORK",
19 [PERF_RECORD_READ] = "READ",
20 [PERF_RECORD_SAMPLE] = "SAMPLE",
21 [PERF_RECORD_HEADER_ATTR] = "ATTR",
22 [PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE",
23 [PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA",
24 [PERF_RECORD_HEADER_BUILD_ID] = "BUILD_ID",
25};
26
10static pid_t event__synthesize_comm(pid_t pid, int full, 27static pid_t event__synthesize_comm(pid_t pid, int full,
11 event__handler_t process, 28 event__handler_t process,
12 struct perf_session *session) 29 struct perf_session *session)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 48c2cc9dae4f..8577085db067 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -160,4 +160,6 @@ 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, symbol_filter_t filter);
161int event__parse_sample(event_t *event, u64 type, struct sample_data *data); 161int event__parse_sample(event_t *event, u64 type, struct sample_data *data);
162 162
163extern const char *event__name[];
164
163#endif /* __PERF_RECORD_H */ 165#endif /* __PERF_RECORD_H */
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 5dc4f8429eda..1614ad710046 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1028,3 +1028,24 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head)
1028 pclose(file); 1028 pclose(file);
1029 return 0; 1029 return 0;
1030} 1030}
1031
1032void hists__inc_nr_events(struct hists *self, u32 type)
1033{
1034 ++self->hists.stats.nr_events[0];
1035 ++self->hists.stats.nr_events[type];
1036}
1037
1038size_t hists__fprintf_nr_events(struct hists *self, FILE *fp)
1039{
1040 int i;
1041 size_t ret = 0;
1042
1043 for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
1044 if (!event__name[i])
1045 continue;
1046 ret += fprintf(fp, "%10s events: %10d\n",
1047 event__name[i], self->stats.nr_events[i]);
1048 }
1049
1050 return ret;
1051}
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 0b4c8df914bd..97b8962ff69a 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -40,6 +40,8 @@ struct sym_priv {
40struct events_stats { 40struct events_stats {
41 u64 total; 41 u64 total;
42 u64 lost; 42 u64 lost;
43 u32 nr_events[PERF_RECORD_HEADER_MAX];
44 u32 nr_unknown_events;
43}; 45};
44 46
45struct hists { 47struct hists {
@@ -68,6 +70,10 @@ void hist_entry__free(struct hist_entry *);
68 70
69void hists__output_resort(struct hists *self); 71void hists__output_resort(struct hists *self);
70void hists__collapse_resort(struct hists *self); 72void hists__collapse_resort(struct hists *self);
73
74void hists__inc_nr_events(struct hists *self, u32 type);
75size_t hists__fprintf_nr_events(struct hists *self, FILE *fp);
76
71size_t hists__fprintf(struct hists *self, struct hists *pair, 77size_t hists__fprintf(struct hists *self, struct hists *pair,
72 bool show_displacement, FILE *fp); 78 bool show_displacement, FILE *fp);
73 79
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 72a7f6ae0293..7231f6b19fb4 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -94,7 +94,6 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc
94 self->mmap_window = 32; 94 self->mmap_window = 32;
95 self->cwd = NULL; 95 self->cwd = NULL;
96 self->cwdlen = 0; 96 self->cwdlen = 0;
97 self->unknown_events = 0;
98 self->machines = RB_ROOT; 97 self->machines = RB_ROOT;
99 self->repipe = repipe; 98 self->repipe = repipe;
100 INIT_LIST_HEAD(&self->ordered_samples.samples_head); 99 INIT_LIST_HEAD(&self->ordered_samples.samples_head);
@@ -241,36 +240,6 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
241 } 240 }
242} 241}
243 242
244static const char *event__name[] = {
245 [0] = "TOTAL",
246 [PERF_RECORD_MMAP] = "MMAP",
247 [PERF_RECORD_LOST] = "LOST",
248 [PERF_RECORD_COMM] = "COMM",
249 [PERF_RECORD_EXIT] = "EXIT",
250 [PERF_RECORD_THROTTLE] = "THROTTLE",
251 [PERF_RECORD_UNTHROTTLE] = "UNTHROTTLE",
252 [PERF_RECORD_FORK] = "FORK",
253 [PERF_RECORD_READ] = "READ",
254 [PERF_RECORD_SAMPLE] = "SAMPLE",
255 [PERF_RECORD_HEADER_ATTR] = "ATTR",
256 [PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE",
257 [PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA",
258 [PERF_RECORD_HEADER_BUILD_ID] = "BUILD_ID",
259};
260
261unsigned long event__total[PERF_RECORD_HEADER_MAX];
262
263void event__print_totals(void)
264{
265 int i;
266 for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
267 if (!event__name[i])
268 continue;
269 pr_info("%10s events: %10ld\n",
270 event__name[i], event__total[i]);
271 }
272}
273
274void mem_bswap_64(void *src, int byte_size) 243void mem_bswap_64(void *src, int byte_size)
275{ 244{
276 u64 *m = src; 245 u64 *m = src;
@@ -580,8 +549,7 @@ static int perf_session__process_event(struct perf_session *self,
580 dump_printf("%#Lx [%#x]: PERF_RECORD_%s", 549 dump_printf("%#Lx [%#x]: PERF_RECORD_%s",
581 offset + head, event->header.size, 550 offset + head, event->header.size,
582 event__name[event->header.type]); 551 event__name[event->header.type]);
583 ++event__total[0]; 552 hists__inc_nr_events(self, event->header.type);
584 ++event__total[event->header.type];
585 } 553 }
586 554
587 if (self->header.needs_swap && event__swap_ops[event->header.type]) 555 if (self->header.needs_swap && event__swap_ops[event->header.type])
@@ -619,7 +587,7 @@ static int perf_session__process_event(struct perf_session *self,
619 case PERF_RECORD_FINISHED_ROUND: 587 case PERF_RECORD_FINISHED_ROUND:
620 return ops->finished_round(event, self, ops); 588 return ops->finished_round(event, self, ops);
621 default: 589 default:
622 self->unknown_events++; 590 ++self->hists.stats.nr_unknown_events;
623 return -1; 591 return -1;
624 } 592 }
625} 593}
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index ce00fa6cdeda..e7fce486ebe2 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -30,8 +30,6 @@ struct perf_session {
30 struct machine host_machine; 30 struct machine host_machine;
31 struct rb_root machines; 31 struct rb_root machines;
32 struct rb_root hists_tree; 32 struct rb_root hists_tree;
33 unsigned long event_total[PERF_RECORD_MAX];
34 unsigned long unknown_events;
35 /* 33 /*
36 * FIXME: should point to the first entry in hists_tree and 34 * FIXME: should point to the first entry in hists_tree and
37 * be a hists instance. Right now its only 'report' 35 * be a hists instance. Right now its only 'report'
@@ -140,4 +138,10 @@ size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
140{ 138{
141 return machines__fprintf_dsos_buildid(&self->machines, fp, with_hits); 139 return machines__fprintf_dsos_buildid(&self->machines, fp, with_hits);
142} 140}
141
142static inline
143size_t perf_session__fprintf_nr_events(struct perf_session *self, FILE *fp)
144{
145 return hists__fprintf_nr_events(&self->hists, fp);
146}
143#endif /* __PERF_SESSION_H */ 147#endif /* __PERF_SESSION_H */