public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 4/21] fix ARCH_HAS_PREFETCH
@ 2002-08-11  7:38 Andrew Morton
  2002-08-11 19:49 ` Alan Cox
  0 siblings, 1 reply; 27+ messages in thread
From: Andrew Morton @ 2002-08-11  7:38 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml



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
 

.

^ permalink raw reply	[flat|nested] 27+ messages in thread
[parent not found: <3D56147E.15E7A98@zip.com.au.suse.lists.linux.kernel>]

end of thread, other threads:[~2002-08-15  6:51 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-11  7:38 [patch 4/21] fix ARCH_HAS_PREFETCH Andrew Morton
2002-08-11 19:49 ` Alan Cox
2002-08-11 18:47   ` Andrew Morton
2002-08-11 18:46     ` Larry McVoy
2002-08-11 19:06     ` Linus Torvalds
2002-08-11 20:07       ` GCC still keeps empty loops? (was: [patch 4/21] fix ARCH_HAS_PREFETCH) Jamie Lokier
2002-08-12  7:45         ` Ralf Baechle
2002-08-13 21:42     ` [patch 4/21] fix ARCH_HAS_PREFETCH Adrian Bunk
2002-08-13 22:12       ` H. Peter Anvin
2002-08-13 22:22         ` Adrian Bunk
2002-08-13 22:42           ` H. Peter Anvin
2002-08-14 17:40         ` Rogier Wolff
2002-08-14 19:41           ` H. Peter Anvin
2002-08-14 19:57             ` Jamie Lokier
2002-08-14 22:03               ` Daniel Jacobowitz
2002-08-14 20:45             ` Willy Tarreau
2002-08-14 20:58               ` H. Peter Anvin
2002-08-14 21:11                 ` Willy Tarreau
2002-08-14 21:13                   ` H. Peter Anvin
2002-08-15  1:23                 ` Alan Cox
2002-08-15  1:28                   ` H. Peter Anvin
2002-08-15  1:37                     ` Alan Cox
2002-08-14 22:53               ` David Lang
2002-08-14 23:31                 ` Jamie Lokier
2002-08-15  6:44                 ` Willy Tarreau
2002-08-15  6:55                   ` H. Peter Anvin
     [not found] <3D56147E.15E7A98@zip.com.au.suse.lists.linux.kernel>
2002-08-11  9:53 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox