OpenCloudOS-Kernel/tools/perf/arch/x86/util
Kan Liang 13d60ba073 perf pmu: Add PMU alias support
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,
   4044879584,,uncore_cha_2/event=1/,2528059205,100.00,,

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

Committer notes:

Rename 'struct perf_pmu_alias_name' to 'pmu_alias', the 'perf_' prefix
should be used for libperf, things inside just tools/perf/ are being
moved away from that prefix.

Also 'pmu_alias' is shorter and reflects the abstraction.

Also don't use 'pmu' as the name for variables for that type, we should
use that for the 'struct perf_pmu' variables, avoiding confusion. Use
'pmu_alias' for 'struct pmu_alias' variables.

Co-developed-by: Jin Yao <yao.jin@linux.intel.com>
Co-developed-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Link: http://lore.kernel.org/lkml/20210902065955.1299-2-yao.jin@linux.intel.com
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-09-03 08:33:26 -03:00
..
Build perf stat: Enable iostat mode for x86 platforms 2021-04-20 08:40:20 -03:00
archinsn.c tools/perf: Convert to insn_decode() 2021-03-15 12:41:26 +01:00
auxtrace.c tools: Fix off-by 1 relative directory includes 2020-03-06 08:36:46 -03:00
dwarf-regs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
event.c perf tools: Support arch specific PERF_SAMPLE_WEIGHT_STRUCT processing 2021-02-18 16:07:06 -03:00
evlist.c perf stat: Add Topdown metrics L2 events as default events 2021-07-09 14:04:32 -03:00
evsel.c perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT 2021-02-08 16:25:00 -03:00
header.c tools: Fix off-by 1 relative directory includes 2020-03-06 08:36:46 -03:00
intel-bts.c perf evlist: Use the right prefix for 'struct evlist' evsel list methods 2020-11-30 14:52:44 -03:00
intel-pt.c perf intel-pt: Use aux_watermark 2021-04-16 16:32:39 +02:00
iostat.c libperf: Move 'idx' from tools/perf to perf_evsel::idx 2021-07-09 14:04:28 -03:00
kvm-stat.c perf x86 kvm-stat: Support to analyze kvm MSR 2021-05-12 12:43:12 -03:00
machine.c tools: Fix off-by 1 relative directory includes 2020-03-06 08:36:46 -03:00
mem-events.c perf tools: Support pmu prefix for mem-store event 2021-06-01 11:04:05 -03:00
perf_regs.c perf tools: Fix various typos in comments 2021-03-23 17:13:43 -03:00
pmu.c perf pmu: Add PMU alias support 2021-09-03 08:33:26 -03:00
topdown.c perf record: Support sample-read topdown metric group 2020-09-17 15:47:58 -03:00
tsc.c perf tsc: Move out common functions from x86 2020-09-22 13:38:33 -03:00
unwind-libdw.c perf libdw: Fix off-by 1 relative directory includes 2020-06-01 12:24:23 -03:00
unwind-libunwind.c perf unwind: Fix libunwind build failure on i386 systems 2019-09-26 21:59:38 +02:00