Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf python: Add evlist all_cpus accessor

Add a means to get the reference counted all_cpus CPU map from an
evlist in its python form.

Reviewed-by: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/20250228222308.626803-10-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
1a8356fb 9e9472c1

+16
+16
tools/perf/util/python.c
··· 874 874 Py_TYPE(pevlist)->tp_free((PyObject*)pevlist); 875 875 } 876 876 877 + static PyObject *pyrf_evlist__all_cpus(struct pyrf_evlist *pevlist) 878 + { 879 + struct pyrf_cpu_map *pcpu_map = PyObject_New(struct pyrf_cpu_map, &pyrf_cpu_map__type); 880 + 881 + if (pcpu_map) 882 + pcpu_map->cpus = perf_cpu_map__get(pevlist->evlist.core.all_cpus); 883 + 884 + return (PyObject *)pcpu_map; 885 + } 886 + 877 887 static PyObject *pyrf_evlist__mmap(struct pyrf_evlist *pevlist, 878 888 PyObject *args, PyObject *kwargs) 879 889 { ··· 1067 1057 } 1068 1058 1069 1059 static PyMethodDef pyrf_evlist__methods[] = { 1060 + { 1061 + .ml_name = "all_cpus", 1062 + .ml_meth = (PyCFunction)pyrf_evlist__all_cpus, 1063 + .ml_flags = METH_NOARGS, 1064 + .ml_doc = PyDoc_STR("CPU map union of all evsel CPU maps.") 1065 + }, 1070 1066 { 1071 1067 .ml_name = "mmap", 1072 1068 .ml_meth = (PyCFunction)pyrf_evlist__mmap,