Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf regs x86: Fix arch__intr_reg_mask() for the hybrid platform

The X86 specific arch__intr_reg_mask() is to check whether the kernel
and hardware can collect XMM registers. But it doesn't work on some
hybrid platform.

Without the patch on ADL-N:

$ perf record -I?
available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10
R11 R12 R13 R14 R15

The config of the test event doesn't contain the PMU information. The
kernel may fail to initialize it on the correct hybrid PMU and return
the wrong non-supported information.

Add the PMU information into the config for the hybrid platform. The
same register set is supported among different hybrid PMUs. Checking
the first available one is good enough.

With the patch on ADL-N:

$ perf record -I?
available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10
R11 R12 R13 R14 R15 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 XMM9
XMM10 XMM11 XMM12 XMM13 XMM14 XMM15

Fixes: 6466ec14aaf44ff1 ("perf regs x86: Add X86 specific arch__intr_reg_mask()")
Reported-by: Ammy Yi <ammy.yi@intel.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20220518145125.1494156-1-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Kan Liang and committed by
Arnaldo Carvalho de Melo
01b28e4a 451ed805

+12
+12
tools/perf/arch/x86/util/perf_regs.c
··· 9 9 #include "../../../util/perf_regs.h" 10 10 #include "../../../util/debug.h" 11 11 #include "../../../util/event.h" 12 + #include "../../../util/pmu.h" 13 + #include "../../../util/pmu-hybrid.h" 12 14 13 15 const struct sample_reg sample_reg_masks[] = { 14 16 SMPL_REG(AX, PERF_REG_X86_AX), ··· 286 284 .disabled = 1, 287 285 .exclude_kernel = 1, 288 286 }; 287 + struct perf_pmu *pmu; 289 288 int fd; 290 289 /* 291 290 * In an unnamed union, init it here to build on older gcc versions 292 291 */ 293 292 attr.sample_period = 1; 293 + 294 + if (perf_pmu__has_hybrid()) { 295 + /* 296 + * The same register set is supported among different hybrid PMUs. 297 + * Only check the first available one. 298 + */ 299 + pmu = list_first_entry(&perf_pmu__hybrid_pmus, typeof(*pmu), hybrid_list); 300 + attr.config |= (__u64)pmu->type << PERF_PMU_TYPE_SHIFT; 301 + } 294 302 295 303 event_attr_init(&attr); 296 304