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 evsel cpus and threads functions

Allow access to cpus and thread_map structs associated with an evsel.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Gautam Menghani <gautam@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250519195148.1708988-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
0589aff4 3ee2255c

+33
+33
tools/perf/util/python.c
··· 781 781 return Py_None; 782 782 } 783 783 784 + static PyObject *pyrf_evsel__cpus(struct pyrf_evsel *pevsel) 785 + { 786 + struct pyrf_cpu_map *pcpu_map = PyObject_New(struct pyrf_cpu_map, &pyrf_cpu_map__type); 787 + 788 + if (pcpu_map) 789 + pcpu_map->cpus = perf_cpu_map__get(pevsel->evsel.core.cpus); 790 + 791 + return (PyObject *)pcpu_map; 792 + } 793 + 794 + static PyObject *pyrf_evsel__threads(struct pyrf_evsel *pevsel) 795 + { 796 + struct pyrf_thread_map *pthread_map = 797 + PyObject_New(struct pyrf_thread_map, &pyrf_thread_map__type); 798 + 799 + if (pthread_map) 800 + pthread_map->threads = perf_thread_map__get(pevsel->evsel.core.threads); 801 + 802 + return (PyObject *)pthread_map; 803 + } 804 + 784 805 static PyObject *pyrf_evsel__str(PyObject *self) 785 806 { 786 807 struct pyrf_evsel *pevsel = (void *)self; ··· 819 798 .ml_meth = (PyCFunction)pyrf_evsel__open, 820 799 .ml_flags = METH_VARARGS | METH_KEYWORDS, 821 800 .ml_doc = PyDoc_STR("open the event selector file descriptor table.") 801 + }, 802 + { 803 + .ml_name = "cpus", 804 + .ml_meth = (PyCFunction)pyrf_evsel__cpus, 805 + .ml_flags = METH_NOARGS, 806 + .ml_doc = PyDoc_STR("CPUs the event is to be used with.") 807 + }, 808 + { 809 + .ml_name = "threads", 810 + .ml_meth = (PyCFunction)pyrf_evsel__threads, 811 + .ml_flags = METH_NOARGS, 812 + .ml_doc = PyDoc_STR("threads the event is to be used with.") 822 813 }, 823 814 { .ml_name = NULL, } 824 815 };