aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/python.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/python.c')
-rw-r--r--tools/perf/util/python.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 88d47895a79c..d2d52175362e 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -553,7 +553,16 @@ struct pyrf_evlist {
553static int pyrf_evlist__init(struct pyrf_evlist *pevlist, 553static int pyrf_evlist__init(struct pyrf_evlist *pevlist,
554 PyObject *args, PyObject *kwargs) 554 PyObject *args, PyObject *kwargs)
555{ 555{
556 perf_evlist__init(&pevlist->evlist); 556 PyObject *pcpus = NULL, *pthreads = NULL;
557 struct cpu_map *cpus;
558 struct thread_map *threads;
559
560 if (!PyArg_ParseTuple(args, "OO", &pcpus, &pthreads))
561 return -1;
562
563 threads = ((struct pyrf_thread_map *)pthreads)->threads;
564 cpus = ((struct pyrf_cpu_map *)pcpus)->cpus;
565 perf_evlist__init(&pevlist->evlist, cpus, threads);
557 return 0; 566 return 0;
558} 567}
559 568
@@ -567,21 +576,15 @@ static PyObject *pyrf_evlist__mmap(struct pyrf_evlist *pevlist,
567 PyObject *args, PyObject *kwargs) 576 PyObject *args, PyObject *kwargs)
568{ 577{
569 struct perf_evlist *evlist = &pevlist->evlist; 578 struct perf_evlist *evlist = &pevlist->evlist;
570 PyObject *pcpus = NULL, *pthreads = NULL; 579 static char *kwlist[] = {"pages", "overwrite",
571 struct cpu_map *cpus = NULL;
572 struct thread_map *threads = NULL;
573 static char *kwlist[] = {"cpus", "threads", "pages", "overwrite",
574 NULL, NULL}; 580 NULL, NULL};
575 int pages = 128, overwrite = false; 581 int pages = 128, overwrite = false;
576 582
577 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|ii", kwlist, 583 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", kwlist,
578 &pcpus, &pthreads, &pages, &overwrite)) 584 &pages, &overwrite))
579 return NULL; 585 return NULL;
580 586
581 threads = ((struct pyrf_thread_map *)pthreads)->threads; 587 if (perf_evlist__mmap(evlist, pages, overwrite) < 0) {
582 cpus = ((struct pyrf_cpu_map *)pcpus)->cpus;
583
584 if (perf_evlist__mmap(evlist, cpus, threads, pages, overwrite) < 0) {
585 PyErr_SetFromErrno(PyExc_OSError); 588 PyErr_SetFromErrno(PyExc_OSError);
586 return NULL; 589 return NULL;
587 } 590 }