Received: by 10.223.185.116 with SMTP id b49csp5068566wrg; Wed, 7 Mar 2018 06:00:11 -0800 (PST) X-Google-Smtp-Source: AG47ELslo96PIZBnwFxcQtUmX7tW3ccVBojvKe9vU1n2MNjKZRsncNz1ZfalNOdjHzrOY7pc2vc5 X-Received: by 10.98.67.216 with SMTP id l85mr22667473pfi.214.1520431211774; Wed, 07 Mar 2018 06:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520431211; cv=none; d=google.com; s=arc-20160816; b=Y5Y40zD0/5bIPaYDI05f2c8ivjiBk3YO1kMfN8HYLV2fB45AKKWzIImVlBFUNZG94J MkBBTQrj4KZWLs9UeqZ8jylO/Q9baRzeFhvXY0Dcz4PBueYdnS8WqDjaRb859/LpF4QF DsaW217LaP8F0t1t001v8928Y7yDUAb8dV2HNn5trtr7GnVtacc3SbqBBjGFcTYJPOni XglDrdCHM660r0sVx78dWU1kzLoJmf4JGvnYfrkQoKruh5Mkh/5YgTT3GGCFxLGXybfX 38CM5b1D1sRfLzwAWuEgiXqTyMvLGVnsYYvcOLdDHGxpoBKNiiDrlSse+i86hB7sbWVZ xiow== 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=xmo/YxrZHCnx0678T8dYp4NaxHVjJR8C6lwq6CR7opo=; b=aW580ETBhTIR6RwtP6brKufvoD5zKK69wBmISB6UvB0xHnuTtXch+lLipT5njrO9sq 6XHXIZMS64Rl85CHVmnyROl3DCT+QIS59z6K8ydYJWFOP/0s8gbW9H1pLa8AoecA1oxW homryFCm9jJoxHBmvdT0aogZkiOzGP6yaTqgCUupbK66OJH8wnr+OWxLSOy8OkAt4xK2 IU/ECrCRsdFkHKDLtcvK8TjJJOMJA0jOoK1/UVXIW2wU/O5K6YJRB2yyCV5oHhgvczTk T+FtQjBKVIsLE687TmzopS0d0UoNjGRZxFFkWcstvIzHaKXAcVJ4KFw3Gvzx15+2E4gR +Qnw== 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 t7-v6si9355472plq.802.2018.03.07.05.59.56; Wed, 07 Mar 2018 06:00:11 -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 S1754039AbeCGN7D (ORCPT + 99 others); Wed, 7 Mar 2018 08:59:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35980 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151AbeCGN7A (ORCPT ); Wed, 7 Mar 2018 08:59:00 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D734DC0023A4; Wed, 7 Mar 2018 13:58:59 +0000 (UTC) Received: from sandy.ghostprotocols.net (ovpn-64-2.rdu2.redhat.com [10.10.64.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7E437A407; Wed, 7 Mar 2018 13:58:57 +0000 (UTC) Received: by sandy.ghostprotocols.net (Postfix, from userid 1000) id A10044770; Wed, 7 Mar 2018 10:58:54 -0300 (BRT) Date: Wed, 7 Mar 2018 10:58:54 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Yisheng Xie , mingo@redhat.com, peterz@infradead.org, namhyung@kernel.org, acme@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: <20180307135854.GA2187@redhat.com> References: <1520336663-53466-1-git-send-email-xieyisheng1@huawei.com> <20180307102157.GC22848@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180307102157.GC22848@krava> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 07 Mar 2018 13:59:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? - 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 > >