Received: by 10.223.185.116 with SMTP id b49csp3716706wrg; Tue, 6 Mar 2018 03:55:22 -0800 (PST) X-Google-Smtp-Source: AG47ELvMgVMQlA95hVv+P/+TSLudbz50Iz0u2zNfr/BF+QNGk3yvGd+vC/JHbf6NPXhHyxA84BDd X-Received: by 2002:a17:902:8215:: with SMTP id x21-v6mr16787856pln.164.1520337322216; Tue, 06 Mar 2018 03:55:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520337322; cv=none; d=google.com; s=arc-20160816; b=P2iF4/YT77kllv4OF0bxLq0ei3enN7fmjqTbEZg1j6ALs8Ytzka/XMcDa9ocPkLKWU rRL4n/s7R4ySF6lCVVY0i5qfI3FrL0Pp2uMp1N1jyWxNQ7cb5zGz0s9wRnHpYORqq6il lpLAeXELqw77UBvPsSg5w0qniI+MPeiTfFPayrlIsFIIvSy20XXjg/JooUijo85E56SY M1vhID2TOoInD/V1Dwg68Q6XZlXrfIselOWOdXyd0MKi7Edg2eWULttkylKb11CJVeEJ 5O4kQF7mYoM9gn3Qd9sDWgtzAjlTeJXSyGkswZ04cbJULDAclz+iAoMoBtohGaRg2MPF iBKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=pdL1oR4yesa8cqbbr2cyCo24PhyvRQStUW86Wx1iuDE=; b=ifUtiU+pgOsxm5x5A6N6IUes6NCthu4K6J3Oz1eTxfOMaBByN+B6m+hxA989kRPK31 YebERjSqGCF8cfrnZT50PzZbASCBzXuPNoz8ceO6NWLvE4yfm/3jGfFB0yIqRGrf10eH BpSI2UXuRkGsMtcLj0pnoeAYSPRu4TCT90viTSEYR4exVpsgbpo1M8jFN5YtkS2MocLX VFqL3sZZxFuvGzJGzDTUbPiWRc3QTHjsVIAcMgvGSY8/8VkOYJflE1Ii5PaUeemZYobr QvnRRI0oFssaYphUzt4oYsfIUw3A0VF4AOwlG3T8ahmlL6Yrp4XTj1i5SYukz0wJ+T3d F7WQ== 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 i12-v6si11126014plk.508.2018.03.06.03.55.07; Tue, 06 Mar 2018 03:55:22 -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 S1753363AbeCFLyM (ORCPT + 99 others); Tue, 6 Mar 2018 06:54:12 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:5739 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750859AbeCFLyL (ORCPT ); Tue, 6 Mar 2018 06:54:11 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 4172A84D6EAEA; Tue, 6 Mar 2018 19:53:56 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.361.1; Tue, 6 Mar 2018 19:53:51 +0800 From: Yisheng Xie To: CC: , , , , , , Yisheng Xie Subject: [PATCH] perf mmap: Discard head in overwrite_rb_find_range Date: Tue, 6 Mar 2018 19:44:23 +0800 Message-ID: <1520336663-53466-1-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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