Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1162631ybe; Fri, 13 Sep 2019 12:02:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgegQiUWSKBfuPm3cAq0Y185Ke+5wKBNUr76fX014jp5TXqpYVvpnleUzZvLou68huJ4GC X-Received: by 2002:a17:906:79ca:: with SMTP id m10mr5204527ejo.292.1568401372776; Fri, 13 Sep 2019 12:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568401372; cv=none; d=google.com; s=arc-20160816; b=IoFCY59gEwfWQeGhsSrLxtwqgW71wDKzyizKw05bKOP0SXnO49utwz4idbkxIPYQX3 TnplcPaehztLhp5Rn4YsfpGZMatT3t8U65OQqvJ8uutGdyQyYgNp51Q4wrND0MSq/4xx E7He/hf6LUJ6jsN9brQPv3FE/8S/tJtCntys9i9fydgY31FRA9oSVYKBXfOL0FUqh22n RN/Gx/8R/maOZL8VySYmEyz2jBcPZQJMnRMXxkcWkbgzO4+NS83w9Pd2KbhnLPEGlzuU p8ss2wpHqWtY1oJYd6XZr17jdGFGpkw+TLDDWfyDF5psSrSbkSoT04VoDlz8OB6S4W2x lEXQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0aG2GFa+gvX0fuiP0zkEwR0ETHZK7yjR61sILmQ0Yfc=; b=pjjiiA5sbrXbHY+oXCg+U0tzlb78FE+5eO9x8O6v1SPKWT3soEOyjzYp0qlrG9Lkik PKCHKZ7aLQizlxt1mlQUV8bMexuz8/ymrPKiGQg5TQ+0uFqPX6+vaRE8LFr/MIVlWdpg tO5k7sp39orXwermKPZRwnSd69/pjOAYHe36Xsxj4iVQPoU0AL0Xt1PX3QQwHiISErJk J+dRVOyaFQuieif9D6cLKIo9xnDhtKGxfcUzFsWgCkOhulKpPErfadsrjoP0tl236UFx s2kAu4yVtT/a/mKnX/VawEAm00dUKwo2c/ChdCnUecupTEX0ADI3UJy4gi5XXucUl5NJ KUFA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si11535473eds.252.2019.09.13.12.02.29; Fri, 13 Sep 2019 12:02:52 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390193AbfIMN0h (ORCPT + 99 others); Fri, 13 Sep 2019 09:26:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56018 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391568AbfIMN0g (ORCPT ); Fri, 13 Sep 2019 09:26:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B99FCCFE6; Fri, 13 Sep 2019 13:26:35 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3EFE5C1D4; Fri, 13 Sep 2019 13:26:33 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 65/73] libperf: Add perf_evlist__filter_pollfd function Date: Fri, 13 Sep 2019 15:23:47 +0200 Message-Id: <20190913132355.21634-66-jolsa@kernel.org> In-Reply-To: <20190913132355.21634-1-jolsa@kernel.org> References: <20190913132355.21634-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 13 Sep 2019 13:26:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding perf_evlist__filter_pollfd function and exporting it in perf/evlist.h header, so libperf users can check if descriptor is still alive. Link: http://lkml.kernel.org/n/tip-7lmjzpk6k2wfhh1os8qw1dxz@git.kernel.org Signed-off-by: Jiri Olsa --- 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 8920833afa9e..ee1d364460e6 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 28b6a12a8a2b..16f526e74d13 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 198dcf305356..90aee2a635b2 100644 --- a/tools/perf/lib/libperf.map +++ b/tools/perf/lib/libperf.map @@ -41,6 +41,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 0c69621e2b2e..9edb0855f711 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -398,19 +398,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) -- 2.21.0