kernel - cpu_pause() needs to be memory-modifying
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 23 Feb 2013 05:44:55 +0000 (21:44 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 23 Feb 2013 05:44:55 +0000 (21:44 -0800)
* __asm __volatile isn't enough, it also needs the "memory"
  attribute to prevent gcc from optimizing out memory loads around
  loops using cpu_pause().

sys/cpu/i386/include/cpufunc.h
sys/cpu/x86_64/include/cpufunc.h

index 309d6ca..ee321ab 100644 (file)
@@ -75,7 +75,7 @@ breakpoint(void)
 static __inline void
 cpu_pause(void)
 {
-       __asm __volatile("pause");
+       __asm __volatile("pause":::"memory");
 }
 
 /*
index cd79b0d..8d04a76 100644 (file)
@@ -76,7 +76,7 @@ breakpoint(void)
 static __inline void
 cpu_pause(void)
 {
-       __asm __volatile("pause");
+       __asm __volatile("pause":::"memory");
 }
 
 static __inline u_int