diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-13 16:50:24 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-14 10:57:13 -0500 |
commit | d8f66248d6f25f7c935cc5307c43bf394db07272 (patch) | |
tree | f30b5512dd08e6a8713fa9fde158c75d57ce1d6b /tools/perf/util | |
parent | 2cd9046cc53dd2625e2cf5854d6cbb1ba61de914 (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.c | 27 | ||||
-rw-r--r-- | tools/perf/util/data_map.h | 5 | ||||
-rw-r--r-- | tools/perf/util/event.c | 37 | ||||
-rw-r--r-- | tools/perf/util/event.h | 19 |
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; | |||
8 | static unsigned long mmap_window = 32; | 8 | static unsigned long mmap_window = 32; |
9 | static char __cwd[PATH_MAX]; | 9 | static char __cwd[PATH_MAX]; |
10 | 10 | ||
11 | static int process_event_stub(event_t *event __used) | 11 | static 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 | ||
64 | static int | 65 | static int process_event(event_t *event, struct perf_session *session, |
65 | process_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 | ||
8 | typedef int (*event_type_handler_t)(event_t *); | 8 | struct perf_session; |
9 | |||
10 | typedef int (*event_type_handler_t)(event_t *self, | ||
11 | struct perf_session *session); | ||
9 | 12 | ||
10 | struct perf_file_handler { | 13 | struct 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 | ||
7 | static pid_t event__synthesize_comm(pid_t pid, int full, | 7 | static 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 | ||
88 | static int event__synthesize_mmap_events(pid_t pid, pid_t tgid, | 90 | static 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 | ||
152 | int event__synthesize_thread(pid_t pid, int (*process)(event_t *event)) | 156 | int 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 | ||
160 | void event__synthesize_threads(int (*process)(event_t *event)) | 167 | void 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 | ||
183 | struct events_stats event__stats; | 192 | struct events_stats event__stats; |
184 | 193 | ||
185 | int event__process_comm(event_t *self) | 194 | int 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 | ||
199 | int event__process_lost(event_t *self) | 208 | int 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 | ||
206 | int event__process_mmap(event_t *self) | 215 | int 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 | ||
227 | int event__process_task(event_t *self) | 236 | int 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, | |||
156 | void map__fixup_start(struct map *self); | 156 | void map__fixup_start(struct map *self); |
157 | void map__fixup_end(struct map *self); | 157 | void map__fixup_end(struct map *self); |
158 | 158 | ||
159 | int event__synthesize_thread(pid_t pid, int (*process)(event_t *event)); | 159 | struct perf_session; |
160 | void event__synthesize_threads(int (*process)(event_t *event)); | 160 | |
161 | int event__synthesize_thread(pid_t pid, | ||
162 | int (*process)(event_t *event, | ||
163 | struct perf_session *session), | ||
164 | struct perf_session *session); | ||
165 | void event__synthesize_threads(int (*process)(event_t *event, | ||
166 | struct perf_session *session), | ||
167 | struct perf_session *session); | ||
161 | 168 | ||
162 | extern char *event__cwd; | 169 | extern char *event__cwd; |
163 | extern int event__cwdlen; | 170 | extern int event__cwdlen; |
164 | extern struct events_stats event__stats; | 171 | extern struct events_stats event__stats; |
165 | extern unsigned long event__total[PERF_RECORD_MAX]; | 172 | extern unsigned long event__total[PERF_RECORD_MAX]; |
166 | 173 | ||
167 | int event__process_comm(event_t *self); | 174 | int event__process_comm(event_t *self, struct perf_session *session); |
168 | int event__process_lost(event_t *self); | 175 | int event__process_lost(event_t *self, struct perf_session *session); |
169 | int event__process_mmap(event_t *self); | 176 | int event__process_mmap(event_t *self, struct perf_session *session); |
170 | int event__process_task(event_t *self); | 177 | int event__process_task(event_t *self, struct perf_session *session); |
171 | 178 | ||
172 | struct addr_location; | 179 | struct addr_location; |
173 | int event__preprocess_sample(const event_t *self, struct addr_location *al, | 180 | int event__preprocess_sample(const event_t *self, struct addr_location *al, |