summaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/evlist.c21
-rw-r--r--tools/perf/util/evlist.h2
2 files changed, 23 insertions, 0 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index a3e28b49128a..023bc3873ae9 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -428,6 +428,27 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd)
evlist->nr_fds++;
}
+int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask)
+{
+ int fd, nr_fds = 0;
+
+ if (evlist->nr_fds == 0)
+ return 0;
+
+ for (fd = 0; fd < evlist->nr_fds; ++fd) {
+ if (evlist->pollfd[fd].revents & revents_and_mask)
+ continue;
+
+ if (fd != nr_fds)
+ evlist->pollfd[nr_fds] = evlist->pollfd[fd];
+
+ ++nr_fds;
+ }
+
+ evlist->nr_fds = nr_fds;
+ return nr_fds;
+}
+
static void perf_evlist__id_hash(struct perf_evlist *evlist,
struct perf_evsel *evsel,
int cpu, int thread, u64 id)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 106de53a6a74..1082420951f9 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -84,6 +84,8 @@ void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
+int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask);
+
struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
OpenPOWER on IntegriCloud