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

perf header: Additional note on AMD IBS for max_precise pmu cap

x86 core PMU exposes supported maximum precision level via max_precise
PMU capability. Although, AMD core PMU does not support precise mode,
certain core PMU events with precise_ip > 0 are allowed and forwarded to
IBS OP PMU.

Display a note about this in the 'perf report' header output and
document the details in the perf-list man page.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Changbin Du <changbin.du@huawei.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ming Wang <wangming01@loongson.cn>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ross Zwisler <zwisler@chromium.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Link: https://lore.kernel.org/r/20231107083331.901-2-ravi.bangoria@amd.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Arnaldo Carvalho de Melo and committed by
Arnaldo Carvalho de Melo
dd678532 a399ee67

+35 -5
+7 -5
tools/perf/Documentation/perf-list.txt
··· 81 81 which supports up to precise-level 2, and precise level 3 for 82 82 some special cases 83 83 84 - On AMD systems it is implemented using IBS (up to precise-level 2). 85 - The precise modifier works with event types 0x76 (cpu-cycles, CPU 86 - clocks not halted) and 0xC1 (micro-ops retired). Both events map to 87 - IBS execution sampling (IBS op) with the IBS Op Counter Control bit 88 - (IbsOpCntCtl) set respectively (see the 84 + On AMD systems it is implemented using IBS OP (up to precise-level 2). 85 + Unlike Intel PEBS which provides levels of precision, AMD core pmu is 86 + inherently non-precise and IBS is inherently precise. (i.e. ibs_op//, 87 + ibs_op//p, ibs_op//pp and ibs_op//ppp are all same). The precise modifier 88 + works with event types 0x76 (cpu-cycles, CPU clocks not halted) and 0xC1 89 + (micro-ops retired). Both events map to IBS execution sampling (IBS op) 90 + with the IBS Op Counter Control bit (IbsOpCntCtl) set respectively (see the 89 91 Core Complex (CCX) -> Processor x86 Core -> Instruction Based Sampling (IBS) 90 92 section of the [AMD Processor Programming Reference (PPR)] relevant to the 91 93 family, model and stepping of the processor being used).
+18
tools/perf/util/env.c
··· 531 531 return cpu.cpu >= 0 && cpu.cpu < env->nr_numa_map ? env->numa_map[cpu.cpu] : -1; 532 532 } 533 533 534 + bool perf_env__has_pmu_mapping(struct perf_env *env, const char *pmu_name) 535 + { 536 + char *pmu_mapping = env->pmu_mappings, *colon; 537 + 538 + for (int i = 0; i < env->nr_pmu_mappings; ++i) { 539 + if (strtoul(pmu_mapping, &colon, 0) == ULONG_MAX || *colon != ':') 540 + goto out_error; 541 + 542 + pmu_mapping = colon + 1; 543 + if (strcmp(pmu_mapping, pmu_name) == 0) 544 + return true; 545 + 546 + pmu_mapping += strlen(pmu_mapping) + 1; 547 + } 548 + out_error: 549 + return false; 550 + } 551 + 534 552 char *perf_env__find_pmu_cap(struct perf_env *env, const char *pmu_name, 535 553 const char *cap) 536 554 {
+2
tools/perf/util/env.h
··· 179 179 int perf_env__numa_node(struct perf_env *env, struct perf_cpu cpu); 180 180 char *perf_env__find_pmu_cap(struct perf_env *env, const char *pmu_name, 181 181 const char *cap); 182 + 183 + bool perf_env__has_pmu_mapping(struct perf_env *env, const char *pmu_name); 182 184 #endif /* __PERF_ENV_H */
+8
tools/perf/util/header.c
··· 2145 2145 __print_pmu_caps(fp, pmu_caps->nr_caps, pmu_caps->caps, 2146 2146 pmu_caps->pmu_name); 2147 2147 } 2148 + 2149 + if (strcmp(perf_env__arch(&ff->ph->env), "x86") == 0 && 2150 + perf_env__has_pmu_mapping(&ff->ph->env, "ibs_op")) { 2151 + char *max_precise = perf_env__find_pmu_cap(&ff->ph->env, "cpu", "max_precise"); 2152 + 2153 + if (max_precise != NULL && atoi(max_precise) == 0) 2154 + fprintf(fp, "# AMD systems uses ibs_op// PMU for some precise events, e.g.: cycles:p, see the 'perf list' man page for further details.\n"); 2155 + } 2148 2156 } 2149 2157 2150 2158 static void print_pmu_mappings(struct feat_fd *ff, FILE *fp)