Commit 35b7cdc6 authored by Kan Liang's avatar Kan Liang Committed by Arnaldo Carvalho de Melo

perf python: Switch to new perf_mmap__read_event() interface

The perf python binding still use the legacy interface.

No functional change.

Committer notes:

Tested before and after with:

  [root@jouet perf]# export PYTHONPATH=/tmp/build/perf/python
  [root@jouet perf]# tools/perf/python/twatch.py
  cpu: 0, pid: 1183, tid: 6293 { type: exit, pid: 1183, ppid: 1183, tid: 6293, ptid: 6293, time: 17886646588257}
  cpu: 2, pid: 13820, tid: 13820 { type: fork, pid: 13820, ppid: 13820, tid: 6306, ptid: 13820, time: 17886869099529}
  cpu: 1, pid: 13820, tid: 6306 { type: comm, pid: 13820, tid: 6306, comm: TaskSchedulerFo }
  ^CTraceback (most recent call last):
    File "tools/perf/python/twatch.py", line 68, in <module>
      main()
    File "tools/perf/python/twatch.py", line 40, in main
      evlist.poll(timeout = -1)
  KeyboardInterrupt
  [root@jouet perf]#

No problems found.
Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1519945751-37786-3-git-send-email-kan.liang@linux.intel.com
[ Changed bool parameters from 0 to 'false', as per Jiri comment ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d7f55c62
...@@ -983,13 +983,19 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, ...@@ -983,13 +983,19 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
union perf_event *event; union perf_event *event;
int sample_id_all = 1, cpu; int sample_id_all = 1, cpu;
static char *kwlist[] = { "cpu", "sample_id_all", NULL }; static char *kwlist[] = { "cpu", "sample_id_all", NULL };
struct perf_mmap *md;
u64 end, start;
int err; int err;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist, if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i", kwlist,
&cpu, &sample_id_all)) &cpu, &sample_id_all))
return NULL; return NULL;
event = perf_evlist__mmap_read(evlist, cpu); md = &evlist->mmap[cpu];
if (perf_mmap__read_init(md, false, &start, &end) < 0)
goto end;
event = perf_mmap__read_event(md, false, &start, end);
if (event != NULL) { if (event != NULL) {
PyObject *pyevent = pyrf_event__new(event); PyObject *pyevent = pyrf_event__new(event);
struct pyrf_event *pevent = (struct pyrf_event *)pyevent; struct pyrf_event *pevent = (struct pyrf_event *)pyevent;
...@@ -1007,14 +1013,14 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, ...@@ -1007,14 +1013,14 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
err = perf_evsel__parse_sample(evsel, event, &pevent->sample); err = perf_evsel__parse_sample(evsel, event, &pevent->sample);
/* Consume the even only after we parsed it out. */ /* Consume the even only after we parsed it out. */
perf_evlist__mmap_consume(evlist, cpu); perf_mmap__consume(md, false);
if (err) if (err)
return PyErr_Format(PyExc_OSError, return PyErr_Format(PyExc_OSError,
"perf: can't parse sample, err=%d", err); "perf: can't parse sample, err=%d", err);
return pyevent; return pyevent;
} }
end:
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment