Received: by 10.223.185.116 with SMTP id b49csp1019851wrg; Fri, 16 Feb 2018 10:56:51 -0800 (PST) X-Google-Smtp-Source: AH8x225Xy8d+EJfoQaqFs60cX+5rXw6G1qY9trNC85LbQyPezG1PTJ6+YqyBR9oK4pCoWnRrrmsl X-Received: by 2002:a17:902:678e:: with SMTP id g14-v6mr6610324plk.309.1518807411646; Fri, 16 Feb 2018 10:56:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518807411; cv=none; d=google.com; s=arc-20160816; b=NYA2nAVDzo4DmIFSVKwNQnPyjA86r7NwSjyfxo56jB9XoidJ+znfmVwe9AaxOonFB0 XTdtgNGd4rBkgyGwCk9P/T63LNbjqn9IPSfbxwCSJlwKjHC7swtn7hivq+XeJwZWOiwg sN3JHYpBhfNeQJUwf4TvhGYc8SeULagGPhzR0h1ipo+4s5ElPFPoRPJHGsYZSB7pqLq8 nwJKvit09ijr+RD7jjKb04W5U9t1or+0dIBt47srAq7mw7zdDGSp09oUU6x3Rxm93c0u 6NPli746HV9D7H6rHyOIS1gscoNcS+Uh0tLRd16Ek0qPrBy3RKVQWoayV/jHALbdaa++ jmAQ== 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=dn3LgOkMELTpIrNdDBdQ3eFJyGwMnPDxOzDUUuLnWCs=; b=GCd0iPNZGhyV/3514QnqbFhpE+3sGL02/vz2U7mGNAr6W2vTSrePqXddVgiUSkJnW2 aX+Ytnw/5UmuQmJHn0aglz+8iUGclVdbE48guoU3KKIv6krTja+WLUHlIHZ6kS3wxDWh I1RkPupP2AETuuRdymlsLGOH4nlwjGwT0WXBjmIaGEmzsWX/HxlTbwTm/1Ib5xDIE7ty 5/OkZi8qNYBWTLvM9O7S4KPLksHdCUjj42Nz1HNFtPeGFVdvoOgXQ1TxkmmkhbW8HUHb 99bERZMUhNVOJCjKrrEVwevBk3CgKIFdFTtEy1BsnVd3sOBx45Gpz+rH1nTZ7tCJAYmr hdTA== 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 n4si2507749pgd.570.2018.02.16.10.56.36; Fri, 16 Feb 2018 10:56:51 -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 S932973AbeBPJxE (ORCPT + 99 others); Fri, 16 Feb 2018 04:53:04 -0500 Received: from terminus.zytor.com ([198.137.202.136]:35803 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932690AbeBPJxC (ORCPT ); Fri, 16 Feb 2018 04:53:02 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1G9bIEl021832; Fri, 16 Feb 2018 01:37:18 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1G9bIFw021829; Fri, 16 Feb 2018 01:37:18 -0800 Date: Fri, 16 Feb 2018 01:37:18 -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: jolsa@kernel.org, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, namhyung@kernel.org, ak@linux.intel.com, acme@redhat.com, wangnan0@huawei.com, kan.liang@intel.com, yao.jin@linux.intel.com Reply-To: jolsa@kernel.org, hpa@zytor.com, peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, namhyung@kernel.org, ak@linux.intel.com, acme@redhat.com, wangnan0@huawei.com, kan.liang@intel.com, yao.jin@linux.intel.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: ee023de05f35484691f7d9e5c1f92195ac4d64d2 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: ee023de05f35484691f7d9e5c1f92195ac4d64d2 Gitweb: https://git.kernel.org/tip/ee023de05f35484691f7d9e5c1f92195ac4d64d2 Author: Kan Liang AuthorDate: Thu, 18 Jan 2018 13:26:22 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 15 Feb 2018 09:53:15 -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 */