diff mbox

[Xen-devel,v2,01/17] xen: x86 & generic: change to __builtin_prefetch()

Message ID 1395841133-2223-1-git-send-email-ian.campbell@citrix.com
State Accepted
Commit 630017f420f111e0c0332dbd99df30ebb8fed207
Headers show

Commit Message

Ian Campbell March 26, 2014, 1:38 p.m. UTC
Quoting Andi Kleen in Linux b483570a13be from 2007:
    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.

ARM wants to use the builtins.

Fix a pair of spelling errors, one of which was from Lucas De Marchi in the
Linux tree.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
---
 xen/include/xen/prefetch.h |   13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Ian Campbell April 2, 2014, 4:01 p.m. UTC | #1
Keir,

On Wed, 2014-03-26 at 13:38 +0000, Ian Campbell wrote:
> Quoting Andi Kleen in Linux b483570a13be from 2007:
>     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.
> 
> ARM wants to use the builtins.
> 
> Fix a pair of spelling errors, one of which was from Lucas De Marchi in the
> Linux tree.
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> Cc: Keir Fraser <keir@xen.org>

Are you OK with this one?

Thanks,
Ian.

> ---
>  xen/include/xen/prefetch.h |   13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/xen/include/xen/prefetch.h b/xen/include/xen/prefetch.h
> index 8d7d3ff..ba73998 100644
> --- a/xen/include/xen/prefetch.h
> +++ b/xen/include/xen/prefetch.h
> @@ -28,24 +28,17 @@
>  	prefetchw(x)	- prefetches the cacheline at "x" for write
>  	spin_lock_prefetch(x) - prefectches the spinlock *x for taking
>  	
> -	there is also PREFETCH_STRIDE which is the architecure-prefered 
> +	there is also PREFETCH_STRIDE which is the architecture-preferred
>  	"lookahead" size for prefetching streamed operations.
>  	
>  */
>  
> -/*
> - *	These cannot be do{}while(0) macros. See the mental gymnastics in
> - *	the loop macro.
> - */
> - 
>  #ifndef ARCH_HAS_PREFETCH
> -#define ARCH_HAS_PREFETCH
> -static inline void prefetch(const void *x) {;}
> +#define prefetch(x) __builtin_prefetch(x)
>  #endif
>  
>  #ifndef ARCH_HAS_PREFETCHW
> -#define ARCH_HAS_PREFETCHW
> -static inline void prefetchw(const void *x) {;}
> +#define prefetchw(x) __builtin_prefetch(x,1)
>  #endif
>  
>  #ifndef ARCH_HAS_SPINLOCK_PREFETCH
diff mbox

Patch

diff --git a/xen/include/xen/prefetch.h b/xen/include/xen/prefetch.h
index 8d7d3ff..ba73998 100644
--- a/xen/include/xen/prefetch.h
+++ b/xen/include/xen/prefetch.h
@@ -28,24 +28,17 @@ 
 	prefetchw(x)	- prefetches the cacheline at "x" for write
 	spin_lock_prefetch(x) - prefectches the spinlock *x for taking
 	
-	there is also PREFETCH_STRIDE which is the architecure-prefered 
+	there is also PREFETCH_STRIDE which is the architecture-preferred
 	"lookahead" size for prefetching streamed operations.
 	
 */
 
-/*
- *	These cannot be do{}while(0) macros. See the mental gymnastics in
- *	the loop macro.
- */
- 
 #ifndef ARCH_HAS_PREFETCH
-#define ARCH_HAS_PREFETCH
-static inline void prefetch(const void *x) {;}
+#define prefetch(x) __builtin_prefetch(x)
 #endif
 
 #ifndef ARCH_HAS_PREFETCHW
-#define ARCH_HAS_PREFETCHW
-static inline void prefetchw(const void *x) {;}
+#define prefetchw(x) __builtin_prefetch(x,1)
 #endif
 
 #ifndef ARCH_HAS_SPINLOCK_PREFETCH