aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/data_map.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-27 13:29:22 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-27 14:22:01 -0500
commit62daacb51a2bf8480e6f6b3696b03f102fc15eb0 (patch)
tree5b9ed87005a5e59bcc95dd9a42e3d09d6481362d /tools/perf/util/data_map.c
parent1de8e24520ffdcf2a90c842eed937f59079a2abd (diff)
perf tools: Reorganize event processing routines, lotsa dups killed
While implementing event__preprocess_sample, that will do all of the symbol lookup in one convenient function, I noticed that util/process_event.[ch] were not being used at all, then started looking if there were other functions that could be shared and... All those functions really don't need to receive offset + head, the only thing they did was common to all of them, so do it at one place instead. Stats about number of each type of event processed now is done in a central place. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: John Kacur <jkacur@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1259346563-12568-11-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/data_map.c')
-rw-r--r--tools/perf/util/data_map.c56
1 files changed, 43 insertions, 13 deletions
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c
index b238462b898..ca0bedf637c 100644
--- a/tools/perf/util/data_map.c
+++ b/tools/perf/util/data_map.c
@@ -8,11 +8,9 @@ static struct perf_file_handler *curr_handler;
8static unsigned long mmap_window = 32; 8static unsigned long mmap_window = 32;
9static char __cwd[PATH_MAX]; 9static char __cwd[PATH_MAX];
10 10
11static int 11static int process_event_stub(event_t *event __used)
12process_event_stub(event_t *event __used,
13 unsigned long offset __used,
14 unsigned long head __used)
15{ 12{
13 dump_printf(": unhandled!\n");
16 return 0; 14 return 0;
17} 15}
18 16
@@ -40,30 +38,62 @@ void register_perf_file_handler(struct perf_file_handler *handler)
40 curr_handler = handler; 38 curr_handler = handler;
41} 39}
42 40
41static const char *event__name[] = {
42 [0] = "TOTAL",
43 [PERF_RECORD_MMAP] = "MMAP",
44 [PERF_RECORD_LOST] = "LOST",
45 [PERF_RECORD_COMM] = "COMM",
46 [PERF_RECORD_EXIT] = "EXIT",
47 [PERF_RECORD_THROTTLE] = "THROTTLE",
48 [PERF_RECORD_UNTHROTTLE] = "UNTHROTTLE",
49 [PERF_RECORD_FORK] = "FORK",
50 [PERF_RECORD_READ] = "READ",
51 [PERF_RECORD_SAMPLE] = "SAMPLE",
52};
53
54unsigned long event__total[PERF_RECORD_MAX];
55
56void event__print_totals(void)
57{
58 int i;
59 for (i = 0; i < PERF_RECORD_MAX; ++i)
60 pr_info("%10s events: %10ld\n",
61 event__name[i], event__total[i]);
62}
63
43static int 64static int
44process_event(event_t *event, unsigned long offset, unsigned long head) 65process_event(event_t *event, unsigned long offset, unsigned long head)
45{ 66{
46 trace_event(event); 67 trace_event(event);
47 68
69 if (event->header.type < PERF_RECORD_MAX) {
70 dump_printf("%p [%p]: PERF_RECORD_%s",
71 (void *)(offset + head),
72 (void *)(long)(event->header.size),
73 event__name[event->header.type]);
74 ++event__total[0];
75 ++event__total[event->header.type];
76 }
77
48 switch (event->header.type) { 78 switch (event->header.type) {
49 case PERF_RECORD_SAMPLE: 79 case PERF_RECORD_SAMPLE:
50 return curr_handler->process_sample_event(event, offset, head); 80 return curr_handler->process_sample_event(event);
51 case PERF_RECORD_MMAP: 81 case PERF_RECORD_MMAP:
52 return curr_handler->process_mmap_event(event, offset, head); 82 return curr_handler->process_mmap_event(event);
53 case PERF_RECORD_COMM: 83 case PERF_RECORD_COMM:
54 return curr_handler->process_comm_event(event, offset, head); 84 return curr_handler->process_comm_event(event);
55 case PERF_RECORD_FORK: 85 case PERF_RECORD_FORK:
56 return curr_handler->process_fork_event(event, offset, head); 86 return curr_handler->process_fork_event(event);
57 case PERF_RECORD_EXIT: 87 case PERF_RECORD_EXIT:
58 return curr_handler->process_exit_event(event, offset, head); 88 return curr_handler->process_exit_event(event);
59 case PERF_RECORD_LOST: 89 case PERF_RECORD_LOST:
60 return curr_handler->process_lost_event(event, offset, head); 90 return curr_handler->process_lost_event(event);
61 case PERF_RECORD_READ: 91 case PERF_RECORD_READ:
62 return curr_handler->process_read_event(event, offset, head); 92 return curr_handler->process_read_event(event);
63 case PERF_RECORD_THROTTLE: 93 case PERF_RECORD_THROTTLE:
64 return curr_handler->process_throttle_event(event, offset, head); 94 return curr_handler->process_throttle_event(event);
65 case PERF_RECORD_UNTHROTTLE: 95 case PERF_RECORD_UNTHROTTLE:
66 return curr_handler->process_unthrottle_event(event, offset, head); 96 return curr_handler->process_unthrottle_event(event);
67 default: 97 default:
68 curr_handler->total_unknown++; 98 curr_handler->total_unknown++;
69 return -1; 99 return -1;