Received: by 10.223.176.46 with SMTP id f43csp35373wra; Thu, 18 Jan 2018 13:32:16 -0800 (PST) X-Google-Smtp-Source: ACJfBosd4R6cHC96VgWcZ6CumQAZoa85c+X9vrScZDCPxlbsySDH0TZRynfUmzdPC0lWpY5zk0De X-Received: by 2002:a17:902:6b01:: with SMTP id o1-v6mr430904plk.51.1516311135964; Thu, 18 Jan 2018 13:32:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516311135; cv=none; d=google.com; s=arc-20160816; b=WmHFEUVlcRh6DPifbWdD0f01Gp4SwXoYe53DTSUsnNcn3bfBHPfuyYhWmbFL/+hJ9e N56VUNNeyAW/AQxYfoxtFV5VgUqSlpmYuuZG1t944NAKCnRnwACJje6kAf8VgtFmLGsq 69mcrS5cBadiyamx1hOgLieQS/wg2ytWjTeoCXGXRc7GEKvYGcXLeF830EQEw6n3Cppz GvE3IgFQNIipqas8wiUI0g0g/FQtJSsvv9qB6EZmRejKJSY65EaWTrVIGIQm23qXEvr8 yJ/zSsDkNQztCxveeaLN333zy8GSm1KWEj3XsX5al3dvxDm1enAO/xmNKS56W9eVSkPD ZIMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=f6gTm5eRYsfdIFU7/O3LhCmvYdWUihQ5Wcta2m5y5zs=; b=dVdSV+o/NfrO7zR/5BQA0tpqZzD7zt55jg49xlW2X20LMMr38zBZxTLUS3XCSzj9w/ 1N484RSQeAYBYiOChQe7+vZ+QMouOrNDdPjiYfpUF8vHt/0UQClvvJyUyAzLp4bOKm07 hPxeI68o+2lAMdTN1lh1Ks0gdIrg0m1l84M1edQTK4mNiLNvjeQRLccs1/RBSBBmSxDQ xx+qLJSpJbRG+WKqi5ciow0saHmS4xB6UMduR+4ztLjAN7f2XMggRu86eVpu4ruFx7FJ g50lu4XUn1V0zDg0+nQ8GtfKPZX38b5lEALA5hkyNAOCXfUPkuN8v0EVTU91g7XnzERI kEcA== 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 a9si6791288pgv.684.2018.01.18.13.32.01; Thu, 18 Jan 2018 13:32:15 -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 S1754952AbeARVap (ORCPT + 99 others); Thu, 18 Jan 2018 16:30:45 -0500 Received: from mga04.intel.com ([192.55.52.120]:47421 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754284AbeARV1g (ORCPT ); Thu, 18 Jan 2018 16:27:36 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 13:27:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,378,1511856000"; d="scan'208";a="11477265" Received: from otc-knm-01.jf.intel.com ([10.54.39.34]) by fmsmga008.fm.intel.com with ESMTP; 18 Jan 2018 13:27:34 -0800 From: kan.liang@intel.com To: acme@kernel.org, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: wangnan0@huawei.com, jolsa@kernel.org, namhyung@kernel.org, ak@linux.intel.com, yao.jin@linux.intel.com, Kan Liang Subject: [PATCH V5 10/17] perf mmap: discard legacy interface for mmap read Date: Thu, 18 Jan 2018 13:26:25 -0800 Message-Id: <1516310792-208685-11-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1516310792-208685-1-git-send-email-kan.liang@intel.com> References: <1516310792-208685-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang 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 --- 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, -- 2.5.5