Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223855
b: refs/heads/master
c: fe17420
h: refs/heads/master
i:
  223853: 966e6eb
  223851: 8423a6d
  223847: 2a9c4e2
  223839: 0d8a730
v: v3
  • Loading branch information
Thomas Gleixner authored and Arnaldo Carvalho de Melo committed Nov 30, 2010
1 parent 8c7854a commit 2d844e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 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: 55b44629f599a2305265ae9c77f9d9bcfd6ddc17
refs/heads/master: fe17420784a6d3602e98f798731369fa05936cbe
27 changes: 11 additions & 16 deletions trunk/tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ static void flush_sample_queue(struct perf_session *s,

os->last_flush = iter->timestamp;
list_del(&iter->list);
free(iter->event);
free(iter);
}

Expand Down Expand Up @@ -531,7 +530,6 @@ static int queue_sample_event(event_t *event, struct sample_data *data,
u64 timestamp = data->time;
struct sample_queue *new;


if (timestamp < s->ordered_samples.last_flush) {
printf("Warning: Timestamp below last timeslice flush\n");
return -EINVAL;
Expand All @@ -542,14 +540,7 @@ static int queue_sample_event(event_t *event, struct sample_data *data,
return -ENOMEM;

new->timestamp = timestamp;

new->event = malloc(event->header.size);
if (!new->event) {
free(new);
return -ENOMEM;
}

memcpy(new->event, event, event->header.size);
new->event = event;

__queue_sample_event(new, s);

Expand Down Expand Up @@ -747,12 +738,12 @@ int __perf_session__process_events(struct perf_session *session,
u64 file_size, struct perf_event_ops *ops)
{
u64 head, page_offset, file_offset, file_pos, progress_next;
int err, mmap_prot, mmap_flags;
int err, mmap_prot, mmap_flags, map_idx = 0;
struct ui_progress *progress;
size_t page_size, mmap_size;
char *buf, *mmaps[8];
event_t *event;
uint32_t size;
char *buf;

perf_event_ops__fill_defaults(ops);

Expand All @@ -774,6 +765,8 @@ int __perf_session__process_events(struct perf_session *session,
if (mmap_size > file_size)
mmap_size = file_size;

memset(mmaps, 0, sizeof(mmaps));

mmap_prot = PROT_READ;
mmap_flags = MAP_SHARED;

Expand All @@ -789,6 +782,8 @@ int __perf_session__process_events(struct perf_session *session,
err = -errno;
goto out_err;
}
mmaps[map_idx] = buf;
map_idx = (map_idx + 1) & (ARRAY_SIZE(mmaps) - 1);
file_pos = file_offset + head;

more:
Expand All @@ -801,10 +796,10 @@ int __perf_session__process_events(struct perf_session *session,
size = 8;

if (head + event->header.size >= mmap_size) {
int munmap_ret;

munmap_ret = munmap(buf, mmap_size);
assert(munmap_ret == 0);
if (mmaps[map_idx]) {
munmap(mmaps[map_idx], mmap_size);
mmaps[map_idx] = NULL;
}

page_offset = page_size * (head / page_size);
file_offset += page_offset;
Expand Down

0 comments on commit 2d844e9

Please sign in to comment.