Skip to contentSkip to conversation

x86, perf, bts: disable BTS from Nehalem to Ivy Bridge

PATCH In review [email protected] 2 participants 3 messages Dec 7, 2012 – Jan 24, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, perf, bts: disable BTS from Nehalem to Ivy Bridge

From: Markus Metzger <[email protected]>

Starting with Nehalem, the BTS "from" information may in some cases be incorrect (AAJ122).

This has been detected while adding branch tracing support to gdb, where it results in sporadic test fails.

Disable BTS support on Nehalem, Westmere, Sandy Bridge, and Ivy Bridge.

CC Mark Kettenis <[email protected]>
CC Pedro Alves <[email protected]>
CC Jan Kratochvil <[email protected]>
---
 arch/x86/kernel/cpu/perf_event_intel.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/perf_event_intel.c +14 -0
index 6bca492..e72aac9 100644
@@ -1893,6 +1893,16 @@ static __init void intel_nehalem_quirk(void)
 	}
 }
 
+static __init void intel_disable_bts(void)
+{
+	/*
+	 * Erratum AAJ122: LBR, BTM, or BTS records may have incorrect branch
+	 * "from" information afer an EIST transition, T-states, C1E, or
+	 * Adaptive Thermal Throttling.
+	 */
+	x86_pmu.bts = 0;
+}
+
 __init int intel_pmu_init(void)
 {
 	union cpuid10_edx edx;
@@ -2003,6 +2013,7 @@ __init int intel_pmu_init(void)
 			X86_CONFIG(.event=0xb1, .umask=0x3f, .inv=1, .cmask=1);
 
 		x86_add_quirk(intel_nehalem_quirk);
+		intel_disable_bts();
 
 		pr_cont("Nehalem events, ");
 		break;
@@ -2042,6 +2053,7 @@ __init int intel_pmu_init(void)
 		intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =
 			X86_CONFIG(.event=0xb1, .umask=0x3f, .inv=1, .cmask=1);
 
+		intel_disable_bts();
 		pr_cont("Westmere events, ");
 		break;
 
@@ -2070,6 +2082,7 @@ __init int intel_pmu_init(void)
 		intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =
 			X86_CONFIG(.event=0xb1, .umask=0x01, .inv=1, .cmask=1);
 
+		intel_disable_bts();
 		pr_cont("SandyBridge events, ");
 		break;
 	case 58: /* IvyBridge */
@@ -2092,6 +2105,7 @@ __init int intel_pmu_init(void)
 		intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =
 			X86_CONFIG(.event=0x0e, .umask=0x01, .inv=1, .cmask=1);
 
+		intel_disable_bts();
 		pr_cont("IvyBridge events, ");
 		break;
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 9 lines · * [email protected] <[email protected]> wrote:

From: Markus Metzger <[email protected]>

Starting with Nehalem, the BTS "from" information may in some cases be incorrect (AAJ122).

This has been detected while adding branch tracing support to gdb, where it results in sporadic test fails.

Disable BTS support on Nehalem, Westmere, Sandy Bridge, and Ivy Bridge.

But the failures are rare, so the BTS data is still correct statistically, by and large, right? So why not just keep it as-is and teach tooling to be more robust about implausible trace entries? It has to be ready for that eventuality *anyway*.

Thanks,

Ingo

#2 lore raw
Quoted 11 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ingo Molnar
Sent: Thursday, January 24, 2013 4:47 PM

Quoted 6 lines

Starting with Nehalem, the BTS "from" information may in some cases be incorrect (AAJ122).

This has been detected while adding branch tracing support to gdb, where it results in sporadic test fails.

Quoted 6 lines
Quoted 1 line

Disable BTS support on Nehalem, Westmere, Sandy Bridge, and Ivy Bridge.

But the failures are rare, so the BTS data is still correct statistically, by and large, right? So why not just keep it as-is and teach tooling to be more robust about implausible trace entries? It has to be ready for that eventuality *anyway*.

Yes, the fails are rare. They are frequent enough, however, to cause sporadic test fails.

The problem is that you can't reliably detect such fails. In the worst case, GDB would show wrong but plausible trace. Typically, GDB just shows garbage (i.e. impossible trace) in such cases.

I'm afraid one might endlessly debate whether the feature as-is is useful or not. It is working fine on Atom so I chose to disable it on core.

The GDB folks would rather not disable the feature inside GDB; they prefer that it is disabled in the kernel. There will be an additional check inside GDB to support older kernel versions.

Regards,
markus.
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052