diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-08-12 22:04:11 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-09-25 15:46:53 -0400 |
commit | 1ddec7f0d0ab5b71cf2cc5a782441c20e7afbcfb (patch) | |
tree | baae592cdbb5f1d443136fda8757a9fcd06412e0 /tools/perf/util | |
parent | 521e8bac67a71a6544274f39d5c61473e0e54ac0 (diff) |
perf evlist: Introduce perf_evlist__filter_pollfd method
To remove all entries in evlist->pollfd[] that have revents matching at
least one of the bits in the specified mask.
It'll adjust evlist->nr_fds to the number of unfiltered fds and will
return this value, as a convenience and to avoid requiring direct access
to internal state of perf_evlist objects.
This will be used after polling the evlist fds so that we remove fds
that were closed by the kernel.
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-y2sca7z3wicvvy40a50lozwm@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/evlist.c | 21 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 2 |
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) | |||
428 | evlist->nr_fds++; | 428 | evlist->nr_fds++; |
429 | } | 429 | } |
430 | 430 | ||
431 | int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask) | ||
432 | { | ||
433 | int fd, nr_fds = 0; | ||
434 | |||
435 | if (evlist->nr_fds == 0) | ||
436 | return 0; | ||
437 | |||
438 | for (fd = 0; fd < evlist->nr_fds; ++fd) { | ||
439 | if (evlist->pollfd[fd].revents & revents_and_mask) | ||
440 | continue; | ||
441 | |||
442 | if (fd != nr_fds) | ||
443 | evlist->pollfd[nr_fds] = evlist->pollfd[fd]; | ||
444 | |||
445 | ++nr_fds; | ||
446 | } | ||
447 | |||
448 | evlist->nr_fds = nr_fds; | ||
449 | return nr_fds; | ||
450 | } | ||
451 | |||
431 | static void perf_evlist__id_hash(struct perf_evlist *evlist, | 452 | static void perf_evlist__id_hash(struct perf_evlist *evlist, |
432 | struct perf_evsel *evsel, | 453 | struct perf_evsel *evsel, |
433 | int cpu, int thread, u64 id) | 454 | 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, | |||
84 | 84 | ||
85 | void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); | 85 | void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); |
86 | 86 | ||
87 | int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask); | ||
88 | |||
87 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); | 89 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); |
88 | 90 | ||
89 | struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id); | 91 | struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id); |