mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
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>
This commit is contained in:
parent
42e59d7d19
commit
b209aa1f83
1 changed files with 6 additions and 1 deletions
|
@ -143,6 +143,7 @@ static int __cmd_trace(void)
|
||||||
int ret, rc = EXIT_FAILURE;
|
int ret, rc = EXIT_FAILURE;
|
||||||
unsigned long offset = 0;
|
unsigned long offset = 0;
|
||||||
unsigned long head = 0;
|
unsigned long head = 0;
|
||||||
|
unsigned long shift;
|
||||||
struct stat perf_stat;
|
struct stat perf_stat;
|
||||||
event_t *event;
|
event_t *event;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
@ -180,6 +181,10 @@ static int __cmd_trace(void)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shift = page_size * (head / page_size);
|
||||||
|
offset += shift;
|
||||||
|
head -= shift;
|
||||||
|
|
||||||
remap:
|
remap:
|
||||||
buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ,
|
buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ,
|
||||||
MAP_SHARED, input, offset);
|
MAP_SHARED, input, offset);
|
||||||
|
@ -192,9 +197,9 @@ more:
|
||||||
event = (event_t *)(buf + head);
|
event = (event_t *)(buf + head);
|
||||||
|
|
||||||
if (head + event->header.size >= page_size * mmap_window) {
|
if (head + event->header.size >= page_size * mmap_window) {
|
||||||
unsigned long shift = page_size * (head / page_size);
|
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
shift = page_size * (head / page_size);
|
||||||
res = munmap(buf, page_size * mmap_window);
|
res = munmap(buf, page_size * mmap_window);
|
||||||
assert(res == 0);
|
assert(res == 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue