[patch 4/21] fix ARCH_HAS_PREFETCH

From: Andrew Morton (akpm@zip.com.au)
Date: Sun Aug 11 2002 - 02:38:38 EST


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.

#ifdef ARCH_HAS_PREFETCH
#define prefetch_prev_lru_page(_page, _base, _field) \
        do { \
                if ((_page)->lru.prev != _base) { \
                        struct page *prev; \
                                                                        \
                        prev = list_entry(_page->lru.prev, \
                                        struct page, lru); \
                        prefetch(&prev->_field); \
                } \
        } while (0)
#else
#define prefetch_prev_lru_page(_page, _base, _field) do { } while (0)
#endif

Which needs a working ARCH_HAS_PREFETCH to avoid probable extra code
generation on CPUs which don't have prefetch.

 prefetch.h | 3 ---
 1 files changed, 3 deletions(-)

--- 2.5.31/include/linux/prefetch.h~arch_has_prefetchw Sun Aug 11 00:20:08 2002
+++ 2.5.31-akpm/include/linux/prefetch.h Sun Aug 11 00:20:08 2002
@@ -39,17 +39,14 @@
  */
  
 #ifndef ARCH_HAS_PREFETCH
-#define ARCH_HAS_PREFETCH
 static inline void prefetch(const void *x) {;}
 #endif
 
 #ifndef ARCH_HAS_PREFETCHW
-#define ARCH_HAS_PREFETCHW
 static inline void prefetchw(const void *x) {;}
 #endif
 
 #ifndef ARCH_HAS_SPINLOCK_PREFETCH
-#define ARCH_HAS_SPINLOCK_PREFETCH
 #define spin_lock_prefetch(x) prefetchw(x)
 #endif
 

.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 15 2002 - 22:00:23 EST