perf jevents: Allow duplicate metrics with different PMUs
Ian Rogers
reviewerPATCH 1/1 perf jevents: Allow duplicate metrics with different PMUs
On hybrid machines the same metric may appear for cpu_atom and cpu_core as well as being referenced from other metrics. The same named metrics are required but on differing PMUs are required. Update the jevents.py to handle this.
On (hybrid) Alderlake before:
```
$ perf stat -M tma_fp_divider -a sleep 1
event syntax error: '.._ACTIVE!3/,tma_core_bound/metric-id=tma_core_bound/,tma_backend_bound/metric-id=tma_..'
\___ Bad event or PMU
```After:
```
$ perf stat -M tma_fp_divider -a sleep 1
Performance counter stats for 'system wide':
1,257,833,472 cpu_core/TOPDOWN.SLOTS/ # 0.0 % tma_fp_divider
45,870 cpu_core/ARITH.FPDIV_ACTIVE/
187,096,541 cpu_core/topdown-retiring/
199,533,380 cpu_core/topdown-mem-bound/
107,164,806 cpu_core/topdown-bad-spec/
214,281,782 cpu_core/CPU_CLK_UNHALTED.THREAD/
1,588,539 cpu_core/ARITH.DIV_ACTIVE/
538,842,818 cpu_core/topdown-fe-bound/
431,005,264 cpu_core/topdown-be-bound/
```--- tools/perf/pmu-events/jevents.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/pmu-events/jevents.py +2 -1
@@ -481,7 +481,8 @@ def add_events_table_entries(item: os.DirEntry, topic: str) -> None: for e in read_json_events(item.path, topic): if e.name: _pending_events.append(e) - if e.metric_name and not any(e.metric_name == x.metric_name for x in _pending_metrics): + if e.metric_name and not any(e.metric_name == x.metric_name and + e.pmu == x.pmu for x in _pending_metrics): _pending_metrics.append(e)
Signature · 1 line
2.49.0.504.g3bcea36a83-goog
Ian Rogers
reviewerQuoted 40 lines · Ian Rogers
On hybrid machines the same metric may appear for
cpu_atomandcpu_coreas well as being referenced from other metrics. The same named metrics are required but on differing PMUs are required. Update thejevents.pyto handle this.On (hybrid) Alderlake before:
``` $ perf stat -M tma_fp_divider -a sleep 1 event syntax error: '.._ACTIVE!3/,tma_core_bound/metric-id=tma_core_bound/,tma_backend_bound/metric-id=tma_..' \___ Bad event or PMU ```After:
``` $ perf stat -M tma_fp_divider -a sleep 1 Performance counter stats for 'system wide': 1,257,833,472 cpu_core/TOPDOWN.SLOTS/ # 0.0 % tma_fp_divider 45,870 cpu_core/ARITH.FPDIV_ACTIVE/ 187,096,541 cpu_core/topdown-retiring/ 199,533,380 cpu_core/topdown-mem-bound/ 107,164,806 cpu_core/topdown-bad-spec/ 214,281,782 cpu_core/CPU_CLK_UNHALTED.THREAD/ 1,588,539 cpu_core/ARITH.DIV_ACTIVE/ 538,842,818 cpu_core/topdown-fe-bound/ 431,005,264 cpu_core/topdown-be-bound/ ```Signed-off-by Ian Rogers <[email protected]>--- tools/perf/pmu-events/jevents.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/perf/pmu-events/jevents.py +0
-0
tools/perf/pmu-events/jevents.py def add_events_table_entries(item: os.DirEntry, topic: str) -> None: · line 485
Quoted 6 lines
tools/perf/pmu-events/jevents.py +2
-1@@ -481,7 +481,8 @@ def add_events_table_entries(item: os.DirEntry, topic: str) -> None: for e in read_json_events(item.path, topic): if e.name: _pending_events.append(e) - if e.metric_name and not any(e.metric_name == x.metric_name for x in _pending_metrics): + if e.metric_name and not any(e.metric_name == x.metric_name and + e.pmu == x.pmu for x in _pending_metrics):
This was triggered by this patch carried in Google's tree but not yet merged into perf-tools-next:
https://lore.kernel.org/lkml/[email protected]/
So please ignore.
Thanks,
Ian
Quoted 6 lines
tools/perf/pmu-events/jevents.py +0
-1_pending_metrics.append(e) --2.49.0.504.g3bcea36a83-goog