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/event.c | |
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/event.c')
-rw-r--r-- | tools/perf/util/event.c | 37 |
1 files changed, 23 insertions, 14 deletions
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); |