Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932954AbeAKV1M convert rfc822-to-8bit (ORCPT + 1 other); Thu, 11 Jan 2018 16:27:12 -0500 Received: from mga14.intel.com ([192.55.52.115]:5797 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754045AbeAKV1L (ORCPT ); Thu, 11 Jan 2018 16:27:11 -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="23330972" 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 03/12] perf mmap: discard 'prev' in perf_mmap__read Thread-Topic: [PATCH V3 03/12] perf mmap: discard 'prev' in perf_mmap__read Thread-Index: AQHTeohYPlaalBpOUkK97TszEqqGWaNuVOYAgADfamA= Date: Thu, 11 Jan 2018 21:27:07 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F077537FFBF0@SHSMSX103.ccr.corp.intel.com> References: <1513879734-237492-1-git-send-email-kan.liang@intel.com> <1513879734-237492-4-git-send-email-kan.liang@intel.com> <20180111142532.GB16655@krava> In-Reply-To: <20180111142532.GB16655@krava> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjE1YWJiMzItOTk5Ny00ZDFkLWI2NjktYjE3ZTYwMzE3ZTdjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IkR0RzlpVGNaMkxxWFhVcG5mWEp6ekFQSWo0a3hiZGprTEVmOGZhNFdxRms9In0= 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:45AM -0800, kan.liang@intel.com wrote: > > From: Kan Liang > > > > 'start' and 'prev' are duplicate in perf_mmap__read() > > > > Use 'map->prev' to replace 'start' in perf_mmap__read_*(). > > > > Suggested-by: Wang Nan > > Signed-off-by: Kan Liang > > --- > > tools/perf/util/mmap.c | 28 ++++++++++------------------ > > 1 file changed, 10 insertions(+), 18 deletions(-) > > > > diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c > > index 3fd4f3c..a844a2f 100644 > > --- a/tools/perf/util/mmap.c > > +++ b/tools/perf/util/mmap.c > > @@ -22,29 +22,27 @@ size_t perf_mmap__mmap_len(struct perf_mmap > *map) > > > > /* When check_messup is true, 'end' must points to a good entry */ > > static union perf_event *perf_mmap__read(struct perf_mmap *map, > > - u64 start, u64 end, u64 *prev) > > + u64 *start, u64 end) > > { > > unsigned char *data = map->base + page_size; > > union perf_event *event = NULL; > > - int diff = end - start; > > + int diff = end - *start; > > I'd like more if the arg was pointer, like 'u64 *startp' and you > kept using the 'u64 start' value in the body.. but can't see any > technical benefit behind it to force it ;-) > I will rename it as startp in V4. Thanks, Kan > jirka > > > > > if (diff >= (int)sizeof(event->header)) { > > size_t size; > > > > - event = (union perf_event *)&data[start & map->mask]; > > + event = (union perf_event *)&data[*start & map->mask]; > > size = event->header.size; > > > > - if (size < sizeof(event->header) || diff < (int)size) { > > - event = NULL; > > - goto broken_event; > > - } > > + if (size < sizeof(event->header) || diff < (int)size) > > + return NULL; > > > > /* > > * Event straddles the mmap boundary -- header should > always > > * be inside due to u64 alignment of output. > > */ > > - if ((start & map->mask) + size != ((start + size) & map->mask)) > { > > - unsigned int offset = start; > > + if ((*start & map->mask) + size != ((*start + size) & map- > >mask)) { > > + unsigned int offset = *start; > > unsigned int len = min(sizeof(*event), size), cpy; > > void *dst = map->event_copy; > > > > @@ -59,20 +57,15 @@ static union perf_event *perf_mmap__read(struct > perf_mmap *map, > > event = (union perf_event *)map->event_copy; > > } > > > > - start += size; > > + *start += size; > > } > > > > -broken_event: > > - if (prev) > > - *prev = start; > > - > > return event; > > } > > SNIP