perf evlist: Introduce poll method for common code idiom
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 18 Aug 2014 20:25:59 +0000 (17:25 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 25 Sep 2014 19:46:55 +0000 (16:46 -0300)
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>
tools/perf/builtin-record.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c
tools/perf/tests/open-syscall-tp-fields.c
tools/perf/tests/perf-record.c
tools/perf/tests/task-exit.c
tools/perf/util/evlist.c
tools/perf/util/evlist.h
tools/perf/util/python.c

index a1b0403941709fab58d2f146472b92e107526fe8..a8c2e9dfb1255d7ced80237dd039aa18ef8516e8 100644 (file)
@@ -459,7 +459,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
                if (hits == rec->samples) {
                        if (done)
                                break;
-                       err = poll(rec->evlist->pollfd, rec->evlist->nr_fds, -1);
+                       err = perf_evlist__poll(rec->evlist, -1);
                        /*
                         * Propagate error, only if there's any. Ignore positive
                         * number of returned events and interrupt error.
index e13864be2acb772c2329417119f8df730b4b580b..832fb527ed90aa0467a0c712bf9bcf9ddc484398 100644 (file)
@@ -964,7 +964,7 @@ static int __cmd_top(struct perf_top *top)
                 perf_evlist__enable(top->evlist);
 
        /* Wait for a minimal set of events before starting the snapshot */
-       poll(top->evlist->pollfd, top->evlist->nr_fds, 100);
+       perf_evlist__poll(top->evlist, 100);
 
        perf_top__mmap_read(top);
 
@@ -991,7 +991,7 @@ static int __cmd_top(struct perf_top *top)
                perf_top__mmap_read(top);
 
                if (hits == top->samples)
-                       ret = poll(top->evlist->pollfd, top->evlist->nr_fds, 100);
+                       ret = perf_evlist__poll(top->evlist, 100);
        }
 
        ret = 0;
index a9e96ff49c7f3638dfe5ac40a85066d04f25543a..b8fedf3f99215589b80a276bb74d8af43dbf6002 100644 (file)
@@ -2171,7 +2171,7 @@ next_event:
        if (trace->nr_events == before) {
                int timeout = done ? 100 : -1;
 
-               if (poll(evlist->pollfd, evlist->nr_fds, timeout) > 0)
+               if (perf_evlist__poll(evlist, timeout) > 0)
                        goto again;
        } else {
                goto again;
index 922bdb627950f0300629a477991ff6af52bdf85f..127dcae0b76033cf457a4a4ff572da6771594e6f 100644 (file)
@@ -105,7 +105,7 @@ int test__syscall_open_tp_fields(void)
                }
 
                if (nr_events == before)
-                       poll(evlist->pollfd, evlist->nr_fds, 10);
+                       perf_evlist__poll(evlist, 10);
 
                if (++nr_polls > 5) {
                        pr_debug("%s: no events!\n", __func__);
index 2ce753c1db63f4b5b29b36df9edfe603da82b216..7a228a2a070bb2280d69320116b2985b5be05b21 100644 (file)
@@ -268,7 +268,7 @@ int test__PERF_RECORD(void)
                 * perf_event_attr.wakeup_events, just PERF_EVENT_SAMPLE does.
                 */
                if (total_events == before && false)
-                       poll(evlist->pollfd, evlist->nr_fds, -1);
+                       perf_evlist__poll(evlist, -1);
 
                sleep(1);
                if (++wakeups > 5) {
index 87522f01c7ad0c4a5851ef4e2b49552777eec280..3a8fedef83bc086e5328dea03dcf6107d3ff1e39 100644 (file)
@@ -105,7 +105,7 @@ retry:
        }
 
        if (!exited || !nr_exit) {
-               poll(evlist->pollfd, evlist->nr_fds, -1);
+               perf_evlist__poll(evlist, -1);
                goto retry;
        }
 
index bcf157c8a9daaf8f09b151e37414ac03036885b5..5ff3c667542f353ab978809d05b3cbc183d79614 100644 (file)
@@ -475,6 +475,11 @@ int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mas
        return nr_fds;
 }
 
+int perf_evlist__poll(struct perf_evlist *evlist, int timeout)
+{
+       return poll(evlist->pollfd, evlist->nr_fds, timeout);
+}
+
 static void perf_evlist__id_hash(struct perf_evlist *evlist,
                                 struct perf_evsel *evsel,
                                 int cpu, int thread, u64 id)
index bbc2fd01b5c5f5079815702d39228335a881db7a..d7e99b67c94f2af6849e2914b0e5f0f586830848 100644 (file)
@@ -87,6 +87,8 @@ int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
 int perf_evlist__alloc_pollfd(struct perf_evlist *evlist);
 int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask);
 
+int perf_evlist__poll(struct perf_evlist *evlist, int timeout);
+
 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);
index 12aa9b0d0ba1769debff0615c0158e2f1c890c21..4472f8be8e3577b936c45deb0f53b326a02ecf18 100644 (file)
@@ -736,7 +736,7 @@ static PyObject *pyrf_evlist__poll(struct pyrf_evlist *pevlist,
        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", kwlist, &timeout))
                return NULL;
 
-       n = poll(evlist->pollfd, evlist->nr_fds, timeout);
+       n = perf_evlist__poll(evlist, timeout);
        if (n < 0) {
                PyErr_SetFromErrno(PyExc_OSError);
                return NULL;