Re: [PATCH v6 2/4] perf jevents: Add python converter script

From: John Garry
Date: Wed Jun 29 2022 - 12:56:47 EST


On 27/06/2022 03:57, Ian Rogers wrote:
+
+ def unit_to_pmu(unit: str) -> str:
+ """Convert a JSON Unit to Linux PMU name."""
+ if not unit:
+ return None
+ # Comment brought over from jevents.c:
+ # it's not realistic to keep adding these, we need something more scalable ...

Since we're converting to python it might be a good idea to consider this - ever have an ideas on something better?

Thanks,
John

+ table = {
+ 'CBO': 'uncore_cbox',
+ 'QPI LL': 'uncore_qpi',
+ 'SBO': 'uncore_sbox',
+ 'iMPH-U': 'uncore_arb',
+ 'CPU-M-CF': 'cpum_cf',
+ 'CPU-M-SF': 'cpum_sf',
+ 'UPI LL': 'uncore_upi',
+ 'hisi_sicl,cpa': 'hisi_sicl,cpa',
+ 'hisi_sccl,ddrc': 'hisi_sccl,ddrc',
+ 'hisi_sccl,hha': 'hisi_sccl,hha',
+ 'hisi_sccl,l3c': 'hisi_sccl,l3c',
+ 'imx8_ddr': 'imx8_ddr',
+ 'L3PMC': 'amd_l3',
+ 'DFPMC': 'amd_df',
+ 'cpu_core': 'cpu_core',
+ 'cpu_atom': 'cpu_atom',
+ }
+ return table[unit] if unit in table else f'uncore_{unit.lower()}'
+