aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/data_map.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-13 16:50:27 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-14 10:57:16 -0500
commitec913369733923dbfd6bdff5953a918107059701 (patch)
tree4c4397f5de47bb1352bfed874919bb438b6e4816 /tools/perf/util/data_map.c
parent13df45ca1c9a430d5f53862854070fcc324e015c (diff)
perf session: Reduce the number of parms to perf_session__process_events
By having the cwd/cwdlen in the perf_session struct and full_paths in perf_event_ops. Now its just a matter of passing the ops. 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-4-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.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c
index 36e3bfe73196..ba2eb2ce018a 100644
--- a/tools/perf/util/data_map.c
+++ b/tools/perf/util/data_map.c
@@ -4,9 +4,6 @@
4#include "thread.h" 4#include "thread.h"
5#include "session.h" 5#include "session.h"
6 6
7static unsigned long mmap_window = 32;
8static char __cwd[PATH_MAX];
9
10static int process_event_stub(event_t *event __used, 7static int process_event_stub(event_t *event __used,
11 struct perf_session *session __used) 8 struct perf_session *session __used)
12{ 9{
@@ -141,8 +138,7 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se
141} 138}
142 139
143int perf_session__process_events(struct perf_session *self, 140int perf_session__process_events(struct perf_session *self,
144 struct perf_event_ops *ops, 141 struct perf_event_ops *ops)
145 int full_paths, int *cwdlen, char **cwd)
146{ 142{
147 int err; 143 int err;
148 unsigned long head, shift; 144 unsigned long head, shift;
@@ -168,17 +164,21 @@ int perf_session__process_events(struct perf_session *self,
168 ops->sample_type_check(sample_type) < 0) 164 ops->sample_type_check(sample_type) < 0)
169 goto out_err; 165 goto out_err;
170 166
171 if (!full_paths) { 167 if (!ops->full_paths) {
172 if (getcwd(__cwd, sizeof(__cwd)) == NULL) { 168 char bf[PATH_MAX];
173 pr_err("failed to get the current directory\n"); 169
170 if (getcwd(bf, sizeof(bf)) == NULL) {
174 err = -errno; 171 err = -errno;
172out_getcwd_err:
173 pr_err("failed to get the current directory\n");
175 goto out_err; 174 goto out_err;
176 } 175 }
177 *cwd = __cwd; 176 self->cwd = strdup(bf);
178 *cwdlen = strlen(*cwd); 177 if (self->cwd == NULL) {
179 } else { 178 err = -ENOMEM;
180 *cwd = NULL; 179 goto out_getcwd_err;
181 *cwdlen = 0; 180 }
181 self->cwdlen = strlen(self->cwd);
182 } 182 }
183 183
184 shift = page_size * (head / page_size); 184 shift = page_size * (head / page_size);
@@ -186,7 +186,7 @@ int perf_session__process_events(struct perf_session *self,
186 head -= shift; 186 head -= shift;
187 187
188remap: 188remap:
189 buf = mmap(NULL, page_size * mmap_window, PROT_READ, 189 buf = mmap(NULL, page_size * self->mmap_window, PROT_READ,
190 MAP_SHARED, self->fd, offset); 190 MAP_SHARED, self->fd, offset);
191 if (buf == MAP_FAILED) { 191 if (buf == MAP_FAILED) {
192 pr_err("failed to mmap file\n"); 192 pr_err("failed to mmap file\n");
@@ -201,12 +201,12 @@ more:
201 if (!size) 201 if (!size)
202 size = 8; 202 size = 8;
203 203
204 if (head + event->header.size >= page_size * mmap_window) { 204 if (head + event->header.size >= page_size * self->mmap_window) {
205 int munmap_ret; 205 int munmap_ret;
206 206
207 shift = page_size * (head / page_size); 207 shift = page_size * (head / page_size);
208 208
209 munmap_ret = munmap(buf, page_size * mmap_window); 209 munmap_ret = munmap(buf, page_size * self->mmap_window);
210 assert(munmap_ret == 0); 210 assert(munmap_ret == 0);
211 211
212 offset += shift; 212 offset += shift;