Received: by 10.223.185.116 with SMTP id b49csp4868448wrg; Wed, 7 Mar 2018 02:23:08 -0800 (PST) X-Google-Smtp-Source: AG47ELuAhxtPY4VaNGT6hfAd8tcO4PbzzRLhsCaipD+3TBFgXr9JpOgEIrsHlqxrrLeaNt36xTUb X-Received: by 10.99.45.194 with SMTP id t185mr16466825pgt.267.1520418188665; Wed, 07 Mar 2018 02:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520418188; cv=none; d=google.com; s=arc-20160816; b=dAuRD+KOVmGd0N5zP9hCzpSgx1Kz3JLUDFNPnQ3Qb0o1ti3f9J2edoGOA/kWB1YfIG uR0TkFR5fthuieWldHJIRR6LdmzDoMVWllQKjvKTMoeEwk1G5BzHd924ORbkr1Zm2pFX /Gc0kvA+1nhToZHoRwdE8LuY0UcQ7HJpvX0qEYdv4KTINDJVeBG/TY0gfNR1Mrl6l/AJ V02ZtYeF0tovHBfXe/ZViRP/nahaRPDQXa0P4ysq0Yg8aapIPGWqMZdcPBhqaib2Aj9o FrfHbf6sIPEnTmcLOJL8pu+KayXe/tRnTlyNEiH4lybn9Fl7iEEWQWu2BtW3/hYXFldb 7ATw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=wkS09UtGBTzqvnFfmXnJiRatHPIbiqbnoQXBm2X+Sng=; b=UDnCbp24+0XVkWNarzK6qresAobKdHVqKDhqovlyvxvOT7Fsyo6cwHGmTuvY0q6Mwb jOSZdc5y38U0Dl/78l2IFJt1Ip7zEx5fNLBxCCJqeo37025mt/5PneIvgfjEWPOs+CU3 Zh2v6gPgZkK6YpWq9V29FR2phlhrW6kLHEI37y7k//OgKTOHvm/aT1etUyM6422RzjVO K0iWOINaowhDNB6opOqrO/hLb/R0YeGKtkV1gv1KV09H9O+3xCBodq/M/Jf4cfkERumZ V7FMs9hY+yRcDbYWWOaLp0PXM/zSIqZa7U1as5I6aFVCmYKkQwgvpKfm7UvcDwStWlXJ 9zFA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g21si13428586pfh.379.2018.03.07.02.22.54; Wed, 07 Mar 2018 02:23:08 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932362AbeCGKWB (ORCPT + 99 others); Wed, 7 Mar 2018 05:22:01 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59464 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751142AbeCGKWA (ORCPT ); Wed, 7 Mar 2018 05:22:00 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B29E740006E6; Wed, 7 Mar 2018 10:21:59 +0000 (UTC) Received: from krava (unknown [10.43.17.243]) by smtp.corp.redhat.com (Postfix) with SMTP id 5EDE0215CDA7; Wed, 7 Mar 2018 10:21:58 +0000 (UTC) Date: Wed, 7 Mar 2018 11:21:57 +0100 From: Jiri Olsa To: Yisheng Xie Cc: acme@redhat.com, mingo@redhat.com, peterz@infradead.org, namhyung@kernel.org, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org, Kan Liang Subject: Re: [PATCH] perf mmap: Discard head in overwrite_rb_find_range Message-ID: <20180307102157.GC22848@krava> References: <1520336663-53466-1-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1520336663-53466-1-git-send-email-xieyisheng1@huawei.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 10:21:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 10:21:59 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 >