Skip to content

Commit 5960aab

Browse files
captain5050namhyung
authored andcommitted
perf python: Add PMU argument to parse_metrics
Add an optional PMU argument to parse_metrics to allow restriction of the particular metrics to be opened. If no argument is provided then all metrics with the given name/group are opened Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Gautam Menghani <gautam@linux.ibm.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent a3ef39e commit 5960aab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/perf/util/python.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,22 +2051,22 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)
20512051

20522052
static PyObject *pyrf__parse_metrics(PyObject *self, PyObject *args)
20532053
{
2054-
const char *input;
2054+
const char *input, *pmu = NULL;
20552055
struct evlist evlist = {};
20562056
PyObject *result;
20572057
PyObject *pcpus = NULL, *pthreads = NULL;
20582058
struct perf_cpu_map *cpus;
20592059
struct perf_thread_map *threads;
20602060
int ret;
20612061

2062-
if (!PyArg_ParseTuple(args, "s|OO", &input, &pcpus, &pthreads))
2062+
if (!PyArg_ParseTuple(args, "s|sOO", &input, &pmu, &pcpus, &pthreads))
20632063
return NULL;
20642064

20652065
threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads : NULL;
20662066
cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus : NULL;
20672067

20682068
evlist__init(&evlist, cpus, threads);
2069-
ret = metricgroup__parse_groups(&evlist, /*pmu=*/"all", input,
2069+
ret = metricgroup__parse_groups(&evlist, pmu ?: "all", input,
20702070
/*metric_no_group=*/ false,
20712071
/*metric_no_merge=*/ false,
20722072
/*metric_no_threshold=*/ true,

0 commit comments

Comments
 (0)