Re: [PATCH v11 2/3]: perf record: enable asynchronous trace writing
From: Jiri Olsa
Date: Mon Oct 08 2018 - 06:59:02 EST
On Mon, Oct 08, 2018 at 09:17:11AM +0300, Alexey Budankov wrote:
SNIP
> static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evlist,
> bool overwrite)
> {
> @@ -520,7 +644,10 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli
> int i;
> int rc = 0;
> struct perf_mmap *maps;
> -
> +#ifdef HAVE_AIO_SUPPORT
> + int trace_fd = rec->data.file.fd;
> + off_t off;
> +#endif
> if (!evlist)
> return 0;
>
> @@ -531,14 +658,34 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli
> if (overwrite && evlist->bkw_mmap_state != BKW_MMAP_DATA_PENDING)
> return 0;
>
> +#ifdef HAVE_AIO_SUPPORT
> + off = lseek(trace_fd, 0, SEEK_CUR);
> +#endif
> for (i = 0; i < evlist->nr_mmaps; i++) {
> struct perf_mmap *map = &maps[i];
>
> if (map->base) {
> - if (perf_mmap__push(map, rec, record__pushfn) != 0) {
> - rc = -1;
> - goto out;
> +#ifdef HAVE_AIO_SUPPORT
> + if (!rec->opts.nr_cblocks) {
> +#endif
maybe it'd be less confusing having something like
rec->opts.aio.enabled
or aio__is_enabled() global with the dummy counterpart
jirka