0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _LINUX_PREFETCH_H
0012 #define _LINUX_PREFETCH_H
0013
0014 #include <linux/types.h>
0015 #include <asm/processor.h>
0016 #include <asm/cache.h>
0017
0018 struct page;
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #ifndef ARCH_HAS_PREFETCH
0040 #define prefetch(x) __builtin_prefetch(x)
0041 #endif
0042
0043 #ifndef ARCH_HAS_PREFETCHW
0044 #define prefetchw(x) __builtin_prefetch(x,1)
0045 #endif
0046
0047 #ifndef ARCH_HAS_SPINLOCK_PREFETCH
0048 #define spin_lock_prefetch(x) prefetchw(x)
0049 #endif
0050
0051 #ifndef PREFETCH_STRIDE
0052 #define PREFETCH_STRIDE (4*L1_CACHE_BYTES)
0053 #endif
0054
0055 static inline void prefetch_range(void *addr, size_t len)
0056 {
0057 #ifdef ARCH_HAS_PREFETCH
0058 char *cp;
0059 char *end = addr + len;
0060
0061 for (cp = addr; cp < end; cp += PREFETCH_STRIDE)
0062 prefetch(cp);
0063 #endif
0064 }
0065
0066 static inline void prefetch_page_address(struct page *page)
0067 {
0068 #if defined(WANT_PAGE_VIRTUAL) || defined(HASHED_PAGE_VIRTUAL)
0069 prefetch(page);
0070 #endif
0071 }
0072
0073 #endif