Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86 & generic: change to __builtin_prefetch()

gcc 3.2+ supports __builtin_prefetch, so it's possible to use it on all
architectures. Change the generic fallback in linux/prefetch.h to use it
instead of noping it out. gcc should do the right thing when the
architecture doesn't support prefetching

Undefine the x86-64 inline assembler version and use the fallback.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Andi Kleen and committed by
Thomas Gleixner
ab483570 124d395f

+2 -13
-6
include/asm-x86/processor_64.h
··· 390 390 asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory"); 391 391 } 392 392 393 - #define ARCH_HAS_PREFETCH 394 - static inline void prefetch(void *x) 395 - { 396 - asm volatile("prefetcht0 (%0)" :: "r" (x)); 397 - } 398 - 399 393 #define ARCH_HAS_PREFETCHW 1 400 394 static inline void prefetchw(void *x) 401 395 {
+2 -7
include/linux/prefetch.h
··· 34 34 35 35 */ 36 36 37 - /* 38 - * These cannot be do{}while(0) macros. See the mental gymnastics in 39 - * the loop macro. 40 - */ 41 - 42 37 #ifndef ARCH_HAS_PREFETCH 43 - static inline void prefetch(const void *x) {;} 38 + #define prefetch(x) __builtin_prefetch(x) 44 39 #endif 45 40 46 41 #ifndef ARCH_HAS_PREFETCHW 47 - static inline void prefetchw(const void *x) {;} 42 + #define prefetchw(x) __builtin_prefetch(x,1) 48 43 #endif 49 44 50 45 #ifndef ARCH_HAS_SPINLOCK_PREFETCH