From 6e70fddec0e1d4a43ffb450f555dde82ff313397 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 17 Feb 2015 14:25:49 +0300 Subject: runtime: fix cputicks on x86 See the following issue for context: https://github.com/golang/go/issues/9729#issuecomment-74648287 In short, RDTSC can produce skewed results without preceding LFENCE/MFENCE. Information on this matter is very scrappy in the internet. But this is what linux kernel does (see rdtsc_barrier). It also fixes the test program on my machine. Update #9729 Change-Id: I3c1ffbf129fdfdd388bd5b7911b392b319248e68 Reviewed-on: https://go-review.googlesource.com/5033 Reviewed-by: Ian Lance Taylor --- src/runtime/runtime2.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/runtime/runtime2.go') diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index ca3e7d564e..ea2d55dbb6 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -562,12 +562,16 @@ var ( goos *int8 ncpu int32 iscgo bool - cpuid_ecx uint32 - cpuid_edx uint32 signote note forcegc forcegcstate sched schedt newprocs int32 + + // Information about what cpu features are available. + // Set on startup in asm_{x86,amd64}.s. + cpuid_ecx uint32 + cpuid_edx uint32 + lfenceBeforeRdtsc bool ) /* -- cgit v1.3-5-g9baa