svn commit: r238910 - stable/9/sys/x86/x86

Jim Harris jimharris at FreeBSD.org
Mon Jul 30 15:30:43 UTC 2012


Author: jimharris
Date: Mon Jul 30 15:30:42 2012
New Revision: 238910
URL: http://svn.freebsd.org/changeset/base/238910

Log:
  MFC r238755:
  
  Add rmb() to tsc_read_##x to enforce serialization of rdtsc captures.
  
  Intel Architecture Manual specifies that rdtsc instruction is not serialized,
  so without this change, TSC synchronization test would periodically fail,
  resulting in use of HPET timecounter instead of TSC-low.  This caused
  severe performance degradation (40-50%) when running high IO/s workloads due to
  HPET MMIO reads and GEOM stat collection.
  
  Tests on Xeon E5-2600 (Sandy Bridge) 8C systems were seeing TSC synchronization
  fail approximately 20% of the time.
  
  Sponsored by: Intel
  Approved by: re (kib)

Modified:
  stable/9/sys/x86/x86/tsc.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/x86/x86/tsc.c
==============================================================================
--- stable/9/sys/x86/x86/tsc.c	Mon Jul 30 14:47:35 2012	(r238909)
+++ stable/9/sys/x86/x86/tsc.c	Mon Jul 30 15:30:42 2012	(r238910)
@@ -326,6 +326,7 @@ init_TSC(void)
 
 #ifdef SMP
 
+/* rmb is required here because rdtsc is not a serializing instruction. */
 #define	TSC_READ(x)			\
 static void				\
 tsc_read_##x(void *arg)			\
@@ -333,6 +334,7 @@ tsc_read_##x(void *arg)			\
 	uint32_t *tsc = arg;		\
 	u_int cpu = PCPU_GET(cpuid);	\
 					\
+	rmb();				\
 	tsc[cpu * 3 + x] = rdtsc32();	\
 }
 TSC_READ(0)


More information about the svn-src-all mailing list