Received: by 10.213.65.68 with SMTP id h4csp163437imn; Mon, 19 Mar 2018 23:36:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELu3UPAWEOod1Mui1hvKmQ2mcK8NHeJ80kgS5X41euMwwOsPt+/Jqhrcy5IzBVCDHqsHaf7c X-Received: by 10.101.101.139 with SMTP id u11mr5168200pgv.436.1521527818563; Mon, 19 Mar 2018 23:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521527818; cv=none; d=google.com; s=arc-20160816; b=iMjKfcgk2GxHcRPqrITnNWF1Mqw26ZNxfc1nratp/UMQW2+Dp0xHxJQ9Gq8SzWMXd+ ZI0QgDlCMqQkKebzDx4QsCl5h/MjSKaAsPWoTUFOiW7FrLD232OsvLIeNN61+UPtBKsO uuZpxzdrrH1/BYzByh8hb3KU8gft7YVOw1wmV01sAWMSjd5BP6TdUDCawsAV3Jx2mjNi HSRwC8AyNUj76KlFT0MIoFww6RkcT0G6A1lGPQExht6vSAajamPiNII9/lwOQYcAwjDl p/+3WlC1N9hF+3hA/uwIMn71wOFw21CJPwCYZ8pvu7t6oUlvuXn2/7nxE7MGcqcuwRnG ANvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=DeOgYqS4hHJ/yr4rdxDCPJHJ06F/kJXXcavvyE3ch+8=; b=jkJk7QA+sNcizagvmQ8pPhDRrwdBQaCA9Kv9KhecqkB3Jbq+oaFMudm+7rBygxt4cS WjseBAEAViRwVeKxd/7MGEjXtpb0MYveyVa5gfKpVptPI/a+QrROFaBo0qj1Z9pJs4PJ qfmUJj2Utp1XzBnji1FB7IK+kHiva3xXUQjAgIA4dSpEUhGuYxkx5hLKNSiUAVleIkv9 kJ8LZ5yoZ+d1c4KksyFq8WVZXCZilVo/TW1aMB5iyZ/kzzaXgNsdedkd5/VL0eE45ID9 qM8GQ40RtiipLErKK/C6nYSEn9q1MXq/waloAB4L/aBqOXgc1TbmUgFgk+VI+am7wlPj GnvQ== 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 1-v6si994558plw.587.2018.03.19.23.36.45; Mon, 19 Mar 2018 23:36:58 -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 S1751651AbeCTGd7 (ORCPT + 99 others); Tue, 20 Mar 2018 02:33:59 -0400 Received: from terminus.zytor.com ([198.137.202.136]:44781 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751455AbeCTGd4 (ORCPT ); Tue, 20 Mar 2018 02:33:56 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w2K6XVYC031731; Mon, 19 Mar 2018 23:33:31 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w2K6XV7e031728; Mon, 19 Mar 2018 23:33:31 -0700 Date: Mon, 19 Mar 2018 23:33:31 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Yisheng Xie Message-ID: Cc: acme@redhat.com, kan.liang@linux.intel.com, tglx@linutronix.de, alexander.shishkin@linux.intel.com, peterz@infradead.org, mingo@kernel.org, jolsa@redhat.com, xieyisheng1@huawei.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com Reply-To: kan.liang@linux.intel.com, acme@redhat.com, jolsa@redhat.com, mingo@kernel.org, peterz@infradead.org, alexander.shishkin@linux.intel.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, namhyung@kernel.org, xieyisheng1@huawei.com, hpa@zytor.com In-Reply-To: <1520944274-37001-1-git-send-email-xieyisheng1@huawei.com> References: <1520944274-37001-1-git-send-email-xieyisheng1@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf mmap: Discard head in overwrite_rb_find_range() Git-Commit-ID: 699db111058798bcc9f92a93767062905a561bef X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 699db111058798bcc9f92a93767062905a561bef Gitweb: https://git.kernel.org/tip/699db111058798bcc9f92a93767062905a561bef Author: Yisheng Xie AuthorDate: Tue, 13 Mar 2018 20:31:13 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 16 Mar 2018 16:33:05 -0300 perf mmap: Discard head in overwrite_rb_find_range() In overwrite mode, start will be set to head in perf_mmap__read_init(). Therefore, there is no need to set the start one more time in overwrite_rb_find_range() and *start can be used as head instead of passing head to overwrite_rb_find_range(). Signed-off-by: Yisheng Xie Reviewed-by: Kan Liang Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1520944274-37001-1-git-send-email-xieyisheng1@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- 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 074c4fd3b67e..38ca3ffb9d61 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; }