Received: by 10.223.185.116 with SMTP id b49csp3559425wrg; Tue, 13 Feb 2018 04:18:53 -0800 (PST) X-Google-Smtp-Source: AH8x225/KlAZZ3J+sjYiapDXv2HPY4VfOSILhxisDZmeTtcQAC+AHeGElHwA/gdHTkRKKEgU9Ft7 X-Received: by 2002:a17:902:6b89:: with SMTP id p9-v6mr956470plk.377.1518524333177; Tue, 13 Feb 2018 04:18:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518524333; cv=none; d=google.com; s=arc-20160816; b=dTGRrADtKJd6NUp7huC0P5WruX/UDxU4cB4BSVpBZgFo0V07H2+J+HdYHjsS9Ckpq4 aRjUuexp1nLSGpDGCx20l1R6Gq4poIUeaBw4erS0xhkUmqto/0J0D50ff6YXuAXdaqrD fG78a5BWS+tXuo0G5JMfxTS1mpSeVSBUB2tyQElVerRrxBATc4flMJjwIw/skrTp89kE mJD193rvUv3zmVNNWdPegH/hFNh8od0+hdQauf2JC1Yo1Q7jX7g4Didab5HwGktxZnyT IcanCShYDZKVLJ4Zd0JNArbo0Hb4L1IYOhSX0wuI8du5+F1MkiKv4PqDGgbiytH6psUy ZGBw== 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=+47wUPaEctQH7fxlGaPp6qVbNF/HXUefIpyu2LjYgSY=; b=hBAoVpf1nLF0CClGXFSRLDy/lXroXXrRPGn9yjXwWT0pwdPIcwqPCAs1QQlgdEt4yI XRYyg288upcZeJirAw8sfa7+p36HObjUyCZxYXop0xgYPB6wMTCs6thcuRHVNy30RQzl I1gzveb48dUyvSmHIGjZbWXPGh3S7O9tZcQpx8yI9I5KEgiueaALEIXzOZe0WThYvvoE ZQzcL1hDMQOeNHpsfIVP1RFlMabCBIshzmwWGj3B4J5nmWCSRPf/V0ZTAZgyvRWXjwrX vk+rywCB3adbEmIYLNDmOiRZFegzKcCQXndT9+tKwSyTEXVcNpCh7s/GtkO2QXdifRFM XAPQ== 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 u136si1656493pgc.481.2018.02.13.04.18.38; Tue, 13 Feb 2018 04:18:53 -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 S935138AbeBMMR1 (ORCPT + 99 others); Tue, 13 Feb 2018 07:17:27 -0500 Received: from terminus.zytor.com ([198.137.202.136]:46393 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934951AbeBMMRY (ORCPT ); Tue, 13 Feb 2018 07:17:24 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1DC724U028692; Tue, 13 Feb 2018 04:07:02 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1DC713k028683; Tue, 13 Feb 2018 04:07:01 -0800 Date: Tue, 13 Feb 2018 04:07:01 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Kan Liang Message-ID: Cc: mingo@kernel.org, ak@linux.intel.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, tglx@linutronix.de, yao.jin@linux.intel.com, acme@redhat.com, namhyung@kernel.org, hpa@zytor.com, kan.liang@intel.com, peterz@infradead.org Reply-To: namhyung@kernel.org, acme@redhat.com, yao.jin@linux.intel.com, hpa@zytor.com, kan.liang@intel.com, peterz@infradead.org, mingo@kernel.org, ak@linux.intel.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, jolsa@kernel.org, wangnan0@huawei.com In-Reply-To: <1516310792-208685-8-git-send-email-kan.liang@intel.com> References: <1516310792-208685-8-git-send-email-kan.liang@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf mmap: Introduce perf_mmap__read_done() Git-Commit-ID: f4075778f7c9f743109e59311b1bdd60f914804e 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: f4075778f7c9f743109e59311b1bdd60f914804e Gitweb: https://git.kernel.org/tip/f4075778f7c9f743109e59311b1bdd60f914804e Author: Kan Liang AuthorDate: Thu, 18 Jan 2018 13:26:22 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 6 Feb 2018 10:11:50 -0300 perf mmap: Introduce perf_mmap__read_done() The direction of overwrite mode is backward. The last perf_mmap__read() will set tail to map->prev. Need to correct the map->prev to head which is the end of next read. It will be used later. Signed-off-by: Kan Liang Acked-by: Jiri Olsa Cc: Andi Kleen Cc: Jin Yao Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1516310792-208685-8-git-send-email-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/mmap.c | 11 +++++++++++ tools/perf/util/mmap.h | 1 + 2 files changed, 12 insertions(+) diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 125bfda..4f59eae 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -338,3 +338,14 @@ int perf_mmap__push(struct perf_mmap *md, bool overwrite, out: return rc; } + +/* + * Mandatory for overwrite mode + * The direction of overwrite mode is backward. + * The last perf_mmap__read() will set tail to map->prev. + * Need to correct the map->prev to head which is the end of next read. + */ +void perf_mmap__read_done(struct perf_mmap *map) +{ + map->prev = perf_mmap__read_head(map); +} diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index 9ab2b48..95549d4 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -96,4 +96,5 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map); int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, u64 *startp, u64 *endp); +void perf_mmap__read_done(struct perf_mmap *map); #endif /*__PERF_MMAP_H */