xref: /linux/tools/perf/arch/x86/util/pmu.c (revision 3d0fe49454652117522f60bfbefb978ba0e5300b)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <string.h>
3 #include <stdio.h>
4 #include <sys/types.h>
5 #include <dirent.h>
6 #include <fcntl.h>
7 #include <linux/stddef.h>
8 #include <linux/perf_event.h>
9 #include <linux/zalloc.h>
10 #include <api/fs/fs.h>
11 #include <errno.h>
12 
13 #include "../../../util/intel-pt.h"
14 #include "../../../util/intel-bts.h"
15 #include "../../../util/pmu.h"
16 #include "../../../util/fncache.h"
17 #include "../../../util/pmus.h"
18 #include "env.h"
19 
20 void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
21 {
22 #ifdef HAVE_AUXTRACE_SUPPORT
23 	if (!strcmp(pmu->name, INTEL_PT_PMU_NAME)) {
24 		pmu->auxtrace = true;
25 		pmu->selectable = true;
26 		pmu->perf_event_attr_init_default = intel_pt_pmu_default_config;
27 	}
28 	if (!strcmp(pmu->name, INTEL_BTS_PMU_NAME)) {
29 		pmu->auxtrace = true;
30 		pmu->selectable = true;
31 	}
32 #endif
33 }
34 
35 int perf_pmus__num_mem_pmus(void)
36 {
37 	/* AMD uses IBS OP pmu and not a core PMU for perf mem/c2c */
38 	if (x86__is_amd_cpu())
39 		return 1;
40 
41 	/* Intel uses core pmus for perf mem/c2c */
42 	return perf_pmus__num_core_pmus();
43 }
44