Received: by 10.213.65.68 with SMTP id h4csp421790imn; Fri, 16 Mar 2018 07:18:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELsFAzKEJh9o0/d4skDp+06wRw5AxBFc/YAEXflIKr5dx2cBoOtCddS73yCthHPV9shi3Cy1 X-Received: by 10.98.51.129 with SMTP id z123mr1756798pfz.132.1521209881567; Fri, 16 Mar 2018 07:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521209881; cv=none; d=google.com; s=arc-20160816; b=fuEuNRpsj9dqGS9drler32aVeeQBgwNcIbj2xpNvSM6CJOwQhssmYIM/qE2iY3Q58V 0Sg97med7phOd4xbsDY8BSK+vZonWEYcGGaFDqZZZYg4EhwHo504WSAj0ekM/MmgPuSy uH09kMy0/CJ0OAvq8I2lCrxPo2/ajOY+tAEKtIJTHyNWExnWjYkIFIhnriRhI2ZU7rig /We0xYZmg7Ze0aBS7eMC4RKwXd2ZRQaU/DqlUzd4KUg4WnxV46OJS6YXKMMdsk3oafm6 RAxGp0do26Uu6B8x7P/vBqBTc5TTqCVBUhkB303KeKUXbmeEItx/OGKGFI2Nq+LWr+GF ehzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=dbGbJ4NhIidCFqoOMrAyDz/JXIJp4fqmbnHGCd5yvls=; b=Up/bkgqVSa9dqbKwUnZnqv08ajVQ77kMJzvypSQMhBdacM2W7xKT676E+MkGiV+vp1 GjZWbUm67DgNBBnDadnIUWRSKGkfNLLYrGT7LA7vMTH5nR5nd9H73ZED8z3/fOv5YupB 0fUP5k/KQrs7ErC0UGJbFX5nmaiVvrUHEe2vFAgU30rr4NPlecOo3Q4U6hBbXjKa8CDW MGUs3yUTu9O9OYlMEqG8pgapdjNwzt5ONVN5iRhAAPHxKXsWlzRq6WHNzQqFhvtQ97/m EkASYnGtdmRFz4IwRm35SjzmviO+ggVRtlwhOkQiXC9KInl8xy/54Sm0KhzWQ/kMV+Md Rodw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16-v6si6382791plk.608.2018.03.16.07.17.47; Fri, 16 Mar 2018 07:18:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752841AbeCPOQ6 (ORCPT + 99 others); Fri, 16 Mar 2018 10:16:58 -0400 Received: from mga09.intel.com ([134.134.136.24]:65129 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751582AbeCPOQz (ORCPT ); Fri, 16 Mar 2018 10:16:55 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2018 07:16:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,316,1517904000"; d="scan'208";a="208821594" Received: from linux.intel.com ([10.54.29.200]) by orsmga005.jf.intel.com with ESMTP; 16 Mar 2018 07:16:55 -0700 Received: from [10.254.69.62] (kliang2-mobl1.ccr.corp.intel.com [10.254.69.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 58DA75802AA; Fri, 16 Mar 2018 07:16:54 -0700 (PDT) Subject: Re: [PATCH v2 -perf/core 1/2] perf mmap: Discard head in overwrite_rb_find_range To: Yisheng Xie , acme@redhat.com Cc: mingo@redhat.com, peterz@infradead.org, namhyung@kernel.org, jolsa@redhat.com, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org References: <1520944274-37001-1-git-send-email-xieyisheng1@huawei.com> From: "Liang, Kan" Message-ID: Date: Fri, 16 Mar 2018 10:16:53 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1520944274-37001-1-git-send-email-xieyisheng1@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/13/2018 8:31 AM, Yisheng Xie wrote: > In overwrite mode, start will be set to head in perf_mmap__read_init. > Therefore, it is no need to set the start one more in > overwrite_rb_find_range and *start can be used as head instead of > passing head to overwrite_rb_find_range. > Looks good to me. Reviewed-by: Kan Liang Thanks, Kan > Signed-off-by: Yisheng Xie > --- > v2: > - rebase to perf/core > > tools/perf/util/mmap.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c > index 074c4fd..38ca3ff 100644 > --- a/tools/perf/util/mmap.c > +++ b/tools/perf/util/mmap.c > @@ -199,19 +199,18 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd) > return 0; > } > > -static int overwrite_rb_find_range(void *buf, int mask, u64 head, u64 *start, u64 *end) > +static int overwrite_rb_find_range(void *buf, int mask, u64 *start, u64 *end) > { > struct perf_event_header *pheader; > - u64 evt_head = head; > + u64 evt_head = *start; > int size = mask + 1; > > - pr_debug2("overwrite_rb_find_range: buf=%p, head=%"PRIx64"\n", buf, head); > - pheader = (struct perf_event_header *)(buf + (head & mask)); > - *start = head; > + pr_debug2("%s: buf=%p, start=%"PRIx64"\n", __func__, buf, *start); > + pheader = (struct perf_event_header *)(buf + (*start & mask)); > while (true) { > - if (evt_head - head >= (unsigned int)size) { > + if (evt_head - *start >= (unsigned int)size) { > pr_debug("Finished reading overwrite ring buffer: rewind\n"); > - if (evt_head - head > (unsigned int)size) > + if (evt_head - *start > (unsigned int)size) > evt_head -= pheader->size; > *end = evt_head; > return 0; > @@ -262,7 +261,7 @@ int perf_mmap__read_init(struct perf_mmap *md) > * Backward ring buffer is full. We still have a chance to read > * most of data from it. > */ > - if (overwrite_rb_find_range(data, md->mask, head, &md->start, &md->end)) > + if (overwrite_rb_find_range(data, md->mask, &md->start, &md->end)) > return -EINVAL; > } > >