Merge tag 'ntb-5.11' of git://github.com/jonmason/ntb
[linux/fpc-iii.git] / tools / perf / arch / x86 / util / auxtrace.c
blob3da506e13f49ddd002a0c6dc8dc4e6da9d61757a
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * auxtrace.c: AUX area tracing support
4 * Copyright (c) 2013-2014, Intel Corporation.
5 */
7 #include <errno.h>
8 #include <stdbool.h>
10 #include "../../../util/header.h"
11 #include "../../../util/debug.h"
12 #include "../../../util/pmu.h"
13 #include "../../../util/auxtrace.h"
14 #include "../../../util/intel-pt.h"
15 #include "../../../util/intel-bts.h"
16 #include "../../../util/evlist.h"
18 static
19 struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist,
20 int *err)
22 struct perf_pmu *intel_pt_pmu;
23 struct perf_pmu *intel_bts_pmu;
24 struct evsel *evsel;
25 bool found_pt = false;
26 bool found_bts = false;
28 intel_pt_pmu = perf_pmu__find(INTEL_PT_PMU_NAME);
29 if (intel_pt_pmu)
30 intel_pt_pmu->auxtrace = true;
31 intel_bts_pmu = perf_pmu__find(INTEL_BTS_PMU_NAME);
32 if (intel_bts_pmu)
33 intel_bts_pmu->auxtrace = true;
35 evlist__for_each_entry(evlist, evsel) {
36 if (intel_pt_pmu && evsel->core.attr.type == intel_pt_pmu->type)
37 found_pt = true;
38 if (intel_bts_pmu && evsel->core.attr.type == intel_bts_pmu->type)
39 found_bts = true;
42 if (found_pt && found_bts) {
43 pr_err("intel_pt and intel_bts may not be used together\n");
44 *err = -EINVAL;
45 return NULL;
48 if (found_pt)
49 return intel_pt_recording_init(err);
51 if (found_bts)
52 return intel_bts_recording_init(err);
54 return NULL;
57 struct auxtrace_record *auxtrace_record__init(struct evlist *evlist,
58 int *err)
60 char buffer[64];
61 int ret;
63 *err = 0;
65 ret = get_cpuid(buffer, sizeof(buffer));
66 if (ret) {
67 *err = ret;
68 return NULL;
71 if (!strncmp(buffer, "GenuineIntel,", 13))
72 return auxtrace_record__init_intel(evlist, err);
74 return NULL;