aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-trace.c7
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
183remap: 188remap:
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