Messages in this thread | | | Subject | Re: [PATCH v7 1/2]: perf util: map data buffer for preserving collected data | From | Alexey Budankov <> | Date | Thu, 6 Sep 2018 14:54:45 +0300 |
| |
On 06.09.2018 14:04, Jiri Olsa wrote: > On Wed, Sep 05, 2018 at 10:19:56AM +0300, Alexey Budankov wrote: > > SNIP > >> @@ -166,6 +174,7 @@ void perf_mmap__munmap(struct perf_mmap *map) >> >> int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd) >> { >> + int i; >> /* >> * The last one will be done at perf_mmap__consume(), so that we >> * make sure we don't prevent tools from consuming every last event in >> @@ -190,6 +199,50 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd) >> map->base = NULL; >> return -1; >> } >> + map->nr_cblocks = mp->nr_cblocks; >> + map->cblocks = calloc(map->nr_cblocks, sizeof(struct aiocb*)); >> + if (!map->cblocks) { >> + pr_debug2("failed to allocate perf event data buffers, error %d\n", >> + errno); >> + return -1; >> + } >> + map->data = calloc(map->nr_cblocks, sizeof(void*)); >> + if (map->data) { >> + int delta_max = sysconf(_SC_AIO_PRIO_DELTA_MAX); >> + for (i = 0; i < map->nr_cblocks; ++i) { >> + map->data[i] = malloc(perf_mmap__mmap_len(map)); >> + if (map->data[i]) { >> + int prio; >> + unsigned char *data = map->data[i]; >> + map->cblocks[i] = (struct aiocb *)&data[map->mask + 1]; > > the 'struct aiocb' is allocated at the last page of the buffer? > is that enough space? could we please make this more transparent > and allocate that space separately?
Would the array of pointers followed by the array of referenced objects fit?
> > thanks, > jirka >
| |