libperf: Adopt perf_evlist__filter_pollfd() from tools/perf
authorJiri Olsa <jolsa@kernel.org>
Mon, 7 Oct 2019 12:53:34 +0000 (14:53 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 10 Oct 2019 15:58:45 +0000 (12:58 -0300)
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 <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20191007125344.14268-27-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/lib/evlist.c
tools/perf/lib/include/perf/evlist.h
tools/perf/lib/libperf.map
tools/perf/util/evlist.c

index 9534ad9a572f1c527d3718ea5209f3b7641ef935..65045614c938bfbb3a80979bfeac497c347a74a4 100644 (file)
@@ -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);
index 28b6a12a8a2b54b80da64a2bbf5aa477896c6555..16f526e74d136e3d0aec420dba1b0a81348c4fca 100644 (file)
@@ -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);
index 5a18fd1aacf259e3a46e4a6a5aa6e85352c7bcab..2184aba36c3f214e15d5e0b3f7ac3db00503ba55 100644 (file)
@@ -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;
index 031ace3696a20310b75021028b2d2af85fb54078..21b77efa802c3e2a388fc67ab3c7935e3071774d 100644 (file)
@@ -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)