Re: [PATCH v1] perf pmu: Add PMU alias support

From: Jin, Yao
Date: Fri Jul 23 2021 - 02:56:22 EST

Hi John,

On 7/22/2021 6:28 PM, John Garry wrote:
On 22/07/2021 02:45, Jin Yao wrote:
From: Kan Liang<kan.liang@xxxxxxxxxxxxxxx>

A perf uncore PMU may have two PMU names, a real name and an alias. The
alias is exported at /sys/bus/event_source/devices/uncore_*/alias.
The perf tool should support the alias as well.

Add alias_name in the struct perf_pmu to store the alias. For the PMU
which doesn't have an alias. It's NULL.

Introduce two X86 specific functions to retrieve the real name and the
alias separately.

Only go through the sysfs to retrieve the mapping between the real name
and the alias once. The result is cached in a list, uncore_pmu_list.

Nothing changed for the other ARCHs.

With the patch, the perf tool can monitor the PMU with either the real
name or the alias.

Use the real name,
  $ perf stat -e uncore_cha_2/event=1/ -x,

Use the alias,
  $ perf stat -e uncore_type_0_2/event=1/ -x,

Having a self-test case would be nice. And it's questionable why this goes in x86 code.

OK, I will add test cases for uncore PMU alias.

For why it's now only x86 specific code, my understanding is, currently x86 has this usage case, we can further extend it to other ARCHs and make it a generic way in future.

Jin Yao