Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 248597
b: refs/heads/master
c: 998bedc
h: refs/heads/master
i:
  248595: 5e94bc3
v: v3
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed May 23, 2011
1 parent c9d89af commit 8e91a34
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4eec42f392043063d0f019640b4ccc2a45570002
refs/heads/master: 998bedc8c56c6869de457c845cbd328592e5e82e
39 changes: 26 additions & 13 deletions trunk/tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,30 @@ static int __perf_session__process_pipe_events(struct perf_session *self,
return err;
}

static union perf_event *
fetch_mmaped_event(struct perf_session *session,
u64 head, size_t mmap_size, char *buf)
{
union perf_event *event;

/*
* Ensure we have enough space remaining to read
* the size of the event in the headers.
*/
if (head + sizeof(event->header) > mmap_size)
return NULL;

event = (union perf_event *)(buf + head);

if (session->header.needs_swap)
perf_event_header__bswap(&event->header);

if (head + event->header.size > mmap_size)
return NULL;

return event;
}

int __perf_session__process_events(struct perf_session *session,
u64 data_offset, u64 data_size,
u64 file_size, struct perf_event_ops *ops)
Expand Down Expand Up @@ -1014,19 +1038,8 @@ int __perf_session__process_events(struct perf_session *session,
file_pos = file_offset + head;

more:
/*
* Ensure we have enough space remaining to read
* the size of the event in the headers.
*/
if (head + sizeof(event->header) > mmap_size)
goto remap;

event = (union perf_event *)(buf + head);

if (session->header.needs_swap)
perf_event_header__bswap(&event->header);

if (head + event->header.size > mmap_size) {
event = fetch_mmaped_event(session, head, mmap_size, buf);
if (!event) {
if (mmaps[map_idx]) {
munmap(mmaps[map_idx], mmap_size);
mmaps[map_idx] = NULL;
Expand Down

0 comments on commit 8e91a34

Please sign in to comment.