All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: linux-arch@vger.kernel.org
Subject: Using __builtin_prefetch everywhere
Date: Sat, 6 Oct 2007 12:44:44 +0200	[thread overview]
Message-ID: <200710061244.44127.ak@suse.de> (raw)


Hallo,

Since there were some issues with the x86-64 prefetch I decided
to switch the standard prefetch over to gcc's __builtin_prefetch.
Since gcc supports this on all architectures I did that change
for everybody: if you don't define a ARCH_HAS_PREFETCH it will
use __builtin_prefetch(x) and the same with ARCH_HAS_PREFETCHW.

If you know of any problems with the __builtin_prefetch
(e.g. gcc miscompiling it) please complain now. The right fix
would be then to define a ARCH_HAS_PREFETCH{,w}

-Andi

Use __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>

Index: linux/include/asm-x86_64/processor.h
===================================================================
--- linux.orig/include/asm-x86_64/processor.h
+++ linux/include/asm-x86_64/processor.h
@@ -368,12 +368,6 @@ static inline void sync_core(void)
 	asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
 } 
 
-#define ARCH_HAS_PREFETCH
-static inline void prefetch(void *x) 
-{ 
-	asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x));
-} 
-
 #define ARCH_HAS_PREFETCHW 1
 static inline void prefetchw(void *x) 
 { 
Index: linux/include/linux/prefetch.h
===================================================================
--- linux.orig/include/linux/prefetch.h
+++ linux/include/linux/prefetch.h
@@ -34,17 +34,12 @@
 	
 */
 
-/*
- *	These cannot be do{}while(0) macros. See the mental gymnastics in
- *	the loop macro.
- */
- 
 #ifndef ARCH_HAS_PREFETCH
-static inline void prefetch(const void *x) {;}
+#define prefetch(x) __builtin_prefetch(x) 
 #endif
 
 #ifndef ARCH_HAS_PREFETCHW
-static inline void prefetchw(const void *x) {;}
+#define prefetchw(x) __builtin_prefetch(x,1)
 #endif
 
 #ifndef ARCH_HAS_SPINLOCK_PREFETCH

                 reply	other threads:[~2007-10-06 10:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200710061244.44127.ak@suse.de \
    --to=ak@suse.de \
    --cc=linux-arch@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.