aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-13 16:50:24 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-14 10:57:13 -0500
commitd8f66248d6f25f7c935cc5307c43bf394db07272 (patch)
treef30b5512dd08e6a8713fa9fde158c75d57ce1d6b /tools/perf/util
parent2cd9046cc53dd2625e2cf5854d6cbb1ba61de914 (diff)
perf session: Pass the perf_session to the event handling operations
They will need it to get the right threads list, etc. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1260741029-4430-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/data_map.c27
-rw-r--r--tools/perf/util/data_map.h5
-rw-r--r--tools/perf/util/event.c37
-rw-r--r--tools/perf/util/event.h19
4 files changed, 54 insertions, 34 deletions
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c
index 6d46dda53a29..22bcdfeff55c 100644
--- a/tools/perf/util/data_map.c
+++ b/tools/perf/util/data_map.c
@@ -8,7 +8,8 @@ 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 process_event_stub(event_t *event __used) 11static int process_event_stub(event_t *event __used,
12 struct perf_session *session __used)
12{ 13{
13 dump_printf(": unhandled!\n"); 14 dump_printf(": unhandled!\n");
14 return 0; 15 return 0;
@@ -61,8 +62,8 @@ void event__print_totals(void)
61 event__name[i], event__total[i]); 62 event__name[i], event__total[i]);
62} 63}
63 64
64static int 65static int process_event(event_t *event, struct perf_session *session,
65process_event(event_t *event, unsigned long offset, unsigned long head) 66 unsigned long offset, unsigned long head)
66{ 67{
67 trace_event(event); 68 trace_event(event);
68 69
@@ -77,23 +78,23 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
77 78
78 switch (event->header.type) { 79 switch (event->header.type) {
79 case PERF_RECORD_SAMPLE: 80 case PERF_RECORD_SAMPLE:
80 return curr_handler->process_sample_event(event); 81 return curr_handler->process_sample_event(event, session);
81 case PERF_RECORD_MMAP: 82 case PERF_RECORD_MMAP:
82 return curr_handler->process_mmap_event(event); 83 return curr_handler->process_mmap_event(event, session);
83 case PERF_RECORD_COMM: 84 case PERF_RECORD_COMM:
84 return curr_handler->process_comm_event(event); 85 return curr_handler->process_comm_event(event, session);
85 case PERF_RECORD_FORK: 86 case PERF_RECORD_FORK:
86 return curr_handler->process_fork_event(event); 87 return curr_handler->process_fork_event(event, session);
87 case PERF_RECORD_EXIT: 88 case PERF_RECORD_EXIT:
88 return curr_handler->process_exit_event(event); 89 return curr_handler->process_exit_event(event, session);
89 case PERF_RECORD_LOST: 90 case PERF_RECORD_LOST:
90 return curr_handler->process_lost_event(event); 91 return curr_handler->process_lost_event(event, session);
91 case PERF_RECORD_READ: 92 case PERF_RECORD_READ:
92 return curr_handler->process_read_event(event); 93 return curr_handler->process_read_event(event, session);
93 case PERF_RECORD_THROTTLE: 94 case PERF_RECORD_THROTTLE:
94 return curr_handler->process_throttle_event(event); 95 return curr_handler->process_throttle_event(event, session);
95 case PERF_RECORD_UNTHROTTLE: 96 case PERF_RECORD_UNTHROTTLE:
96 return curr_handler->process_unthrottle_event(event); 97 return curr_handler->process_unthrottle_event(event, session);
97 default: 98 default:
98 curr_handler->total_unknown++; 99 curr_handler->total_unknown++;
99 return -1; 100 return -1;
@@ -209,7 +210,7 @@ more:
209 (void *)(long)event->header.size, 210 (void *)(long)event->header.size,
210 event->header.type); 211 event->header.type);
211 212
212 if (!size || process_event(event, offset, head) < 0) { 213 if (!size || process_event(event, self, offset, head) < 0) {
213 214
214 dump_printf("%p [%p]: skipping unknown header type: %d\n", 215 dump_printf("%p [%p]: skipping unknown header type: %d\n",
215 (void *)(offset + head), 216 (void *)(offset + head),
diff --git a/tools/perf/util/data_map.h b/tools/perf/util/data_map.h
index 98c5b823388c..6d4ae52bc07b 100644
--- a/tools/perf/util/data_map.h
+++ b/tools/perf/util/data_map.h
@@ -5,7 +5,10 @@
5#include "header.h" 5#include "header.h"
6#include "session.h" 6#include "session.h"
7 7
8typedef int (*event_type_handler_t)(event_t *); 8struct perf_session;
9
10typedef int (*event_type_handler_t)(event_t *self,
11 struct perf_session *session);
9 12
10struct perf_file_handler { 13struct perf_file_handler {
11 event_type_handler_t process_sample_event; 14 event_type_handler_t process_sample_event;
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index ba0de90cd3d4..e2c489533c6d 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -5,7 +5,9 @@
5#include "thread.h" 5#include "thread.h"
6 6
7static pid_t event__synthesize_comm(pid_t pid, int full, 7static pid_t event__synthesize_comm(pid_t pid, int full,
8 int (*process)(event_t *event)) 8 int (*process)(event_t *event,
9 struct perf_session *session),
10 struct perf_session *session)
9{ 11{
10 event_t ev; 12 event_t ev;
11 char filename[PATH_MAX]; 13 char filename[PATH_MAX];
@@ -54,7 +56,7 @@ out_race:
54 if (!full) { 56 if (!full) {
55 ev.comm.tid = pid; 57 ev.comm.tid = pid;
56 58
57 process(&ev); 59 process(&ev, session);
58 goto out_fclose; 60 goto out_fclose;
59 } 61 }
60 62
@@ -72,7 +74,7 @@ out_race:
72 74
73 ev.comm.tid = pid; 75 ev.comm.tid = pid;
74 76
75 process(&ev); 77 process(&ev, session);
76 } 78 }
77 closedir(tasks); 79 closedir(tasks);
78 80
@@ -86,7 +88,9 @@ out_failure:
86} 88}
87 89
88static int event__synthesize_mmap_events(pid_t pid, pid_t tgid, 90static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
89 int (*process)(event_t *event)) 91 int (*process)(event_t *event,
92 struct perf_session *session),
93 struct perf_session *session)
90{ 94{
91 char filename[PATH_MAX]; 95 char filename[PATH_MAX];
92 FILE *fp; 96 FILE *fp;
@@ -141,7 +145,7 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
141 ev.mmap.pid = tgid; 145 ev.mmap.pid = tgid;
142 ev.mmap.tid = pid; 146 ev.mmap.tid = pid;
143 147
144 process(&ev); 148 process(&ev, session);
145 } 149 }
146 } 150 }
147 151
@@ -149,15 +153,20 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
149 return 0; 153 return 0;
150} 154}
151 155
152int event__synthesize_thread(pid_t pid, int (*process)(event_t *event)) 156int event__synthesize_thread(pid_t pid,
157 int (*process)(event_t *event,
158 struct perf_session *session),
159 struct perf_session *session)
153{ 160{
154 pid_t tgid = event__synthesize_comm(pid, 1, process); 161 pid_t tgid = event__synthesize_comm(pid, 1, process, session);
155 if (tgid == -1) 162 if (tgid == -1)
156 return -1; 163 return -1;
157 return event__synthesize_mmap_events(pid, tgid, process); 164 return event__synthesize_mmap_events(pid, tgid, process, session);
158} 165}
159 166
160void event__synthesize_threads(int (*process)(event_t *event)) 167void event__synthesize_threads(int (*process)(event_t *event,
168 struct perf_session *session),
169 struct perf_session *session)
161{ 170{
162 DIR *proc; 171 DIR *proc;
163 struct dirent dirent, *next; 172 struct dirent dirent, *next;
@@ -171,7 +180,7 @@ void event__synthesize_threads(int (*process)(event_t *event))
171 if (*end) /* only interested in proper numerical dirents */ 180 if (*end) /* only interested in proper numerical dirents */
172 continue; 181 continue;
173 182
174 event__synthesize_thread(pid, process); 183 event__synthesize_thread(pid, process, session);
175 } 184 }
176 185
177 closedir(proc); 186 closedir(proc);
@@ -182,7 +191,7 @@ int event__cwdlen;
182 191
183struct events_stats event__stats; 192struct events_stats event__stats;
184 193
185int event__process_comm(event_t *self) 194int event__process_comm(event_t *self, struct perf_session *session __used)
186{ 195{
187 struct thread *thread = threads__findnew(self->comm.pid); 196 struct thread *thread = threads__findnew(self->comm.pid);
188 197
@@ -196,14 +205,14 @@ int event__process_comm(event_t *self)
196 return 0; 205 return 0;
197} 206}
198 207
199int event__process_lost(event_t *self) 208int event__process_lost(event_t *self, struct perf_session *session __used)
200{ 209{
201 dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); 210 dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost);
202 event__stats.lost += self->lost.lost; 211 event__stats.lost += self->lost.lost;
203 return 0; 212 return 0;
204} 213}
205 214
206int event__process_mmap(event_t *self) 215int event__process_mmap(event_t *self, struct perf_session *session __used)
207{ 216{
208 struct thread *thread = threads__findnew(self->mmap.pid); 217 struct thread *thread = threads__findnew(self->mmap.pid);
209 struct map *map = map__new(&self->mmap, MAP__FUNCTION, 218 struct map *map = map__new(&self->mmap, MAP__FUNCTION,
@@ -224,7 +233,7 @@ int event__process_mmap(event_t *self)
224 return 0; 233 return 0;
225} 234}
226 235
227int event__process_task(event_t *self) 236int event__process_task(event_t *self, struct perf_session *session __used)
228{ 237{
229 struct thread *thread = threads__findnew(self->fork.pid); 238 struct thread *thread = threads__findnew(self->fork.pid);
230 struct thread *parent = threads__findnew(self->fork.ppid); 239 struct thread *parent = threads__findnew(self->fork.ppid);
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 51a96c2effde..6b6429b63da3 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -156,18 +156,25 @@ struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
156void map__fixup_start(struct map *self); 156void map__fixup_start(struct map *self);
157void map__fixup_end(struct map *self); 157void map__fixup_end(struct map *self);
158 158
159int event__synthesize_thread(pid_t pid, int (*process)(event_t *event)); 159struct perf_session;
160void event__synthesize_threads(int (*process)(event_t *event)); 160
161int event__synthesize_thread(pid_t pid,
162 int (*process)(event_t *event,
163 struct perf_session *session),
164 struct perf_session *session);
165void event__synthesize_threads(int (*process)(event_t *event,
166 struct perf_session *session),
167 struct perf_session *session);
161 168
162extern char *event__cwd; 169extern char *event__cwd;
163extern int event__cwdlen; 170extern int event__cwdlen;
164extern struct events_stats event__stats; 171extern struct events_stats event__stats;
165extern unsigned long event__total[PERF_RECORD_MAX]; 172extern unsigned long event__total[PERF_RECORD_MAX];
166 173
167int event__process_comm(event_t *self); 174int event__process_comm(event_t *self, struct perf_session *session);
168int event__process_lost(event_t *self); 175int event__process_lost(event_t *self, struct perf_session *session);
169int event__process_mmap(event_t *self); 176int event__process_mmap(event_t *self, struct perf_session *session);
170int event__process_task(event_t *self); 177int event__process_task(event_t *self, struct perf_session *session);
171 178
172struct addr_location; 179struct addr_location;
173int event__preprocess_sample(const event_t *self, struct addr_location *al, 180int event__preprocess_sample(const event_t *self, struct addr_location *al,