diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-27 13:29:22 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-27 14:22:01 -0500 |
commit | 62daacb51a2bf8480e6f6b3696b03f102fc15eb0 (patch) | |
tree | 5b9ed87005a5e59bcc95dd9a42e3d09d6481362d /tools/perf/util/event.c | |
parent | 1de8e24520ffdcf2a90c842eed937f59079a2abd (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/event.c')
-rw-r--r-- | tools/perf/util/event.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 1dae7e3b400d..70b4aa03b472 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include "event.h" | 2 | #include "event.h" |
3 | #include "debug.h" | 3 | #include "debug.h" |
4 | #include "string.h" | 4 | #include "string.h" |
5 | #include "thread.h" | ||
5 | 6 | ||
6 | static pid_t event__synthesize_comm(pid_t pid, int full, | 7 | static pid_t event__synthesize_comm(pid_t pid, int full, |
7 | int (*process)(event_t *event)) | 8 | int (*process)(event_t *event)) |
@@ -175,3 +176,76 @@ void event__synthesize_threads(int (*process)(event_t *event)) | |||
175 | 176 | ||
176 | closedir(proc); | 177 | closedir(proc); |
177 | } | 178 | } |
179 | |||
180 | char *event__cwd; | ||
181 | int event__cwdlen; | ||
182 | |||
183 | struct events_stats event__stats; | ||
184 | |||
185 | int event__process_comm(event_t *self) | ||
186 | { | ||
187 | struct thread *thread = threads__findnew(self->comm.pid); | ||
188 | |||
189 | dump_printf("PERF_RECORD_COMM: %s:%d\n", | ||
190 | self->comm.comm, self->comm.pid); | ||
191 | |||
192 | if (thread == NULL || thread__set_comm(thread, self->comm.comm)) { | ||
193 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); | ||
194 | return -1; | ||
195 | } | ||
196 | |||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | int event__process_lost(event_t *self) | ||
201 | { | ||
202 | dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); | ||
203 | event__stats.lost += self->lost.lost; | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | int event__process_mmap(event_t *self) | ||
208 | { | ||
209 | struct thread *thread = threads__findnew(self->mmap.pid); | ||
210 | struct map *map = map__new(&self->mmap, MAP__FUNCTION, | ||
211 | event__cwd, event__cwdlen); | ||
212 | |||
213 | dump_printf(" %d/%d: [%p(%p) @ %p]: %s\n", | ||
214 | self->mmap.pid, self->mmap.tid, | ||
215 | (void *)(long)self->mmap.start, | ||
216 | (void *)(long)self->mmap.len, | ||
217 | (void *)(long)self->mmap.pgoff, | ||
218 | self->mmap.filename); | ||
219 | |||
220 | if (thread == NULL || map == NULL) | ||
221 | dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n"); | ||
222 | else | ||
223 | thread__insert_map(thread, map); | ||
224 | |||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | int event__process_task(event_t *self) | ||
229 | { | ||
230 | struct thread *thread = threads__findnew(self->fork.pid); | ||
231 | struct thread *parent = threads__findnew(self->fork.ppid); | ||
232 | |||
233 | dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid, | ||
234 | self->fork.ppid, self->fork.ptid); | ||
235 | /* | ||
236 | * A thread clone will have the same PID for both parent and child. | ||
237 | */ | ||
238 | if (thread == parent) | ||
239 | return 0; | ||
240 | |||
241 | if (self->header.type == PERF_RECORD_EXIT) | ||
242 | return 0; | ||
243 | |||
244 | if (thread == NULL || parent == NULL || | ||
245 | thread__fork(thread, parent) < 0) { | ||
246 | dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n"); | ||
247 | return -1; | ||
248 | } | ||
249 | |||
250 | return 0; | ||
251 | } | ||