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 <linux/types.h>
14 #include <asm/processor.h>
15 #include <asm/cache.h>
18 prefetch(x) attempts to pre-emptively get the memory pointed to
19 by address "x" into the CPU L1 cache.
20 prefetch(x) should not cause any kind of exception, prefetch(0) is
23 prefetch() should be defined by the architecture, if not, the
24 #define below provides a no-op define.
26 There are 3 prefetch() macros:
28 prefetch(x) - prefetches the cacheline at "x" for read
29 prefetchw(x) - prefetches the cacheline at "x" for write
30 spin_lock_prefetch(x) - prefetches the spinlock *x for taking
32 there is also PREFETCH_STRIDE which is the architecure-preferred
33 "lookahead" size for prefetching streamed operations.
37 #ifndef ARCH_HAS_PREFETCH
38 #define prefetch(x) __builtin_prefetch(x)
41 #ifndef ARCH_HAS_PREFETCHW
42 #define prefetchw(x) __builtin_prefetch(x,1)
45 #ifndef ARCH_HAS_SPINLOCK_PREFETCH
46 #define spin_lock_prefetch(x) prefetchw(x)
49 #ifndef PREFETCH_STRIDE
50 #define PREFETCH_STRIDE (4*L1_CACHE_BYTES)
53 static inline void prefetch_range(void *addr
, size_t len
)
55 #ifdef ARCH_HAS_PREFETCH
57 char *end
= addr
+ len
;
59 for (cp
= addr
; cp
< end
; cp
+= PREFETCH_STRIDE
)
This page took 0.031012 seconds and 5 git commands to generate.