Received: by 10.223.185.116 with SMTP id b49csp1018927wrg; Fri, 16 Feb 2018 10:55:40 -0800 (PST) X-Google-Smtp-Source: AH8x2263RhKKdFTKfKA/XlK7alHNWH2QyqlnKBVEBqgghpM2czNtNHOE40uLX/stHZsBxovTf4o6 X-Received: by 10.99.181.28 with SMTP id y28mr6060609pge.222.1518807340085; Fri, 16 Feb 2018 10:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518807340; cv=none; d=google.com; s=arc-20160816; b=wv8QlqI11iPRc5CTAkqdJn2K35hCsk5p1pmKEP3m8P5zkDIlV80ngTH76/t6dEiWhB VDgD3NI79gbqjV8hur+ywVsXKulhaMr+lIqkr7FYtTJ6N5a/2p84qLIRfV3TESUkM0cY kwd1AkSvswA6qo9bR1ttKYU8WtvGWHggIdjb8d1mkDnYnJ8s3iWyQc+khbytbyLDkWWL xjPOWKnQFsT5GCzam7i3V4RmR+tUc3GdnHqZLJV4wDxtju8h5DejaMbecEZ7GUwRM5QM 844iuQ0MWG7ICLcG70bVX3YSYeQ+kg2xHg+qf1bxBl2/jxC+pWzYRT5Po33wY2RWXktM eyMA== 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=vjERS5969XGcB1wia7B3yDaCLBfOHtgn7aZCTekd2Qs=; b=JzB0ikAJmzIpuZRdLshsAbIOUzM8ZokiaQ2h+VROQcHzSgvTTRDB8pskbpxz5wq29Y VPZV2s7xg81qi1tRC5JuutoXs05cuUL5MOKxzQX0p9dMCCXMS3CZ9PcMOMIQ2Us6DDvy k4P8HdGZmpyCX/s91ia7iYSokGPqOnYVIM/x/SL3qwbOQJJvTyo4+FZDLbpes+NEtP1O vD41GnF8ovtpbYhKEbZautkaNqQcHgzIyWW+nnYrvroKRIq7mNMtPUOFTNN3m3bnkQcI Ko4l3Y1bR3JffbGYzwIPVXu5VI/jtW5ogQ1HzOBCJ+xVSmLfpQxxW+28ITa1UaZBnaof /Thg== 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 f11si11123015pgs.556.2018.02.16.10.55.24; Fri, 16 Feb 2018 10:55:40 -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 S932573AbeBPJty (ORCPT + 99 others); Fri, 16 Feb 2018 04:49:54 -0500 Received: from terminus.zytor.com ([198.137.202.136]:60867 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932325AbeBPJtv (ORCPT ); Fri, 16 Feb 2018 04:49:51 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1G9cigl021987; Fri, 16 Feb 2018 01:38:44 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1G9ch5R021984; Fri, 16 Feb 2018 01:38:43 -0800 Date: Fri, 16 Feb 2018 01:38:43 -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: namhyung@kernel.org, ak@linux.intel.com, hpa@zytor.com, mingo@kernel.org, acme@redhat.com, wangnan0@huawei.com, kan.liang@intel.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, tglx@linutronix.de, yao.jin@linux.intel.com, peterz@infradead.org Reply-To: peterz@infradead.org, yao.jin@linux.intel.com, jolsa@kernel.org, tglx@linutronix.de, kan.liang@intel.com, linux-kernel@vger.kernel.org, wangnan0@huawei.com, mingo@kernel.org, acme@redhat.com, hpa@zytor.com, ak@linux.intel.com, namhyung@kernel.org 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: 3effc2f165a842d640873e29d4c5cc1650143aef 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: 3effc2f165a842d640873e29d4c5cc1650143aef Gitweb: https://git.kernel.org/tip/3effc2f165a842d640873e29d4c5cc1650143aef Author: Kan Liang AuthorDate: Thu, 18 Jan 2018 13:26:25 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 15 Feb 2018 09:54:17 -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,