diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-08-18 16:25:59 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-09-25 15:46:55 -0400 |
commit | f66a889dbc96dd342c87232d74f0956076707746 (patch) | |
tree | e56930da92ec4753c15c2d572d4c87db935d2d41 | |
parent | 0a04c9e0b2181aff8348b5e80d9d96ec8df1ffb3 (diff) |
perf evlist: Introduce poll method for common code idiom
Since we have access two evlist members in all these poll calls, provide
a helper.
This will also help to make the patch introducing the pollfd class more
clear, as the evlist specific uses will be hiden away
perf_evlist__poll().
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-jr9d4aop4lvy9453qahbcgp0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-record.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/open-syscall-tp-fields.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/perf-record.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/task-exit.c | 2 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 5 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 2 | ||||
-rw-r--r-- | tools/perf/util/python.c | 2 |
9 files changed, 15 insertions, 8 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index a1b040394170..a8c2e9dfb125 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -459,7 +459,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
459 | if (hits == rec->samples) { | 459 | if (hits == rec->samples) { |
460 | if (done) | 460 | if (done) |
461 | break; | 461 | break; |
462 | err = poll(rec->evlist->pollfd, rec->evlist->nr_fds, -1); | 462 | err = perf_evlist__poll(rec->evlist, -1); |
463 | /* | 463 | /* |
464 | * Propagate error, only if there's any. Ignore positive | 464 | * Propagate error, only if there's any. Ignore positive |
465 | * number of returned events and interrupt error. | 465 | * number of returned events and interrupt error. |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index e13864be2acb..832fb527ed90 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -964,7 +964,7 @@ static int __cmd_top(struct perf_top *top) | |||
964 | perf_evlist__enable(top->evlist); | 964 | perf_evlist__enable(top->evlist); |
965 | 965 | ||
966 | /* Wait for a minimal set of events before starting the snapshot */ | 966 | /* Wait for a minimal set of events before starting the snapshot */ |
967 | poll(top->evlist->pollfd, top->evlist->nr_fds, 100); | 967 | perf_evlist__poll(top->evlist, 100); |
968 | 968 | ||
969 | perf_top__mmap_read(top); | 969 | perf_top__mmap_read(top); |
970 | 970 | ||
@@ -991,7 +991,7 @@ static int __cmd_top(struct perf_top *top) | |||
991 | perf_top__mmap_read(top); | 991 | perf_top__mmap_read(top); |
992 | 992 | ||
993 | if (hits == top->samples) | 993 | if (hits == top->samples) |
994 | ret = poll(top->evlist->pollfd, top->evlist->nr_fds, 100); | 994 | ret = perf_evlist__poll(top->evlist, 100); |
995 | } | 995 | } |
996 | 996 | ||
997 | ret = 0; | 997 | ret = 0; |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index a9e96ff49c7f..b8fedf3f9921 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -2171,7 +2171,7 @@ next_event: | |||
2171 | if (trace->nr_events == before) { | 2171 | if (trace->nr_events == before) { |
2172 | int timeout = done ? 100 : -1; | 2172 | int timeout = done ? 100 : -1; |
2173 | 2173 | ||
2174 | if (poll(evlist->pollfd, evlist->nr_fds, timeout) > 0) | 2174 | if (perf_evlist__poll(evlist, timeout) > 0) |
2175 | goto again; | 2175 | goto again; |
2176 | } else { | 2176 | } else { |
2177 | goto again; | 2177 | goto again; |
diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c index 922bdb627950..127dcae0b760 100644 --- a/tools/perf/tests/open-syscall-tp-fields.c +++ b/tools/perf/tests/open-syscall-tp-fields.c | |||
@@ -105,7 +105,7 @@ int test__syscall_open_tp_fields(void) | |||
105 | } | 105 | } |
106 | 106 | ||
107 | if (nr_events == before) | 107 | if (nr_events == before) |
108 | poll(evlist->pollfd, evlist->nr_fds, 10); | 108 | perf_evlist__poll(evlist, 10); |
109 | 109 | ||
110 | if (++nr_polls > 5) { | 110 | if (++nr_polls > 5) { |
111 | pr_debug("%s: no events!\n", __func__); | 111 | pr_debug("%s: no events!\n", __func__); |
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index 2ce753c1db63..7a228a2a070b 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c | |||
@@ -268,7 +268,7 @@ int test__PERF_RECORD(void) | |||
268 | * perf_event_attr.wakeup_events, just PERF_EVENT_SAMPLE does. | 268 | * perf_event_attr.wakeup_events, just PERF_EVENT_SAMPLE does. |
269 | */ | 269 | */ |
270 | if (total_events == before && false) | 270 | if (total_events == before && false) |
271 | poll(evlist->pollfd, evlist->nr_fds, -1); | 271 | perf_evlist__poll(evlist, -1); |
272 | 272 | ||
273 | sleep(1); | 273 | sleep(1); |
274 | if (++wakeups > 5) { | 274 | if (++wakeups > 5) { |
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index 87522f01c7ad..3a8fedef83bc 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c | |||
@@ -105,7 +105,7 @@ retry: | |||
105 | } | 105 | } |
106 | 106 | ||
107 | if (!exited || !nr_exit) { | 107 | if (!exited || !nr_exit) { |
108 | poll(evlist->pollfd, evlist->nr_fds, -1); | 108 | perf_evlist__poll(evlist, -1); |
109 | goto retry; | 109 | goto retry; |
110 | } | 110 | } |
111 | 111 | ||
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index bcf157c8a9da..5ff3c667542f 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -475,6 +475,11 @@ int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mas | |||
475 | return nr_fds; | 475 | return nr_fds; |
476 | } | 476 | } |
477 | 477 | ||
478 | int perf_evlist__poll(struct perf_evlist *evlist, int timeout) | ||
479 | { | ||
480 | return poll(evlist->pollfd, evlist->nr_fds, timeout); | ||
481 | } | ||
482 | |||
478 | static void perf_evlist__id_hash(struct perf_evlist *evlist, | 483 | static void perf_evlist__id_hash(struct perf_evlist *evlist, |
479 | struct perf_evsel *evsel, | 484 | struct perf_evsel *evsel, |
480 | int cpu, int thread, u64 id) | 485 | int cpu, int thread, u64 id) |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index bbc2fd01b5c5..d7e99b67c94f 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -87,6 +87,8 @@ int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); | |||
87 | int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); | 87 | int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); |
88 | int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask); | 88 | int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask); |
89 | 89 | ||
90 | int perf_evlist__poll(struct perf_evlist *evlist, int timeout); | ||
91 | |||
90 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); | 92 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); |
91 | 93 | ||
92 | struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id); | 94 | struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id); |
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 12aa9b0d0ba1..4472f8be8e35 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -736,7 +736,7 @@ static PyObject *pyrf_evlist__poll(struct pyrf_evlist *pevlist, | |||
736 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", kwlist, &timeout)) | 736 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", kwlist, &timeout)) |
737 | return NULL; | 737 | return NULL; |
738 | 738 | ||
739 | n = poll(evlist->pollfd, evlist->nr_fds, timeout); | 739 | n = perf_evlist__poll(evlist, timeout); |
740 | if (n < 0) { | 740 | if (n < 0) { |
741 | PyErr_SetFromErrno(PyExc_OSError); | 741 | PyErr_SetFromErrno(PyExc_OSError); |
742 | return NULL; | 742 | return NULL; |