Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932797AbeAKMAQ (ORCPT + 1 other); Thu, 11 Jan 2018 07:00:16 -0500 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:34818 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932387AbeAKMAP (ORCPT ); Thu, 11 Jan 2018 07:00:15 -0500 X-Original-SENDERIP: 156.147.1.151 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Thu, 11 Jan 2018 21:00:09 +0900 From: Namhyung Kim To: "Liang, Kan" Cc: "acme@kernel.org" , "peterz@infradead.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "wangnan0@huawei.com" , "jolsa@kernel.org" , "ak@linux.intel.com" , "yao.jin@linux.intel.com" , "kernel-team@lge.com" Subject: Re: [PATCH V3 04/12] perf mmap: introduce perf_mmap__read_done Message-ID: <20180111120009.GA7189@sejong> References: <1513879734-237492-1-git-send-email-kan.liang@intel.com> <1513879734-237492-5-git-send-email-kan.liang@intel.com> <20180102073343.GA8810@sejong> <37D7C6CF3E00A74B8858931C1DB2F077537FBC61@SHSMSX103.ccr.corp.intel.com> <20180104024643.GA1400@danjae.aot.lge.com> <37D7C6CF3E00A74B8858931C1DB2F077537FDC1D@SHSMSX103.ccr.corp.intel.com> <20180109071258.GC7138@sejong> <37D7C6CF3E00A74B8858931C1DB2F077537FEE2B@SHSMSX103.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <37D7C6CF3E00A74B8858931C1DB2F077537FEE2B@SHSMSX103.ccr.corp.intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 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