Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64

From: John Garry
Date: Mon Mar 08 2021 - 11:37:36 EST


On 06/03/2021 19:34, Jiri Olsa wrote:
On Fri, Mar 05, 2021 at 11:06:58AM +0000, John Garry wrote:
Hi Jirka,

- struct pmu_events_map *map = perf_pmu__find_map(NULL);
+ struct pmu_events_map *map = find_cpumap();
so this is just for arm at the moment right?

Yes - but to be more accurate, arm64.

At the moment, from the archs which use pmu-events, only arm64 and nds32
have versions of get_cpuid_str() which require a non-NULL pmu argument.

But then apparently nds32 only supports a single CPU, so this issue of
heterogeneous CPUs should not be a concern there:)

could we rather make this arch specific code, so we don't need
to do the scanning on archs where this is not needed?

like marking perf_pmu__find_map as __weak and add arm specific
version?
Well I was thinking that this code should not be in metricgroup.c anyway.

So there is code which is common in current perf_pmu__find_map() for all
archs.

I could factor that out into a common function, below. Just a bit worried
about perf_pmu__find_map() and perf_pmu__find_pmu_map() being confused.
right, so perf_pmu__find_map does not take perf_pmu as argument
anymore, so the prefix does not fit, how about pmu_events_map__find ?

I think it could be ok.

But now I am slightly concerned that we don't put anything like this in arch/arm64, based on this earlier discussion on close topic:

https://lore.kernel.org/lkml/20190719075450.xcm4i4a5sfaxlfap@willie-the-truck/

Hi Will, Mark,

Do you have any objection to add arm64 specific code here?

So what I had originally in this patch was to iterate PMUs in common code and find the CPU PMU and use that to match CPU metrics, as long as it's not a heterogeneous system.

Now the suggestion was to move that into arch specific code, as it's not needed for all archs.

Thanks,
John