linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/3] perf ilist: Don't display deprecated events
@ 2025-10-16 22:22 Ian Rogers
  2025-10-16 22:22 ` [PATCH v1 2/3] perf python: Add PMU argument to parse_metrics Ian Rogers
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Ian Rogers @ 2025-10-16 22:22 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Howard Chu, Gautam Menghani, linux-perf-users,
	linux-kernel

Unsupported legacy events are flagged as deprecated. Don't display
these events in ilist as they won't open and there are over 1,000
legacy cache events.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/python/ilist.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/python/ilist.py b/tools/perf/python/ilist.py
index 9d6465c60df3..69005a88872e 100755
--- a/tools/perf/python/ilist.py
+++ b/tools/perf/python/ilist.py
@@ -439,6 +439,8 @@ class IListApp(App):
                 pmu_node = pmus.add(pmu_name)
                 try:
                     for event in sorted(pmu.events(), key=lambda x: x["name"]):
+                        if "deprecated" in event:
+                            continue
                         if "name" in event:
                             e = event["name"].lower()
                             if "alias" in event:
-- 
2.51.0.858.gf9c4a03a3a-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/3] perf python: Add PMU argument to parse_metrics
  2025-10-16 22:22 [PATCH v1 1/3] perf ilist: Don't display deprecated events Ian Rogers
@ 2025-10-16 22:22 ` Ian Rogers
  2025-10-17 14:21   ` Gautam Menghani
  2025-10-16 22:22 ` [PATCH v1 3/3] perf ilist: Add PMU information to metrics Ian Rogers
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Ian Rogers @ 2025-10-16 22:22 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Howard Chu, Gautam Menghani, linux-perf-users,
	linux-kernel

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>
---
 tools/perf/util/python.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 779fe1280a56..fa5e4270d182 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -2051,7 +2051,7 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)
 
 static PyObject *pyrf__parse_metrics(PyObject *self, PyObject *args)
 {
-	const char *input;
+	const char *input, *pmu = NULL;
 	struct evlist evlist = {};
 	PyObject *result;
 	PyObject *pcpus = NULL, *pthreads = NULL;
@@ -2059,14 +2059,14 @@ static PyObject *pyrf__parse_metrics(PyObject *self, PyObject *args)
 	struct perf_thread_map *threads;
 	int ret;
 
-	if (!PyArg_ParseTuple(args, "s|OO", &input, &pcpus, &pthreads))
+	if (!PyArg_ParseTuple(args, "s|sOO", &input, &pmu, &pcpus, &pthreads))
 		return NULL;
 
 	threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads : NULL;
 	cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus : NULL;
 
 	evlist__init(&evlist, cpus, threads);
-	ret = metricgroup__parse_groups(&evlist, /*pmu=*/"all", input,
+	ret = metricgroup__parse_groups(&evlist, pmu ?: "all", input,
 					/*metric_no_group=*/ false,
 					/*metric_no_merge=*/ false,
 					/*metric_no_threshold=*/ true,
-- 
2.51.0.858.gf9c4a03a3a-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 3/3] perf ilist: Add PMU information to metrics
  2025-10-16 22:22 [PATCH v1 1/3] perf ilist: Don't display deprecated events Ian Rogers
  2025-10-16 22:22 ` [PATCH v1 2/3] perf python: Add PMU argument to parse_metrics Ian Rogers
@ 2025-10-16 22:22 ` Ian Rogers
  2025-10-19  2:56 ` [PATCH v1 1/3] perf ilist: Don't display deprecated events Namhyung Kim
  2025-10-20  2:12 ` Namhyung Kim
  3 siblings, 0 replies; 9+ messages in thread
From: Ian Rogers @ 2025-10-16 22:22 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Howard Chu, Gautam Menghani, linux-perf-users,
	linux-kernel

Duplicate metrics may exist on hybrid platforms, with the metric's PMU
being used to select the metric to use. Incorporate the metric PMU
into the ilist display and support opening it just for a given PMU.

Before:
```
 ⭘                                    Interactive Perf List
    ├── ▼ TopdownL1                               tma_backend_bound
    │   ├── tma_backend_bound                     Counts the total number of issue slots that were
    │   ├── ▶ tma_backend_bound_group             not consumed by the backend due to backend stalls
    │   ├── tma_backend_bound                     Counts the total number of issue slots that were
    │   ├── ▶ tma_backend_bound_group             not consumed by the backend due to backend stalls.
    │   ├── tma_bad_speculation                   Note that uops must be available for consumption
    │   ├── ▶ tma_bad_speculation_group           in order for this event to count. If a uop is not
    │   ├── tma_bad_speculation                   available (IQ is empty), this event will not count
    │   ├── ▶ tma_bad_speculation_group           cpu_atom@TOPDOWN_BE_BOUND.ALL@ / (5 *
    │   ├── tma_frontend_bound                    cpu_atom@CPU_CLK_UNHALTED.CORE@)
    │   ├── ▶ tma_frontend_bound_group            tma_backend_bound > 0.1
    │   ├── tma_frontend_bound                  ▆▆
    │   ├── ▶ tma_frontend_bound_group
    │   ├── tma_retiring
    │   ├── ▶ tma_retiring_group
    │   ├── tma_retiring
    │   └── ▶ tma_retiring_group
    ├── ▶ TopdownL2
total▄▄▅▅▆▅▅▂▁▁▁▁▂▃▂▂▃▄▄▇▇█▆▆▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▄▅▅▅▄▆▆▆▅▅▅▅▅▅▇▇▇▇▆▅▆▆▆▆▅▅▅▄▃▃▃▃▃▃▃▃▃▃▄▄▄▅▅▅▅▅▆▆▆▆▆▆
cpu0▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
cpu1▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▃▃▃▃▃▃▃▃▄▄▄▄▄▄▄▄▄▄▅▅▅▅▅▅▅▅▅▅▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
cpu2▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
cpu3▁▁▁▁▁▁▁▁▁▄▄▄▄▄▄▄▄▄▄█████▆▆▆▆▆▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅
cpu4████▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂
cpu5▁▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▇▇▇▇▇▇▇▇▇▇▆▆
cpu6▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
cpu7▁▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▃▃▃▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▆▆▆▆▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
cpu8▁▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▃▃▃▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▅▅▅▅▅▆▆▆▆▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
cpu9▁▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂█████▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅
cpu10▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
cpu11▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇█████▁▁▁▁▁▁▁▁▁
cpu12▁▁▁▁▁▁▁▁▁▁▁▁▁▁▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
cpu13▁▁▁▁▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
cpu14▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇█████▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
cpu15▁▁▁▁▁▁▁▁▁▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
cpu16▃▃▃▃▃▃▃▃▃▄▄▃▃▃▃▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▄▃▃▃▃▃▃▃▃▄▄▄▄▄▄▁▁▃▃▃▃▃▃▃▃▃▃▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
cpu17▁▁▁▁▁▄▄▅▅▅▅▅▅▅▅▄▄▄▄▄▄▄▄▃▃▃▃▂▂▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▄▄▄▄▃▃▃▃▂▂▂▂▄▄▄▄▄▄▆▆▆▆▆▆▆▆▆▆▆▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
 s Search  n Next  p Previous  c Collapse  ^q Quit                                      ▏^p palette
```

After:
```
 ⭘                                    Interactive Perf List
    ├── ▼ TopdownL1                               tma_backend_bound
    │   ├── tma_backend_bound (cpu_atom)          Counts the total number of issue slots that were
    │   ├── ▼ tma_backend_bound_group (cpu_atom)  not consumed by the backend due to backend stalls
    │   │   ├── tma_core_bound (cpu_atom)         Counts the total number of issue slots that were
    │   │   ├── ▶ tma_core_bound_group (cpu_atom  not consumed by the backend due to backend stalls.
    │   │   ├── tma_resource_bound (cpu_atom)     Note that uops must be available for consumption
    │   │   └── ▶ tma_resource_bound_group (cpu_  in order for this event to count. If a uop is not
    │   ├── tma_backend_bound (cpu_core)          available (IQ is empty), this event will not count
    │   ├── ▶ tma_backend_bound_group (cpu_core)  cpu_atom@TOPDOWN_BE_BOUND.ALL@ / (5 *
    │   ├── tma_bad_speculation (cpu_atom)        cpu_atom@CPU_CLK_UNHALTED.CORE@)
    │   ├── ▶ tma_bad_speculation_group (cpu_ato▆▆tma_backend_bound > 0.1
    │   ├── tma_bad_speculation (cpu_core)
    │   ├── ▶ tma_bad_speculation_group (cpu_cor▃▃
    │   ├── tma_frontend_bound (cpu_atom)
    │   ├── ▶ tma_frontend_bound_group (cpu_atom
    │   ├── tma_frontend_bound (cpu_core)
    │   ├── ▶ tma_frontend_bound_group (cpu_core
                                           ▌
total▁▁▁▁▂▂▂▂▂▂▂▂▂▃▃▃▃▃▃▃▃▃▃▂▂▂▂▃▃▃▄▄▄▄▄▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▄▄▄▄▄▄▅▅▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▇▆▇▇
cpu16▇▇▇▇▇▇▇▇▇▇▇▆▆▁▁▁▁▁▁▁▁▁▁▁▁▂▂▄▄▅▅▅▅▅▅▆▆▆▆▆▆▆▆▇▇▇▇▆▆▆▆▆▆▆▆▅▅▅▅▅▅▅▅▅▅▅▅▅▅▆▆▆▆▄▄▄▄▃▃▄▄▄▄▇▇▇▇▇▇▇▇▇▇
cpu17█▇▇▇▇▇▇▇▇▆▆▆▆▆▆▅▅▅▅▃▃▃▃▂▂▁▁▅▅▅▅▅▅▅▅▄▄▄▄▄▄▄▄▄▄▄▄▃▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▅▅▄▄▂▂▇▇▇▇▆▆▅▅▆▆
cpu18▇▇▇▇▇██▇▇▃▃▃▃▃▃▃▃▃▃▂▂▂▂▂▂▂▂▃▃▃▃▃▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▄▄▄▄▄▅▅▅▅▅▅▅▅
cpu19▇▃▃▄▄▄▄▄▄▄▄▄▄▅▅▅▅▅▅▅▅▁▁▂▂▃▃▃▃▅▅▆▆▆▆▆▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇██▇▇▇▇▇▇▆▆▅▅▅▅▆▆▄▄▄▄▅▅
cpu20▃▃▃▃▃▃▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▂▂▂▂▂▄▄▄▄▅▅▅▅▅▅▆▆▇▇
cpu21▇▇▇▇▇▇▇██▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▆▆▆▆▆▆▆▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▆▆▆▆▆▆▆▆▆▆▆▆▆▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▅▅▄▄▂▂▂▂▂▂▁▁▁▁
cpu22█▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▆▆▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▂▂▁▁▁▁▂▂▂▂▂▂▂▂
cpu23▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▃▄▄▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▇▇▇▇▆▆██▇▇▇▇▇▇
cpu24▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▃▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▅▅▇▇▆▆▆▆▆▆▇▇▇▇
cpu25▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▆▆▆▆▇▇▇▇▇▇██
cpu26▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▃▄▄▇▇▇▇▇▇▇▇▇▇██▇▇▇▇▇▇▇▇▇▇▆▆▆▆▆▆▆▆▆▆▆▆▇▇▇▇▇▇▇▇▆▆▆▆▆▆▆▆▆▆▂▂▁▁▁▁▂▂▂▂▂▂▂▂
cpu27▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▄▄▄▄▅▅▅▅▅▅▇▇
total 7.4923074548462605
cpu16 0.2961618003253457
cpu17 0.3065719718925585
cpu18 0.27800656881051855
cpu19 0.28564742078353406
cpu20 0.2764790653117084
 s Search  n Next  p Previous  c Collapse  ^q Quit                                      ▏^p palette
```

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/python/ilist.py | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/tools/perf/python/ilist.py b/tools/perf/python/ilist.py
index 69005a88872e..eb687ce9d5a6 100755
--- a/tools/perf/python/ilist.py
+++ b/tools/perf/python/ilist.py
@@ -51,6 +51,7 @@ class TreeValue(ABC):
 class Metric(TreeValue):
     """A metric in the tree."""
     metric_name: str
+    metric_pmu: str
 
     def name(self) -> str:
         return self.metric_name
@@ -60,6 +61,8 @@ class Metric(TreeValue):
         for metric in perf.metrics():
             if metric["MetricName"] != self.metric_name:
                 continue
+            if self.metric_pmu and metric["PMU"] != self.metric_pmu:
+                continue
             desc = get_info(metric, "BriefDescription")
             desc += get_info(metric, "PublicDescription")
             desc += get_info(metric, "MetricExpr")
@@ -71,7 +74,7 @@ class Metric(TreeValue):
         return query in self.metric_name
 
     def parse(self) -> perf.evlist:
-        return perf.parse_metrics(self.metric_name)
+        return perf.parse_metrics(self.metric_name, self.metric_pmu)
 
     def value(self, evlist: perf.evlist, evsel: perf.evsel, cpu: int, thread: int) -> float:
         val = evlist.compute_metric(self.metric_name, cpu, thread)
@@ -456,14 +459,25 @@ class IListApp(App):
             for metric in perf.metrics():
                 groups.update(metric["MetricGroup"])
 
-            def add_metrics_to_tree(node: TreeNode[TreeValue], parent: str):
+            def add_metrics_to_tree(node: TreeNode[TreeValue], parent: str, pmu: str = None):
                 for metric in sorted(perf.metrics(), key=lambda x: x["MetricName"]):
+                    metric_pmu = metric.get('PMU')
+                    if pmu and metric_pmu and metric_pmu != pmu:
+                        continue
                     if parent in metric["MetricGroup"]:
                         name = metric["MetricName"]
-                        node.add_leaf(name, data=Metric(name))
+                        display_name = name
+                        if metric_pmu:
+                            display_name += f" ({metric_pmu})"
+                        node.add_leaf(display_name, data=Metric(name, metric_pmu))
                         child_group_name = f'{name}_group'
                         if child_group_name in groups:
-                            add_metrics_to_tree(node.add(child_group_name), child_group_name)
+                            display_child_group_name = child_group_name
+                            if metric_pmu:
+                                display_child_group_name += f" ({metric_pmu})"
+                            add_metrics_to_tree(node.add(display_child_group_name),
+                                                child_group_name,
+                                                metric_pmu)
 
             for group in sorted(groups):
                 if group.endswith('_group'):
-- 
2.51.0.858.gf9c4a03a3a-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 2/3] perf python: Add PMU argument to parse_metrics
  2025-10-16 22:22 ` [PATCH v1 2/3] perf python: Add PMU argument to parse_metrics Ian Rogers
@ 2025-10-17 14:21   ` Gautam Menghani
  0 siblings, 0 replies; 9+ messages in thread
From: Gautam Menghani @ 2025-10-17 14:21 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Howard Chu, linux-perf-users, linux-kernel

On Thu, Oct 16, 2025 at 03:22:27PM -0700, Ian Rogers wrote:
> 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>
> ---
>  tools/perf/util/python.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
> index 779fe1280a56..fa5e4270d182 100644
> --- a/tools/perf/util/python.c
> +++ b/tools/perf/util/python.c
> @@ -2051,7 +2051,7 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)
>  
>  static PyObject *pyrf__parse_metrics(PyObject *self, PyObject *args)
>  {
> -	const char *input;
> +	const char *input, *pmu = NULL;
>  	struct evlist evlist = {};
>  	PyObject *result;
>  	PyObject *pcpus = NULL, *pthreads = NULL;
> @@ -2059,14 +2059,14 @@ static PyObject *pyrf__parse_metrics(PyObject *self, PyObject *args)
>  	struct perf_thread_map *threads;
>  	int ret;
>  
> -	if (!PyArg_ParseTuple(args, "s|OO", &input, &pcpus, &pthreads))
> +	if (!PyArg_ParseTuple(args, "s|sOO", &input, &pmu, &pcpus, &pthreads))
>  		return NULL;
>  
>  	threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads : NULL;
>  	cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus : NULL;
>  
>  	evlist__init(&evlist, cpus, threads);
> -	ret = metricgroup__parse_groups(&evlist, /*pmu=*/"all", input,
> +	ret = metricgroup__parse_groups(&evlist, pmu ?: "all", input,
>  					/*metric_no_group=*/ false,
>  					/*metric_no_merge=*/ false,
>  					/*metric_no_threshold=*/ true,
> -- 

Acked-by: Gautam Menghani <gautam@linux.ibm.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] perf ilist: Don't display deprecated events
  2025-10-16 22:22 [PATCH v1 1/3] perf ilist: Don't display deprecated events Ian Rogers
  2025-10-16 22:22 ` [PATCH v1 2/3] perf python: Add PMU argument to parse_metrics Ian Rogers
  2025-10-16 22:22 ` [PATCH v1 3/3] perf ilist: Add PMU information to metrics Ian Rogers
@ 2025-10-19  2:56 ` Namhyung Kim
  2025-10-19  6:50   ` Howard Chu
  2025-10-20  2:12 ` Namhyung Kim
  3 siblings, 1 reply; 9+ messages in thread
From: Namhyung Kim @ 2025-10-19  2:56 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Howard Chu,
	Gautam Menghani, linux-perf-users, linux-kernel

Hi Ian,

On Thu, Oct 16, 2025 at 03:22:26PM -0700, Ian Rogers wrote:
> Unsupported legacy events are flagged as deprecated. Don't display
> these events in ilist as they won't open and there are over 1,000
> legacy cache events.

Off-topic, any chance to integrate this into a perf command?
It'd be convenient if we can call this like `perf list --interactive`
or some other way.

Thanks,
Namhyung

> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/python/ilist.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/perf/python/ilist.py b/tools/perf/python/ilist.py
> index 9d6465c60df3..69005a88872e 100755
> --- a/tools/perf/python/ilist.py
> +++ b/tools/perf/python/ilist.py
> @@ -439,6 +439,8 @@ class IListApp(App):
>                  pmu_node = pmus.add(pmu_name)
>                  try:
>                      for event in sorted(pmu.events(), key=lambda x: x["name"]):
> +                        if "deprecated" in event:
> +                            continue
>                          if "name" in event:
>                              e = event["name"].lower()
>                              if "alias" in event:
> -- 
> 2.51.0.858.gf9c4a03a3a-goog
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] perf ilist: Don't display deprecated events
  2025-10-19  2:56 ` [PATCH v1 1/3] perf ilist: Don't display deprecated events Namhyung Kim
@ 2025-10-19  6:50   ` Howard Chu
  2025-10-19 23:04     ` Ian Rogers
  0 siblings, 1 reply; 9+ messages in thread
From: Howard Chu @ 2025-10-19  6:50 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Gautam Menghani,
	linux-perf-users, linux-kernel

Hi Namhyung,

On Sat, Oct 18, 2025 at 7:56 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hi Ian,
>
> On Thu, Oct 16, 2025 at 03:22:26PM -0700, Ian Rogers wrote:
> > Unsupported legacy events are flagged as deprecated. Don't display
> > these events in ilist as they won't open and there are over 1,000
> > legacy cache events.
>
> Off-topic, any chance to integrate this into a perf command?
> It'd be convenient if we can call this like `perf list --interactive`
> or some other way.

You have my vote, user-friendliness is important.
I think Ian mentioned that the major drawback is the difficulty of
forwarding arguments passed to the ilist.py program. A random thought:
perf is known for binding everything under a single command, but to
make scripting more flexible, perhaps some Bash scripts added to
.bashrc could be considered. After all, perf is fundamentally a
command-line tool.

Thanks,
Howard

>
> Thanks,
> Namhyung
>
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  tools/perf/python/ilist.py | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/perf/python/ilist.py b/tools/perf/python/ilist.py
> > index 9d6465c60df3..69005a88872e 100755
> > --- a/tools/perf/python/ilist.py
> > +++ b/tools/perf/python/ilist.py
> > @@ -439,6 +439,8 @@ class IListApp(App):
> >                  pmu_node = pmus.add(pmu_name)
> >                  try:
> >                      for event in sorted(pmu.events(), key=lambda x: x["name"]):
> > +                        if "deprecated" in event:
> > +                            continue
> >                          if "name" in event:
> >                              e = event["name"].lower()
> >                              if "alias" in event:
> > --
> > 2.51.0.858.gf9c4a03a3a-goog
> >

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] perf ilist: Don't display deprecated events
  2025-10-19  6:50   ` Howard Chu
@ 2025-10-19 23:04     ` Ian Rogers
  2025-10-20  1:10       ` Namhyung Kim
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Rogers @ 2025-10-19 23:04 UTC (permalink / raw)
  To: Howard Chu, Namhyung Kim, Arnaldo Carvalho de Melo,
	Gautam Menghani
  Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter, linux-perf-users, linux-kernel

On Sat, Oct 18, 2025 at 11:50 PM Howard Chu <howardchu95@gmail.com> wrote:
>
> Hi Namhyung,
>
> On Sat, Oct 18, 2025 at 7:56 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > Hi Ian,
> >
> > On Thu, Oct 16, 2025 at 03:22:26PM -0700, Ian Rogers wrote:
> > > Unsupported legacy events are flagged as deprecated. Don't display
> > > these events in ilist as they won't open and there are over 1,000
> > > legacy cache events.
> >
> > Off-topic, any chance to integrate this into a perf command?
> > It'd be convenient if we can call this like `perf list --interactive`
> > or some other way.
>
> You have my vote, user-friendliness is important.
> I think Ian mentioned that the major drawback is the difficulty of
> forwarding arguments passed to the ilist.py program. A random thought:
> perf is known for binding everything under a single command, but to
> make scripting more flexible, perhaps some Bash scripts added to
> .bashrc could be considered. After all, perf is fundamentally a
> command-line tool.

Thanks Howard and Namhyung,

I think Arnaldo also raised this in the past.  My thought on how to do
this is to build in to `perf script`:

1) `perf script` currently uses libpython and then exposes a
trace_start, trace_end and process_event method. When building the
flamegraph work the only place that textual can run is in trace_end as
it needs to run on the main python thread. This means we can't do
incremental loading of data files while textual is showing the data as
perf wants to be the main thread. So step 1 is to create a python
version of the trace_start, trace_end and process_event callbacks. To
do this something like the session API needs wrapping or writing in
python. I'm not sure I'd keep the API the same as the C one. It'd be
interesting to think of async file processing. It'd be nice to make
the generation of strings.. in the event lazier. We could start with
the existing API though, and then migrate to something more complex
later.

2) Once we have a session like API in python we can convert the
existing `perf script` commands to be standalone tools similar to
ilist. So we can convert all the existing tools to be standalone.

3) Once we have standalone versions of the `perf script` scripts then
we can have `perf script` just exec the commands. The install step can
install the scripts like it currently does and we can move ilist into
the scripts location.

4) Once we run python things as tools in their own right we can
deprecate the libpython stuff, probably make it a build opt-in thing,
etc. It seems hard to delete unused features, like libbfd, from the
codebase. We did merge a patch deprecating libperl as a step in this
direction.

Thanks,
Ian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] perf ilist: Don't display deprecated events
  2025-10-19 23:04     ` Ian Rogers
@ 2025-10-20  1:10       ` Namhyung Kim
  0 siblings, 0 replies; 9+ messages in thread
From: Namhyung Kim @ 2025-10-20  1:10 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Howard Chu, Arnaldo Carvalho de Melo, Gautam Menghani,
	Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter, linux-perf-users, linux-kernel

On Sun, Oct 19, 2025 at 04:04:17PM -0700, Ian Rogers wrote:
> On Sat, Oct 18, 2025 at 11:50 PM Howard Chu <howardchu95@gmail.com> wrote:
> >
> > Hi Namhyung,
> >
> > On Sat, Oct 18, 2025 at 7:56 PM Namhyung Kim <namhyung@kernel.org> wrote:
> > >
> > > Hi Ian,
> > >
> > > On Thu, Oct 16, 2025 at 03:22:26PM -0700, Ian Rogers wrote:
> > > > Unsupported legacy events are flagged as deprecated. Don't display
> > > > these events in ilist as they won't open and there are over 1,000
> > > > legacy cache events.
> > >
> > > Off-topic, any chance to integrate this into a perf command?
> > > It'd be convenient if we can call this like `perf list --interactive`
> > > or some other way.
> >
> > You have my vote, user-friendliness is important.
> > I think Ian mentioned that the major drawback is the difficulty of
> > forwarding arguments passed to the ilist.py program. A random thought:
> > perf is known for binding everything under a single command, but to
> > make scripting more flexible, perhaps some Bash scripts added to
> > .bashrc could be considered. After all, perf is fundamentally a
> > command-line tool.
> 
> Thanks Howard and Namhyung,
> 
> I think Arnaldo also raised this in the past.  My thought on how to do
> this is to build in to `perf script`:
> 
> 1) `perf script` currently uses libpython and then exposes a
> trace_start, trace_end and process_event method. When building the
> flamegraph work the only place that textual can run is in trace_end as
> it needs to run on the main python thread. This means we can't do
> incremental loading of data files while textual is showing the data as
> perf wants to be the main thread. So step 1 is to create a python
> version of the trace_start, trace_end and process_event callbacks. To
> do this something like the session API needs wrapping or writing in
> python. I'm not sure I'd keep the API the same as the C one. It'd be
> interesting to think of async file processing. It'd be nice to make
> the generation of strings.. in the event lazier. We could start with
> the existing API though, and then migrate to something more complex
> later.

Sounds like a long term plan.  I'm ok with the change but not sure how
soon it would happen.  I was suggesting a short term workaround if you
don't plan to work on this.  I thought we can exec ilist.py with proper
settings from `perf list`.  But it's up to you. :)

Thanks,
Namhyung

> 
> 2) Once we have a session like API in python we can convert the
> existing `perf script` commands to be standalone tools similar to
> ilist. So we can convert all the existing tools to be standalone.
> 
> 3) Once we have standalone versions of the `perf script` scripts then
> we can have `perf script` just exec the commands. The install step can
> install the scripts like it currently does and we can move ilist into
> the scripts location.
> 
> 4) Once we run python things as tools in their own right we can
> deprecate the libpython stuff, probably make it a build opt-in thing,
> etc. It seems hard to delete unused features, like libbfd, from the
> codebase. We did merge a patch deprecating libperl as a step in this
> direction.
> 
> Thanks,
> Ian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] perf ilist: Don't display deprecated events
  2025-10-16 22:22 [PATCH v1 1/3] perf ilist: Don't display deprecated events Ian Rogers
                   ` (2 preceding siblings ...)
  2025-10-19  2:56 ` [PATCH v1 1/3] perf ilist: Don't display deprecated events Namhyung Kim
@ 2025-10-20  2:12 ` Namhyung Kim
  3 siblings, 0 replies; 9+ messages in thread
From: Namhyung Kim @ 2025-10-20  2:12 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Howard Chu,
	Gautam Menghani, linux-perf-users, linux-kernel, Ian Rogers

On Thu, 16 Oct 2025 15:22:26 -0700, Ian Rogers wrote:

> Unsupported legacy events are flagged as deprecated. Don't display
> these events in ilist as they won't open and there are over 1,000
> legacy cache events.
> 
> 

Applied to perf-tools-next, thanks!

Best regards,
Namhyung


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-10-20  2:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 22:22 [PATCH v1 1/3] perf ilist: Don't display deprecated events Ian Rogers
2025-10-16 22:22 ` [PATCH v1 2/3] perf python: Add PMU argument to parse_metrics Ian Rogers
2025-10-17 14:21   ` Gautam Menghani
2025-10-16 22:22 ` [PATCH v1 3/3] perf ilist: Add PMU information to metrics Ian Rogers
2025-10-19  2:56 ` [PATCH v1 1/3] perf ilist: Don't display deprecated events Namhyung Kim
2025-10-19  6:50   ` Howard Chu
2025-10-19 23:04     ` Ian Rogers
2025-10-20  1:10       ` Namhyung Kim
2025-10-20  2:12 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).