2 * Generic cache management functions. Everything is arch-specific,
3 * but this header exists to make sure the defines/functions can be
4 * used in a generic way.
6 * 2000-11-13 Arjan van de Ven <arjan@fenrus.demon.nl>
10 #ifndef _LINUX_PREFETCH_H
11 #define _LINUX_PREFETCH_H
13 #include <asm/processor.h>
14 #include <asm/cache.h>
17 prefetch(x) attempts to pre-emptively get the memory pointed to
18 by address "x" into the CPU L1 cache.
19 prefetch(x) should not cause any kind of exception, prefetch(0) is
22 prefetch() should be defined by the architecture, if not, the
23 #define below provides a no-op define.
25 There are 3 prefetch() macros:
27 prefetch(x) - prefetches the cacheline at "x" for read
28 prefetchw(x) - prefetches the cacheline at "x" for write
29 spin_lock_prefetch(x) - prefectches the spinlock *x for taking
31 there is also PREFETCH_STRIDE which is the architecure-prefered
32 "lookahead" size for prefetching streamed operations.
37 * These cannot be do{}while(0) macros. See the mental gymnastics in
41 #ifndef ARCH_HAS_PREFETCH
42 #define ARCH_HAS_PREFETCH
43 static inline void prefetch(const void *x) {;}
46 #ifndef ARCH_HAS_PREFETCHW
47 #define ARCH_HAS_PREFETCHW
48 static inline void prefetchw(const void *x) {;}
51 #ifndef ARCH_HAS_SPINLOCK_PREFETCH
52 #define ARCH_HAS_SPINLOCK_PREFETCH
53 #define spin_lock_prefetch(x) prefetchw(x)
56 #ifndef PREFETCH_STRIDE
57 #define PREFETCH_STRIDE (4*L1_CACHE_BYTES)