Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5456753ybp; Mon, 14 Oct 2019 23:07:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS7Od25PmqyGNLoMPQpgGD6hwk1mms7R5Xmc9qw6WIj5gfL03wZcDs0hYCN9OTJLDMBapX X-Received: by 2002:a17:906:cd11:: with SMTP id oz17mr32563928ejb.71.1571119628179; Mon, 14 Oct 2019 23:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571119628; cv=none; d=google.com; s=arc-20160816; b=llMc14w1EBnjXWv4vGieRTSzDEffPCOkgdqpWarpxfiHmmECA9ZjIqjd75gwluAZc6 tkMF6i1WZs6PqusEoQo0/gCJamnBvTvXlSvFTrPlfHHhuA+jkvBb3RMUTCTTrSuqvRs5 suK3IZE/6++sV4i5fgoLLeBbzBgex74bVv0f6o7GpN1XW9SZj+P5DxA25rS9/wv50xMM tC1mot7DRnxO6t5R60uWxS3fECiejeSBY6nqxDDtQ7KiuxZquMhEJQUO2tBi+NNbFVkl 46BJ8d9dI0N8VVbDaCf0iuQ3eBX2JIS+uol8GVKzJmbosXsxLIMsDNTu+iYCcnmPqCiA beZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=1Ff/I8xhi4gdUtMERpUfoj8kh/S8u22HDubgdg0Hi4A=; b=vpdijRz90VyQacnNEN4s5cuu6Hmnebstrs5guzLER9kkeVSLEtgrzLgZVEMy3nVX7z VlZ6eHpUjzOy9atU3fFJrU9Y6qU+p/k51DNMgHiRzWU+Q898tdlPehwkKkoigqTGbALZ YT0siq7W8iOsm8HaGO/X7JI22np2EYS63bIle5Kn+8rFagtGdyYdc9Ytbqi0uVzWYfPT 1YonFRCuCR4gTotTJrdcEXwjTjr3KYC57EZvwPtrzuRWehXKUofyFYxPXac/oyeT0yOk xWdv3oBP9OLSJWstQ3xF1o59dvx6jToNtzaIivq1ADcPHZSQmulKsfFwHtnv8oz4DOvS gqVg== 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 f17si14714417eda.232.2019.10.14.23.06.44; Mon, 14 Oct 2019 23:07:08 -0700 (PDT) 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 S1728584AbfJOFcL (ORCPT + 99 others); Tue, 15 Oct 2019 01:32:11 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:42072 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728493AbfJOFcE (ORCPT ); Tue, 15 Oct 2019 01:32:04 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iKFQl-0008S0-N4; Tue, 15 Oct 2019 07:31:35 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 66E051C0450; Tue, 15 Oct 2019 07:31:35 +0200 (CEST) Date: Tue, 15 Oct 2019 05:31:35 -0000 From: "tip-bot2 for Jiri Olsa" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] libperf: Adopt perf_evlist__filter_pollfd() from tools/perf Cc: Jiri Olsa , Alexander Shishkin , Michael Petlan , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191007125344.14268-27-jolsa@kernel.org> References: <20191007125344.14268-27-jolsa@kernel.org> MIME-Version: 1.0 Message-ID: <157111749528.12254.11860766663201094833.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 84227cb11ff4d9815b9b1daf0c1a2bd7e9274c58 Gitweb: https://git.kernel.org/tip/84227cb11ff4d9815b9b1daf0c1a2bd7e9274c58 Author: Jiri Olsa AuthorDate: Mon, 07 Oct 2019 14:53:34 +02:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Thu, 10 Oct 2019 12:58:45 -03:00 libperf: Adopt perf_evlist__filter_pollfd() from tools/perf Introduce the perf_evlist__filter_pollfd function and export it in the perf/evlist.h header, so that libperf users can check if the descriptor is still alive. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20191007125344.14268-27-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/evlist.c | 15 +++++++++++++++ tools/perf/lib/include/perf/evlist.h | 2 ++ tools/perf/lib/libperf.map | 1 + tools/perf/util/evlist.c | 12 +----------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index 9534ad9..6504561 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c @@ -313,6 +313,21 @@ int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, return pos; } +static void perf_evlist__munmap_filtered(struct fdarray *fda, int fd, + void *arg __maybe_unused) +{ + struct perf_mmap *map = fda->priv[fd].ptr; + + if (map) + perf_mmap__put(map); +} + +int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask) +{ + return fdarray__filter(&evlist->pollfd, revents_and_mask, + perf_evlist__munmap_filtered, NULL); +} + int perf_evlist__poll(struct perf_evlist *evlist, int timeout) { return fdarray__poll(&evlist->pollfd, timeout); diff --git a/tools/perf/lib/include/perf/evlist.h b/tools/perf/lib/include/perf/evlist.h index 28b6a12..16f526e 100644 --- a/tools/perf/lib/include/perf/evlist.h +++ b/tools/perf/lib/include/perf/evlist.h @@ -32,6 +32,8 @@ LIBPERF_API void perf_evlist__set_maps(struct perf_evlist *evlist, struct perf_cpu_map *cpus, struct perf_thread_map *threads); LIBPERF_API int perf_evlist__poll(struct perf_evlist *evlist, int timeout); +LIBPERF_API int perf_evlist__filter_pollfd(struct perf_evlist *evlist, + short revents_and_mask); LIBPERF_API int perf_evlist__mmap(struct perf_evlist *evlist, int pages); LIBPERF_API void perf_evlist__munmap(struct perf_evlist *evlist); diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map index 5a18fd1..2184aba 100644 --- a/tools/perf/lib/libperf.map +++ b/tools/perf/lib/libperf.map @@ -42,6 +42,7 @@ LIBPERF_0.0.1 { perf_evlist__poll; perf_evlist__mmap; perf_evlist__munmap; + perf_evlist__filter_pollfd; perf_mmap__consume; perf_mmap__read_init; perf_mmap__read_done; diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 031ace3..21b77ef 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -423,19 +423,9 @@ int evlist__add_pollfd(struct evlist *evlist, int fd) return perf_evlist__add_pollfd(&evlist->core, fd, NULL, POLLIN); } -static void perf_evlist__munmap_filtered(struct fdarray *fda, int fd, - void *arg __maybe_unused) -{ - struct perf_mmap *map = fda->priv[fd].ptr; - - if (map) - perf_mmap__put(map); -} - int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) { - return fdarray__filter(&evlist->core.pollfd, revents_and_mask, - perf_evlist__munmap_filtered, NULL); + return perf_evlist__filter_pollfd(&evlist->core, revents_and_mask); } int evlist__poll(struct evlist *evlist, int timeout)