Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+15 -8
+1 -1
tools/perf/builtin-record.c
··· 459 459 if (hits == rec->samples) { 460 460 if (done) 461 461 break; 462 - err = poll(rec->evlist->pollfd, rec->evlist->nr_fds, -1); 462 + err = perf_evlist__poll(rec->evlist, -1); 463 463 /* 464 464 * Propagate error, only if there's any. Ignore positive 465 465 * number of returned events and interrupt error.
+2 -2
tools/perf/builtin-top.c
··· 964 964 perf_evlist__enable(top->evlist); 965 965 966 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 969 perf_top__mmap_read(top); 970 970 ··· 991 991 perf_top__mmap_read(top); 992 992 993 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 997 ret = 0;
+1 -1
tools/perf/builtin-trace.c
··· 2171 2171 if (trace->nr_events == before) { 2172 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 2175 goto again; 2176 2176 } else { 2177 2177 goto again;
+1 -1
tools/perf/tests/open-syscall-tp-fields.c
··· 105 105 } 106 106 107 107 if (nr_events == before) 108 - poll(evlist->pollfd, evlist->nr_fds, 10); 108 + perf_evlist__poll(evlist, 10); 109 109 110 110 if (++nr_polls > 5) { 111 111 pr_debug("%s: no events!\n", __func__);
+1 -1
tools/perf/tests/perf-record.c
··· 268 268 * perf_event_attr.wakeup_events, just PERF_EVENT_SAMPLE does. 269 269 */ 270 270 if (total_events == before && false) 271 - poll(evlist->pollfd, evlist->nr_fds, -1); 271 + perf_evlist__poll(evlist, -1); 272 272 273 273 sleep(1); 274 274 if (++wakeups > 5) {
+1 -1
tools/perf/tests/task-exit.c
··· 105 105 } 106 106 107 107 if (!exited || !nr_exit) { 108 - poll(evlist->pollfd, evlist->nr_fds, -1); 108 + perf_evlist__poll(evlist, -1); 109 109 goto retry; 110 110 } 111 111
+5
tools/perf/util/evlist.c
··· 475 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 483 static void perf_evlist__id_hash(struct perf_evlist *evlist, 479 484 struct perf_evsel *evsel, 480 485 int cpu, int thread, u64 id)
+2
tools/perf/util/evlist.h
··· 87 87 int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); 88 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 92 struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); 91 93 92 94 struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
+1 -1
tools/perf/util/python.c
··· 736 736 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", kwlist, &timeout)) 737 737 return NULL; 738 738 739 - n = poll(evlist->pollfd, evlist->nr_fds, timeout); 739 + n = perf_evlist__poll(evlist, timeout); 740 740 if (n < 0) { 741 741 PyErr_SetFromErrno(PyExc_OSError); 742 742 return NULL;