Skip to contentSkip to conversation

pt_test: skip pt_disable_branch on Broadwell CPUs

PATCH New Jan Stancek 2 participants 3 messages Oct 28, 2019 – Nov 4, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pt_test: skip pt_disable_branch on Broadwell CPUs

commit d35869ba348d ("perf/x86/intel/pt: Allow the disabling of branch tracing") disallows not setting BRANCH_EN due to erratum BDM106 on Broadwell CPUs.

---
 testcases/kernel/tracing/pt_test/pt_test.c | 31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
testcases/kernel/tracing/pt_test/pt_test.c +31 -0
index 1095e800f721..f9903fdcd396 100644
@@ -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;
 	}
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 pt_test: skip pt_disable_branch on Broadwell CPUs

Hi Jan,

Quoted 4 lines

commit d35869ba348d ("perf/x86/intel/pt: Allow the disabling of branch tracing") disallows not setting BRANCH_EN due to erratum BDM106 on Broadwell CPUs.

...

testcases/kernel/tracing/pt_test/pt_test.c static void setup(void) · line 176

Quoted 7 lines
testcases/kernel/tracing/pt_test/pt_test.c +3 -0
@@ -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");

I'd join string (to be on single line), even it's longer than 80. (better for grep)

Kind regards,
Petr

#2 lore raw

PATCH 1/1 pt_test: skip pt_disable_branch on Broadwell CPUs

----- Original Message -----

Quoted 8 lines

Hi Jan,

Quoted 5 lines

commit d35869ba348d ("perf/x86/intel/pt: Allow the disabling of branch tracing")
disallows not setting BRANCH_EN due to erratum BDM106 on Broadwell CPUs.

Pushed.

Quoted 15 lines

...

testcases/kernel/tracing/pt_test/pt_test.c static void setup(void) · line 176

Quoted 7 lines
testcases/kernel/tracing/pt_test/pt_test.c +3 -0
@@ -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");

I'd join string (to be on single line), even it's longer than 80. (better for grep)

Kind regards,
Petr