diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-10-06 15:21:26 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-07 02:36:10 -0400 |
commit | b209aa1f83964d49a332a7b6b818ebede5cdc6ef (patch) | |
tree | 65899a686eedd374d0524a0812273bdeac5f08a3 /tools/perf | |
parent | 42e59d7d19dc4b49feab2a860fd9a8ca3248c833 (diff) |
perf tools: Start the perf.data mapping at data offset in perf trace
Currently, we are mapping perf.data in the beginning of the file
and use the data offset as a buffer offset.
This may exceed the mapping area if the data offset is upper than
page_size * mmap_window and result in a page fault (thing that
happen if we merge trace.info in perf.data).
Instead, let's start the mapping in the page that matches our data
offset.
v2: Drop a junk from another patch (trace_report() removal)
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <1254856886-10348-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-trace.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 5d4c84d86373..d573d4ea6c21 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -143,6 +143,7 @@ static int __cmd_trace(void) | |||
143 | int ret, rc = EXIT_FAILURE; | 143 | int ret, rc = EXIT_FAILURE; |
144 | unsigned long offset = 0; | 144 | unsigned long offset = 0; |
145 | unsigned long head = 0; | 145 | unsigned long head = 0; |
146 | unsigned long shift; | ||
146 | struct stat perf_stat; | 147 | struct stat perf_stat; |
147 | event_t *event; | 148 | event_t *event; |
148 | uint32_t size; | 149 | uint32_t size; |
@@ -180,6 +181,10 @@ static int __cmd_trace(void) | |||
180 | return EXIT_FAILURE; | 181 | return EXIT_FAILURE; |
181 | } | 182 | } |
182 | 183 | ||
184 | shift = page_size * (head / page_size); | ||
185 | offset += shift; | ||
186 | head -= shift; | ||
187 | |||
183 | remap: | 188 | remap: |
184 | buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ, | 189 | buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ, |
185 | MAP_SHARED, input, offset); | 190 | MAP_SHARED, input, offset); |
@@ -192,9 +197,9 @@ more: | |||
192 | event = (event_t *)(buf + head); | 197 | event = (event_t *)(buf + head); |
193 | 198 | ||
194 | if (head + event->header.size >= page_size * mmap_window) { | 199 | if (head + event->header.size >= page_size * mmap_window) { |
195 | unsigned long shift = page_size * (head / page_size); | ||
196 | int res; | 200 | int res; |
197 | 201 | ||
202 | shift = page_size * (head / page_size); | ||
198 | res = munmap(buf, page_size * mmap_window); | 203 | res = munmap(buf, page_size * mmap_window); |
199 | assert(res == 0); | 204 | assert(res == 0); |
200 | 205 | ||