Re: [PATCH v15 03/12] perf tools: Update perf evlist mmap related APIs and helpers

From: Wangnan (F)
Date: Wed Jul 13 2016 - 21:59:00 EST




On 2016/7/13 22:06, Jiri Olsa wrote:
On Tue, Jul 12, 2016 at 10:00:03AM +0000, Wang Nan wrote:

SNIP

-union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int idx)
+union perf_event *perf_mmap__read_forward(struct perf_mmap *md, bool overwrite)
{
- struct perf_mmap *md = &evlist->mmap[idx];
u64 head;
u64 old = md->prev;
@@ -795,13 +795,12 @@ union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int
head = perf_mmap__read_head(md);
- return perf_mmap__read(md, evlist->overwrite, old, head, &md->prev);
+ return perf_mmap__read(md, overwrite, old, head, &md->prev);
}
union perf_event *
-perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
+perf_mmap__read_backward(struct perf_mmap *md, bool overwrite __maybe_unused)
{
- struct perf_mmap *md = &evlist->mmap[idx];
u64 head, end;
u64 start = md->prev;
@@ -836,6 +835,20 @@ perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
return perf_mmap__read(md, false, start, end, &md->prev);
should you pas evlist->overwrite in here?

No need. The second arg of perf_mmap__read() is not 'overwrite', but 'check_messup'.
When set to 'true', stop reading if caller require a buffer larger than half of the
size of the ring buffer and report a warning. Only forward, read-only ring buffer
requires this check. We can always read the whole backward ring buffer because we
pause it before reading.

I'll add more comments here.

Thank you.

thanks,
jirka