Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932791AbeAKV0d convert rfc822-to-8bit (ORCPT + 1 other); Thu, 11 Jan 2018 16:26:33 -0500 Received: from mga02.intel.com ([134.134.136.20]:65529 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752804AbeAKV0c (ORCPT ); Thu, 11 Jan 2018 16:26:32 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,346,1511856000"; d="scan'208";a="10557900" From: "Liang, Kan" To: Jiri Olsa CC: "acme@kernel.org" , "peterz@infradead.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "wangnan0@huawei.com" , "jolsa@kernel.org" , "namhyung@kernel.org" , "ak@linux.intel.com" , "yao.jin@linux.intel.com" Subject: RE: [PATCH V3 02/12] perf mmap: factor out function to find ringbuffer position Thread-Topic: [PATCH V3 02/12] perf mmap: factor out function to find ringbuffer position Thread-Index: AQHTeohYQA4ITzGJdE69QMaG5y6pe6NuVNcAgADdQYA= Date: Thu, 11 Jan 2018 21:26:28 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F077537FFBDE@SHSMSX103.ccr.corp.intel.com> References: <1513879734-237492-1-git-send-email-kan.liang@intel.com> <1513879734-237492-3-git-send-email-kan.liang@intel.com> <20180111142520.GA16655@krava> In-Reply-To: <20180111142520.GA16655@krava> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTc3ZDNiNjYtNDcyNi00MWFmLWExNjItMDM4MzRiYWY5ZDAzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IlwvTjg5aVhpcDI4eTVRNnM5OEdpVDhTMVhWVzBzMUxjMEhLVEpwUUFyOHprPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: > On Thu, Dec 21, 2017 at 10:08:44AM -0800, kan.liang@intel.com wrote: > > SNIP > > > +/* > > + * Report the start and end of the available data in ringbuffer > > + */ > > +int perf_mmap__read_init(struct perf_mmap *map, bool overwrite, > > + u64 *start, u64 *end) > > { > > - u64 head = perf_mmap__read_head(md); > > - u64 old = md->prev; > > - u64 end = head, start = old; > > - unsigned char *data = md->base + page_size; > > + u64 head = perf_mmap__read_head(map); > > + u64 old = map->prev; > > + unsigned char *data = map->base + page_size; > > unsigned long size; > > - void *buf; > > - int rc = 0; > > > > - start = overwrite ? head : old; > > - end = overwrite ? old : head; > > + /* > > + * Check if event was unmapped due to a POLLHUP/POLLERR. > > + */ > > + if (!refcount_read(&map->refcnt)) > > + return -EINVAL; > > > > - if (start == end) > > - return 0; > > + *start = overwrite ? head : old; > > + *end = overwrite ? old : head; > > > > - size = end - start; > > - if (size > (unsigned long)(md->mask) + 1) { > > + if (*start == *end) > > + return -EAGAIN; > > + > > + size = *end - *start; > > + if (size > (unsigned long)(map->mask) + 1) { > > if (!overwrite) { > > WARN_ONCE(1, "failed to keep up with mmap data. > (warn only once)\n"); > > > > I know you did not change this, but is this leg even possible > in !overwrite mode? I think kernel will throw away the data, > keep the head and wait for tail to be read by user.. Right, it should not happen in !overwrite mode. I guess it's just sanity check. It should not bring any problems. I think I will still keep it for V4 if no objection? Thanks, Kan > > jirka > > > - md->prev = head; > > - perf_mmap__consume(md, overwrite); > > - return 0; > > + map->prev = head; > > + perf_mmap__consume(map, overwrite); > > + return -EAGAIN; > > SNIP