Messages in this thread | | | From | "Liang, Kan" <> | Subject | RE: [PATCH V3 04/12] perf mmap: introduce perf_mmap__read_done | Date | Thu, 11 Jan 2018 14:40:00 +0000 |
| |
> Hi, > > On Tue, Jan 09, 2018 at 03:12:28PM +0000, Liang, Kan wrote: > > > > > > > > > > > > > > Also I guess the current code might miss some events since the > head > > > can > > > > > be > > > > > > > different between _read_init() and _read_done(), no? > > > > > > > > > > > > > > > > > > > The overwrite mode requires the ring buffer to be paused during > > > > > processing. > > > > > > The head is unchanged between __read_init() and __read_done(). > > > > > > > > > > Ah, ok then. Maybe we could read the head once, and use it during > > > > > processing. > > > > > > > > Yes, it only needs to read head once for overwrite mode. > > > > But for non-overwrite, we have to read the head in every > > > > perf_mmap__read_event(). Because the head is floating. > > > > The non-overwrite is specially handled in patch 5/12 as well. > > > > > > Right, I understand it for the non-overwrite mode. > > > > > > But, for the overwrite mode, my concern was that it might be possible > > > that it reads a stale head in __read_init() (even after it paused the > > > ring buffer) and reads an update head in __read_done(). Then it's > > > gonna miss some records. I'm not sure whether it reads the same head > > > in __read_init() and __read_done() by the pause. > > > > > > > The only scenario which may cause the different 'head' may be as below. > > The 'rb->head' is updated in __perf_output_begin(), but haven’t been > > assigned to 'pc->data_head' for perf tool. During this period, the 'paused' > > is set and __read_init() reads head. > > But this scenario never happens because of the ringbuffer lock. > > Which lock did you say? > The RCU lock. > > > > > Otherwise, I cannot imagine any other scenarios which may causes the > > different 'head' in __read_init() and __read_done() with ringbuffer > > paused. Please let me know if there is an example. > > Maybe I'm missing something. But I don't know what makes it guarantee > to see the updated data_head written by another cpu before the pause. >
I think it should be the kernel's responsibility. It's described in the changelog of Commit 86e7972f690c "perf/ring_buffer: Introduce new ioctl options to pause and resume the ring-buffer" > > > > > There would be some records miss. But it's only because the ringbuffer > > is paused. The head should keep the same. > > Hmm.. yes. It's gonna miss some records anyway, then I don't care > about it anymore. >
OK. Thanks for the review.
Thanks, Kan
| |