Re: [PATCH v15 09/12] perf record: Read from overwritable ring buffer

Jiri Olsa
2016-07-13T14:07:44Z

On Tue, Jul 12, 2016 at 10:00:09AM +0000, Wang Nan wrote:

SNIP

> @@ -131,9 +156,10 @@ rb_find_range(void *data, int mask, u64 head, u64 old,
> return backward_rb_find_range(data, mask, head, start, end);
> }
>
> -static int record__mmap_read(struct record *rec, struct perf_evlist *evlist, int idx)
> +static int
> +record__mmap_read(struct record *rec, struct perf_mmap *md,
> + bool overwrite, bool backward)
> {
> - struct perf_mmap *md = &evlist->mmap[idx];
> u64 head = perf_mmap__read_head(md);
> u64 old = md->prev;
> u64 end = head, start = old;
> @@ -143,7 +169,7 @@ static int record__mmap_read(struct record *rec, struct perf_evlist *evlist, int
> int rc = 0;
>
> if (rb_find_range(data, md->mask, head,
> - old, &start, &end, false))
> + old, &start, &end, backward))
> return -1;
>
> if (start == end)
> @@ -156,7 +182,7 @@ static int record__mmap_read(struct record *rec, struct perf_evlist *evlist, int
> WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n");
>
> md->prev = head;
> - perf_evlist__mmap_consume(evlist, idx);
> + perf_mmap__consume(md, overwrite || backward);
> return 0;
> }
>
> @@ -181,7 +207,7 @@ static int record__mmap_read(struct record *rec, struct perf_evlist *evlist, int
> }
>
> md->prev = head;
> - perf_evlist__mmap_consume(evlist, idx);
> + perf_mmap__consume(md, overwrite || backward);
> out:
> return rc;
> }
> @@ -341,6 +367,75 @@ int auxtrace_record__snapshot_start(struct auxtrace_record *itr __maybe_unused)

could above hunks be moved into separate patch?

jirka