[PATCH v1 06/11] perf python: Add optional cpus and threads arguments to parse_events
From: Ian Rogers
Date: Thu Jan 09 2025 - 02:52:46 EST
Used for the evlist initialization.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/python.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 6a7042fd2569..45ee6479e4dd 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -1330,12 +1330,18 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)
struct evlist evlist = {};
struct parse_events_error err;
PyObject *result;
+ PyObject *pcpus = NULL, *pthreads = NULL;
+ struct perf_cpu_map *cpus;
+ struct perf_thread_map *threads;
- if (!PyArg_ParseTuple(args, "s", &input))
+ if (!PyArg_ParseTuple(args, "s|OO", &input, &pcpus, &pthreads))
return NULL;
+ threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads : NULL;
+ cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus : NULL;
+
parse_events_error__init(&err);
- evlist__init(&evlist, NULL, NULL);
+ evlist__init(&evlist, cpus, threads);
if (parse_events(&evlist, input, &err)) {
parse_events_error__print(&err, input);
PyErr_SetFromErrno(PyExc_OSError);
--
2.47.1.613.gc27f4b7a9f-goog