Received: by 10.223.185.116 with SMTP id b49csp3562503wrg; Tue, 13 Feb 2018 04:21:21 -0800 (PST) X-Google-Smtp-Source: AH8x227F4qqg9+JM/KapWTcavo3OWSCOBBRMDVdbcSgw38Ffzh/h1n1t0GuZq/CLreGdiIwJgHq3 X-Received: by 10.98.215.12 with SMTP id b12mr1068243pfh.149.1518524481734; Tue, 13 Feb 2018 04:21:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518524481; cv=none; d=google.com; s=arc-20160816; b=t3fOXDg2nAqjHpd3jxKtxOfbwxFjVeKF20vcLOSjzWQcBtw1rj8ZlGizUo7QQLHwxk a5oQ6w+yF23+mXJDM7PJSssRnyjGuuRZmhm6dWUrwXoUaujyspIFN09mvVZnaV4uBggu Tf3SvXRY/exJ/bz5LnAKakv9EPfdW/RUj2jlsWS7mUFE+Va+AvcbN+14Rf2xzcTWJzu+ WrMd1BKBw1b7aSYKEcyp6r5Zhzk9FGI5lGCnhM53YwykRl50zolcSqD2jMEBCiLLvjVQ MPrk8FUHNyNM01b+6AKi4De0oI1KSHDUqlmX0A4WvMfRms30qq3zEv29oau0lLN1G31O kPIQ== 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=oIcDUlF7KnM6eGbFDvHYtmPaJw1umsUestyCjxbtgeA=; b=gqmM9NR2oTihNMNHWD7AMrO6LaJ7tDx0gLOP/jyrR3zrlcbsTrWTxqhW2eKhO50rL7 LXttcViSvQkRxVTu6u31suEG3MG1yczAMDZaeWrT0YDaxOF0MW1KAYDb2ZO7W7GdWFuX DJyYbq3O+C3RtbLwTGJ19/W0wE7PaWPZLpM3NUXO2bTN1fvoZQ+nKpCo8yyUqHE3ecyr UnJwyObBbeJwY55TL2zEjZ8rbtZSa6j1R3wmWnfUIWbtvONxrUFrDxHal9IG5TSBsLJo d4QT5Fzk0xh0jssyJgCI5Qluy7U25IJ2/QuObVbzFbn866ai9iqAfWLUpVlVPGJMJBgK OCUA== 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 94-v6si1275748ple.298.2018.02.13.04.21.06; Tue, 13 Feb 2018 04:21:21 -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 S935246AbeBMMSp (ORCPT + 99 others); Tue, 13 Feb 2018 07:18:45 -0500 Received: from terminus.zytor.com ([198.137.202.136]:46731 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934918AbeBMMSl (ORCPT ); Tue, 13 Feb 2018 07:18:41 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1DC8IKA028948; Tue, 13 Feb 2018 04:08:18 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1DC8Itu028944; Tue, 13 Feb 2018 04:08:18 -0800 Date: Tue, 13 Feb 2018 04:08: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, wangnan0@huawei.com, namhyung@kernel.org, ak@linux.intel.com, tglx@linutronix.de, kan.liang@intel.com, acme@redhat.com, peterz@infradead.org, mingo@kernel.org, hpa@zytor.com, yao.jin@linux.intel.com, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, yao.jin@linux.intel.com, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org, acme@redhat.com, kan.liang@intel.com, tglx@linutronix.de, ak@linux.intel.com, namhyung@kernel.org, jolsa@kernel.org, wangnan0@huawei.com In-Reply-To: <1516310792-208685-11-git-send-email-kan.liang@intel.com> References: <1516310792-208685-11-git-send-email-kan.liang@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf mmap: Discard legacy interface for mmap read Git-Commit-ID: b47160428c794efb32aa6ad6aac323ad79b1e834 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: b47160428c794efb32aa6ad6aac323ad79b1e834 Gitweb: https://git.kernel.org/tip/b47160428c794efb32aa6ad6aac323ad79b1e834 Author: Kan Liang AuthorDate: Thu, 18 Jan 2018 13:26:25 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 6 Feb 2018 10:11:50 -0300 perf mmap: Discard legacy interface for mmap read Discards perf_mmap__read_backward() and perf_mmap__read_catchup(). No tools use them. There are tools still use perf_mmap__read_forward(). Keep it, but add comments to point to the new interface for future use. 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-11-git-send-email-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/mmap.c | 50 ++++---------------------------------------------- tools/perf/util/mmap.h | 3 --- 2 files changed, 4 insertions(+), 49 deletions(-) diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index f804926..91531a7 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -63,6 +63,10 @@ static union perf_event *perf_mmap__read(struct perf_mmap *map, return event; } +/* + * legacy interface for mmap read. + * Don't use it. Use perf_mmap__read_event(). + */ union perf_event *perf_mmap__read_forward(struct perf_mmap *map) { u64 head; @@ -78,41 +82,6 @@ union perf_event *perf_mmap__read_forward(struct perf_mmap *map) return perf_mmap__read(map, &map->prev, head); } -union perf_event *perf_mmap__read_backward(struct perf_mmap *map) -{ - u64 head, end; - - /* - * Check if event was unmapped due to a POLLHUP/POLLERR. - */ - if (!refcount_read(&map->refcnt)) - return NULL; - - head = perf_mmap__read_head(map); - if (!head) - return NULL; - - /* - * 'head' pointer starts from 0. Kernel minus sizeof(record) form - * it each time when kernel writes to it, so in fact 'head' is - * negative. 'end' pointer is made manually by adding the size of - * the ring buffer to 'head' pointer, means the validate data can - * read is the whole ring buffer. If 'end' is positive, the ring - * buffer has not fully filled, so we must adjust 'end' to 0. - * - * However, since both 'head' and 'end' is unsigned, we can't - * simply compare 'end' against 0. Here we compare '-head' and - * the size of the ring buffer, where -head is the number of bytes - * kernel write to the ring buffer. - */ - if (-head < (u64)(map->mask + 1)) - end = 0; - else - end = head + map->mask + 1; - - return perf_mmap__read(map, &map->prev, end); -} - /* * Read event from ring buffer one by one. * Return one event for each call. @@ -152,17 +121,6 @@ union perf_event *perf_mmap__read_event(struct perf_mmap *map, return event; } -void perf_mmap__read_catchup(struct perf_mmap *map) -{ - u64 head; - - if (!refcount_read(&map->refcnt)) - return; - - head = perf_mmap__read_head(map); - map->prev = head; -} - static bool perf_mmap__empty(struct perf_mmap *map) { return perf_mmap__read_head(map) == map->prev && !map->auxtrace_mmap.base; diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index 2871854..ec7d3a24 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -65,8 +65,6 @@ void perf_mmap__put(struct perf_mmap *map); void perf_mmap__consume(struct perf_mmap *map, bool overwrite); -void perf_mmap__read_catchup(struct perf_mmap *md); - static inline u64 perf_mmap__read_head(struct perf_mmap *mm) { struct perf_event_mmap_page *pc = mm->base; @@ -87,7 +85,6 @@ static inline void perf_mmap__write_tail(struct perf_mmap *md, u64 tail) } union perf_event *perf_mmap__read_forward(struct perf_mmap *map); -union perf_event *perf_mmap__read_backward(struct perf_mmap *map); union perf_event *perf_mmap__read_event(struct perf_mmap *map, bool overwrite,