Received: by 10.223.185.116 with SMTP id b49csp5712414wrg; Wed, 7 Mar 2018 17:07:48 -0800 (PST) X-Google-Smtp-Source: AG47ELuH7Kcl/V3U64kQxtH5rlA7XqG+vZhybIHqXWlUQ36fCY8qeWdmn0E59NaySJCWUBUz3Bxo X-Received: by 10.99.66.65 with SMTP id p62mr19201520pga.378.1520471268281; Wed, 07 Mar 2018 17:07:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520471268; cv=none; d=google.com; s=arc-20160816; b=fZgdchxkV7/V2TgiIeAtRzf6hOuueqvK5NFN9AVHee18HfJwK8hgxwlqc13tuOS/VK OD4/Eqw+E/ECNiEYOgfS+u2DAXlvaIERGBGQNjOEnggxjRykV1LP7I37DSK4A03nSv8l Kud7kSM8wsJriQ/98JXGqM1TkAmkExKEyac+yiQ3V0CQUx07KBaQkJYPvaV7+uRsVwQ3 4a+j0Kge9vh+VsjiHFSczP23odXH1IJABA1xdWfH/oTXfd+ha/2DfBwTorigLs+pqRS/ f/HjthKWmAWsNAm6TcYo8CTjoBL0Ib5IZaGKz3fTjQitplAEU6GYybPRPPLXm63Pi3Xm xL7A== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=dUu/9g3Xc+XNF/AI6NEm2eErAjXp+6F8hYlOlg5KYY0=; b=k4eUpN7a5j+mXHiNqRbqat/SSGg6la5d9cfL0e8nwQRNqVwYOOt3X9Kw6DhabaOAqM K0i0dxc6lyFT2Iog3NPpGtcXE4Dm+pEs7kPSY0kCJ42z6Tqu0c//o4u8GnTOTxyP1OEw dx+LnQ1PA7Z020LmiSFDbeFHd6tjV8XQcQCUdVSGATueE+aBinnEZFgaEN04J2Twyfpu NmkgxQ2xPRS8Bjjrk+WmeMvngEARdVnsXua7TTgTRXXcwSHQBQc/42y128Hkwd0gH6yb sJPtX1gZEn6GFvi25iGxk/l/stq2+4Z3Ve3VCjEyI6NZOCw//3KLml/M2dtItkKRQExj HOfQ== 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 x4si12066137pgo.278.2018.03.07.17.07.33; Wed, 07 Mar 2018 17:07:48 -0800 (PST) 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 S1755165AbeCHBGV (ORCPT + 99 others); Wed, 7 Mar 2018 20:06:21 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5742 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754834AbeCHBF6 (ORCPT ); Wed, 7 Mar 2018 20:05:58 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id CF92F2C33BBDB; Thu, 8 Mar 2018 09:05:43 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.361.1; Thu, 8 Mar 2018 09:05:45 +0800 Subject: Re: [PATCH] perf mmap: Discard head in overwrite_rb_find_range To: Arnaldo Carvalho de Melo , Jiri Olsa References: <1520336663-53466-1-git-send-email-xieyisheng1@huawei.com> <20180307102157.GC22848@krava> <20180307135854.GA2187@redhat.com> CC: , , , , , , Kan Liang From: Yisheng Xie Message-ID: <27975756-0602-6a5b-f5cf-ba9a33e1863a@huawei.com> Date: Thu, 8 Mar 2018 09:05:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <20180307135854.GA2187@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnaldo, On 2018/3/7 21:58, Arnaldo Carvalho de Melo wrote: > Em Wed, Mar 07, 2018 at 11:21:57AM +0100, Jiri Olsa escreveu: >> On Tue, Mar 06, 2018 at 07:44:23PM +0800, 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. >> >> it conflicts a little with recent cleanup from Kan Liang,, >> https://marc.info/?t=152035082800001&r=1&w=2 >> >> otherwise it looks ok to me > > yeah, wait a while till I push Kan's simplifications and then resubmit, > ok? > Sure, I will wait and resubmit. Thanks Yisheng > - Arnaldo > >> jirka >> >>> >>> Signed-off-by: Yisheng Xie >>> --- >>> 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 91531a7..6751ac9 100644 >>> --- a/tools/perf/util/mmap.c >>> +++ b/tools/perf/util/mmap.c >>> @@ -223,19 +223,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; >>> @@ -287,7 +286,7 @@ int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, >>> * 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, startp, endp)) >>> + if (overwrite_rb_find_range(data, md->mask, startp, endp)) >>> return -EINVAL; >>> } >>> >>> -- >>> 1.7.12.4 >>> > > . >