[PATCH] x86_64 prefetchw() function can take into account CONFIG_MK8/ CONFIG_MPSC

From: Eric Dumazet
Date: Thu Jun 23 2005 - 04:58:57 EST


If we build a x86_64 kernel for an AMD64 or for an Intel EMT64, no need to use alternative_input.
Reserve alternative_input only for a generic kernel.

Thank you

Eric Dumazet

Signed-off-by: Eric Dumazet <dada1@xxxxxxxxxxxxx>

diff -Nru linux-2.6.12/include/asm-x86_64/processor.h linux-2.6.12-orig/include/asm-x86_64/processor.h
--- linux-2.6.12-orig/include/asm-x86_64/processor.h 2005-06-17 21:48:29.000000000 +0200
+++ linux-2.6.12/include/asm-x86_64/processor.h 2005-06-23 11:20:08.000000000 +0200
@@ -389,10 +389,21 @@
#define ARCH_HAS_PREFETCHW 1
static inline void prefetchw(void *x)
{
+#if defined(CONFIG_MK8)
+ /* AMD64 / MK8 has 3DNOW, we can emit a true prefetchw, using a "m" in the asm input */
+ asm volatile("prefetchw %0" :: "m" (*(unsigned long *)x));
+#elif defined(CONFIG_MPSC)
+ /* Intel EMT64 does not have 3DNOW, no prefetchw instruction */
+#else
+ /* If we build a generic X86_64 kernel,
+ * we must use alternative_input() and a "r" asm constraint to make sure
+ * the size of the instruction will be <= 5
+ */
alternative_input(ASM_NOP5,
"prefetchw (%1)",
X86_FEATURE_3DNOW,
"r" (x));
+#endif
}

#define ARCH_HAS_SPINLOCK_PREFETCH 1