[LTP] [PATCH] pt_test: skip pt_disable_branch on Broadwell CPUs
Jan Stancek
jstancek@redhat.com
Mon Oct 28 14:33:26 CET 2019
commit d35869ba348d ("perf/x86/intel/pt: Allow the disabling of branch tracing")
disallows not setting BRANCH_EN due to erratum BDM106 on Broadwell CPUs.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/tracing/pt_test/pt_test.c | 31 ++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/testcases/kernel/tracing/pt_test/pt_test.c b/testcases/kernel/tracing/pt_test/pt_test.c
index 1095e800f721..f9903fdcd396 100644
--- a/testcases/kernel/tracing/pt_test/pt_test.c
+++ b/testcases/kernel/tracing/pt_test/pt_test.c
@@ -124,6 +124,32 @@ static void intel_pt_trace_check(void)
tst_res(TPASS, "perf trace test passed");
}
+static int is_affected_by_erratum_BDM106(void)
+{
+ int family = -1, model = -1;
+
+ if (FILE_LINES_SCANF("/proc/cpuinfo", "cpu family%*s%d", &family)
+ || family != 6)
+ return 0;
+
+ if (!FILE_LINES_SCANF("/proc/cpuinfo", "model%*s%d", &model)) {
+ tst_res(TINFO, "Intel FAM6 model %d", model);
+
+ switch (model) {
+ case 0x3D: /* INTEL_FAM6_BROADWELL */
+ /* fallthrough */
+ case 0x47: /* INTEL_FAM6_BROADWELL_G */
+ /* fallthrough */
+ case 0x4F: /* INTEL_FAM6_BROADWELL_X */
+ /* fallthrough */
+ case 0x56: /* INTEL_FAM6_BROADWELL_D */
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
static void setup(void)
{
struct perf_event_attr attr = {};
@@ -145,6 +171,11 @@ static void setup(void)
attr.size = sizeof(struct perf_event_attr);
attr.mmap = 1;
if (str_branch_flag) {
+ if (is_affected_by_erratum_BDM106()) {
+ tst_brk(TCONF, "erratum BDM106 disallows not "
+ "setting BRANCH_EN on this CPU");
+ }
+
tst_res(TINFO, "Intel PT will disable branch trace");
attr.config |= 1;
}
--
1.8.3.1
More information about the ltp
mailing list