aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/python.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-30 08:59:43 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-31 09:40:52 -0500
commit7e2ed097538c57ff5268e9a6bced7c0b885809c8 (patch)
tree44f9998cc6054d5bef07d6c2979afb0e81ddf13c /tools/perf/util/python.c
parentf8a9530939ed87b9a1b1a038b90e355098b679a2 (diff)
perf evlist: Store pointer to the cpu and thread maps
So that we don't have to pass it around to the several methods that needs it, simplifying usage. There is one case where we don't have the thread/cpu map in advance, which is in the parsing routines used by top, stat, record, that we have to wait till all options are parsed to know if a cpu or thread list was passed to then create those maps. For that case consolidate the cpu and thread map creation via perf_evlist__create_maps() out of the code in top and record, while also providing a perf_evlist__set_maps() for cases where multiple evlists share maps or for when maps that represent CPU sockets, for instance, get crafted out of topology information or subsets of threads in a particular application are to be monitored, providing more granularity in specifying which cpus and threads to monitor. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
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 }