Commit 8e4f2fd3 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix ARCH_HAS_PREFETCH

include/linux/prefetch.h does a strange thing: if the arch doesn't have
the prefectch functions, this header defines no-op version of them and
then defines ARCH_HAS_PREFETCH.  So there's no way for mainline code to
know if the architecture *really* has prefetch instructions.

This information loss is unfortunate.  Examples:

	for (i = 0; i < N; i++)
		prefetch(foo[i]);

   Problem is, if `prefetch' is a no-op, the compiler will still
   generate an empty busy-wait loop.  Which it must do.  We need to
   know the truth about ARCH_HAS_PREFETCH to correctly elide that loop.
parent 456f17cd
...@@ -39,17 +39,14 @@ ...@@ -39,17 +39,14 @@
*/ */
#ifndef ARCH_HAS_PREFETCH #ifndef ARCH_HAS_PREFETCH
#define ARCH_HAS_PREFETCH
static inline void prefetch(const void *x) {;} static inline void prefetch(const void *x) {;}
#endif #endif
#ifndef ARCH_HAS_PREFETCHW #ifndef ARCH_HAS_PREFETCHW
#define ARCH_HAS_PREFETCHW
static inline void prefetchw(const void *x) {;} static inline void prefetchw(const void *x) {;}
#endif #endif
#ifndef ARCH_HAS_SPINLOCK_PREFETCH #ifndef ARCH_HAS_SPINLOCK_PREFETCH
#define ARCH_HAS_SPINLOCK_PREFETCH
#define spin_lock_prefetch(x) prefetchw(x) #define spin_lock_prefetch(x) prefetchw(x)
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment