diff options
author | Vegard Nossum <vegard.nossum@gmail.com> | 2008-05-31 09:56:17 -0400 |
---|---|---|
committer | Vegard Nossum <vegard.nossum@gmail.com> | 2009-06-15 06:40:03 -0400 |
commit | 2dff440525f8faba8836e9f05297b76f23b4af30 (patch) | |
tree | 9f15e1dc2da06dba97cd939e41f34342caf05097 /include/linux/kmemcheck.h | |
parent | f85612967c93b67b10dd240e3e8bf8a0eee9def7 (diff) |
kmemcheck: add mm functions
With kmemcheck enabled, the slab allocator needs to do this:
1. Tell kmemcheck to allocate the shadow memory which stores the status of
each byte in the allocation proper, e.g. whether it is initialized or
uninitialized.
2. Tell kmemcheck which parts of memory that should be marked uninitialized.
There are actually a few more states, such as "not yet allocated" and
"recently freed".
If a slab cache is set up using the SLAB_NOTRACK flag, it will never return
memory that can take page faults because of kmemcheck.
If a slab cache is NOT set up using the SLAB_NOTRACK flag, callers can still
request memory with the __GFP_NOTRACK flag. This does not prevent the page
faults from occuring, however, but marks the object in question as being
initialized so that no warnings will ever be produced for this object.
In addition to (and in contrast to) __GFP_NOTRACK, the
__GFP_NOTRACK_FALSE_POSITIVE flag indicates that the allocation should
not be tracked _because_ it would produce a false positive. Their values
are identical, but need not be so in the future (for example, we could now
enable/disable false positives with a config option).
Parts of this patch were contributed by Pekka Enberg but merged for
atomicity.
Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
[rebased for mainline inclusion]
Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
Diffstat (limited to 'include/linux/kmemcheck.h')
-rw-r--r-- | include/linux/kmemcheck.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/include/linux/kmemcheck.h b/include/linux/kmemcheck.h index 39480c91b2f9..5b65f4ebeadf 100644 --- a/include/linux/kmemcheck.h +++ b/include/linux/kmemcheck.h | |||
@@ -7,11 +7,58 @@ | |||
7 | #ifdef CONFIG_KMEMCHECK | 7 | #ifdef CONFIG_KMEMCHECK |
8 | extern int kmemcheck_enabled; | 8 | extern int kmemcheck_enabled; |
9 | 9 | ||
10 | /* The slab-related functions. */ | ||
11 | void kmemcheck_alloc_shadow(struct kmem_cache *s, gfp_t flags, int node, | ||
12 | struct page *page, int order); | ||
13 | void kmemcheck_free_shadow(struct kmem_cache *s, struct page *page, int order); | ||
14 | void kmemcheck_slab_alloc(struct kmem_cache *s, gfp_t gfpflags, void *object, | ||
15 | size_t size); | ||
16 | void kmemcheck_slab_free(struct kmem_cache *s, void *object, size_t size); | ||
17 | |||
18 | void kmemcheck_show_pages(struct page *p, unsigned int n); | ||
19 | void kmemcheck_hide_pages(struct page *p, unsigned int n); | ||
20 | |||
21 | bool kmemcheck_page_is_tracked(struct page *p); | ||
22 | |||
23 | void kmemcheck_mark_unallocated(void *address, unsigned int n); | ||
24 | void kmemcheck_mark_uninitialized(void *address, unsigned int n); | ||
25 | void kmemcheck_mark_initialized(void *address, unsigned int n); | ||
26 | void kmemcheck_mark_freed(void *address, unsigned int n); | ||
27 | |||
28 | void kmemcheck_mark_unallocated_pages(struct page *p, unsigned int n); | ||
29 | void kmemcheck_mark_uninitialized_pages(struct page *p, unsigned int n); | ||
30 | |||
10 | int kmemcheck_show_addr(unsigned long address); | 31 | int kmemcheck_show_addr(unsigned long address); |
11 | int kmemcheck_hide_addr(unsigned long address); | 32 | int kmemcheck_hide_addr(unsigned long address); |
12 | #else | 33 | #else |
13 | #define kmemcheck_enabled 0 | 34 | #define kmemcheck_enabled 0 |
14 | 35 | ||
36 | static inline void | ||
37 | kmemcheck_alloc_shadow(struct kmem_cache *s, gfp_t flags, int node, | ||
38 | struct page *page, int order) | ||
39 | { | ||
40 | } | ||
41 | |||
42 | static inline void | ||
43 | kmemcheck_free_shadow(struct kmem_cache *s, struct page *page, int order) | ||
44 | { | ||
45 | } | ||
46 | |||
47 | static inline void | ||
48 | kmemcheck_slab_alloc(struct kmem_cache *s, gfp_t gfpflags, void *object, | ||
49 | size_t size) | ||
50 | { | ||
51 | } | ||
52 | |||
53 | static inline void kmemcheck_slab_free(struct kmem_cache *s, void *object, | ||
54 | size_t size) | ||
55 | { | ||
56 | } | ||
57 | |||
58 | static inline bool kmemcheck_page_is_tracked(struct page *p) | ||
59 | { | ||
60 | return false; | ||
61 | } | ||
15 | #endif /* CONFIG_KMEMCHECK */ | 62 | #endif /* CONFIG_KMEMCHECK */ |
16 | 63 | ||
17 | #endif /* LINUX_KMEMCHECK_H */ | 64 | #endif /* LINUX_KMEMCHECK_H */ |