[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180111120009.GA7189@sejong>
Date: Thu, 11 Jan 2018 21:00:09 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: "Liang, Kan" <kan.liang@...el.com>
Cc: "acme@...nel.org" <acme@...nel.org>,
"peterz@...radead.org" <peterz@...radead.org>,
"mingo@...hat.com" <mingo@...hat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"wangnan0@...wei.com" <wangnan0@...wei.com>,
"jolsa@...nel.org" <jolsa@...nel.org>,
"ak@...ux.intel.com" <ak@...ux.intel.com>,
"yao.jin@...ux.intel.com" <yao.jin@...ux.intel.com>,
"kernel-team@....com" <kernel-team@....com>
Subject: Re: [PATCH V3 04/12] perf mmap: introduce perf_mmap__read_done
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?
>
> 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.
>
> 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.
>
> I also did some tests and dump the 'head' in __read_init() and
> __read_done() with ringbuffer paused. I didn't see any difference either.
Maybe on a weak-ordered machine? Not sure though.
But as I said, I don't care anymore since we cannot avoid some missing
records.
Thanks,
Namhyung
Powered by blists - more mailing lists