Change python polling guts using evlist->pollfd for
poller object.

Cc: Adrian Hunter <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Signed-off-by: Jiri Olsa <[email protected]>
---
 tools/perf/util/python-ext-sources |  2 ++
 tools/perf/util/python.c           | 19 +++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/python-ext-sources 
b/tools/perf/util/python-ext-sources
index 16a475a7d492..a2d584126eb1 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -20,3 +20,5 @@ util/strlist.c
 ../lib/api/fs/fs.c
 util/trace-event.c
 ../../lib/rbtree.c
+util/poller.c
+util/string.c
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 12aa9b0d0ba1..5903b6c30c16 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -7,6 +7,7 @@
 #include "event.h"
 #include "cpumap.h"
 #include "thread_map.h"
+#include "poller.h"
 
 /*
  * Support debug printing even though util/debug.c is not linked.  That means
@@ -730,13 +731,22 @@ static PyObject *pyrf_evlist__poll(struct pyrf_evlist 
*pevlist,
                                   PyObject *args, PyObject *kwargs)
 {
        struct perf_evlist *evlist = &pevlist->evlist;
+       struct poller *poller = &evlist->poller;
        static char *kwlist[] = { "timeout", NULL };
-       int timeout = -1, n;
+       int timeout = -1, n, err;
 
        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", kwlist, &timeout))
                return NULL;
 
-       n = poll(evlist->pollfd, evlist->nr_fds, timeout);
+       if (poller__empty(poller)) {
+               err = perf_evlist__set_poller(evlist);
+               if (err) {
+                       PyErr_SetFromErrno(PyExc_OSError);
+                       return NULL;
+               }
+       }
+
+       n = poller__poll(poller, timeout);
        if (n < 0) {
                PyErr_SetFromErrno(PyExc_OSError);
                return NULL;
@@ -750,12 +760,13 @@ static PyObject *pyrf_evlist__get_pollfd(struct 
pyrf_evlist *pevlist,
                                         PyObject *kwargs __maybe_unused)
 {
        struct perf_evlist *evlist = &pevlist->evlist;
+       struct poller *poller = &evlist->poller;
         PyObject *list = PyList_New(0);
        int i;
 
-       for (i = 0; i < evlist->nr_fds; ++i) {
+       for (i = 0; i < poller->n; ++i) {
                PyObject *file;
-               FILE *fp = fdopen(evlist->pollfd[i].fd, "r");
+               FILE *fp = fdopen(poller->ptr[i].fd, "r");
 
                if (fp == NULL)
                        goto free_list;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to