aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/prefetch.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/prefetch.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/prefetch.h')
-rw-r--r--include/linux/prefetch.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/include/linux/prefetch.h b/include/linux/prefetch.h
new file mode 100644
index 000000000000..fc86f274147f
--- /dev/null
+++ b/include/linux/prefetch.h
@@ -0,0 +1,69 @@
1/*
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.
5 *
6 * 2000-11-13 Arjan van de Ven <arjan@fenrus.demon.nl>
7 *
8 */
9
10#ifndef _LINUX_PREFETCH_H
11#define _LINUX_PREFETCH_H
12
13#include <linux/types.h>
14#include <asm/processor.h>
15#include <asm/cache.h>
16
17/*
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
21 specifically ok.
22
23 prefetch() should be defined by the architecture, if not, the
24 #define below provides a no-op define.
25
26 There are 3 prefetch() macros:
27
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) - prefectches the spinlock *x for taking
31
32 there is also PREFETCH_STRIDE which is the architecure-prefered
33 "lookahead" size for prefetching streamed operations.
34
35*/
36
37/*
38 * These cannot be do{}while(0) macros. See the mental gymnastics in
39 * the loop macro.
40 */
41
42#ifndef ARCH_HAS_PREFETCH
43static inline void prefetch(const void *x) {;}
44#endif
45
46#ifndef ARCH_HAS_PREFETCHW
47static inline void prefetchw(const void *x) {;}
48#endif
49
50#ifndef ARCH_HAS_SPINLOCK_PREFETCH
51#define spin_lock_prefetch(x) prefetchw(x)
52#endif
53
54#ifndef PREFETCH_STRIDE
55#define PREFETCH_STRIDE (4*L1_CACHE_BYTES)
56#endif
57
58static inline void prefetch_range(void *addr, size_t len)
59{
60#ifdef ARCH_HAS_PREFETCH
61 char *cp;
62 char *end = addr + len;
63
64 for (cp = addr; cp < end; cp += PREFETCH_STRIDE)
65 prefetch(cp);
66#endif
67}
68
69#endif