diff options
author | Christoph Hellwig <hch@lst.de> | 2006-10-04 05:15:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-04 10:55:13 -0400 |
commit | 1d2c8eea698514cfaa53fc991b960791d09508e1 (patch) | |
tree | e6e2b2d491e7e7256862fcc493b81815cc966312 /include/linux/slab.h | |
parent | 88ca3b94e82e763ef90c8e57cacd51a3c143ea62 (diff) |
[PATCH] slab: clean up leak tracking ifdefs a little bit
- rename ____kmalloc to kmalloc_track_caller so that people have a chance
to guess what it does just from it's name. Add a comment describing it
for those who don't. Also move it after kmalloc in slab.h so people get
less confused when they are just looking for kmalloc - move things around
in slab.c a little to reduce the ifdef mess.
[penberg@cs.helsinki.fi: Fix up reversed #ifdef]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Christoph Lameter <clameter@engr.sgi.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/slab.h')
-rw-r--r-- | include/linux/slab.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index 70be57d8ae0d..c4947b8a2c03 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -77,13 +77,6 @@ struct cache_sizes { | |||
77 | extern struct cache_sizes malloc_sizes[]; | 77 | extern struct cache_sizes malloc_sizes[]; |
78 | 78 | ||
79 | extern void *__kmalloc(size_t, gfp_t); | 79 | extern void *__kmalloc(size_t, gfp_t); |
80 | #ifndef CONFIG_DEBUG_SLAB | ||
81 | #define ____kmalloc(size, flags) __kmalloc(size, flags) | ||
82 | #else | ||
83 | extern void *__kmalloc_track_caller(size_t, gfp_t, void*); | ||
84 | #define ____kmalloc(size, flags) \ | ||
85 | __kmalloc_track_caller(size, flags, __builtin_return_address(0)) | ||
86 | #endif | ||
87 | 80 | ||
88 | /** | 81 | /** |
89 | * kmalloc - allocate memory | 82 | * kmalloc - allocate memory |
@@ -153,6 +146,23 @@ found: | |||
153 | return __kmalloc(size, flags); | 146 | return __kmalloc(size, flags); |
154 | } | 147 | } |
155 | 148 | ||
149 | /* | ||
150 | * kmalloc_track_caller is a special version of kmalloc that records the | ||
151 | * calling function of the routine calling it for slab leak tracking instead | ||
152 | * of just the calling function (confusing, eh?). | ||
153 | * It's useful when the call to kmalloc comes from a widely-used standard | ||
154 | * allocator where we care about the real place the memory allocation | ||
155 | * request comes from. | ||
156 | */ | ||
157 | #ifndef CONFIG_DEBUG_SLAB | ||
158 | #define kmalloc_track_caller(size, flags) \ | ||
159 | __kmalloc(size, flags) | ||
160 | #else | ||
161 | extern void *__kmalloc_track_caller(size_t, gfp_t, void*); | ||
162 | #define kmalloc_track_caller(size, flags) \ | ||
163 | __kmalloc_track_caller(size, flags, __builtin_return_address(0)) | ||
164 | #endif | ||
165 | |||
156 | extern void *__kzalloc(size_t, gfp_t); | 166 | extern void *__kzalloc(size_t, gfp_t); |
157 | 167 | ||
158 | /** | 168 | /** |
@@ -271,7 +281,7 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags) | |||
271 | #define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f) | 281 | #define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f) |
272 | #define kmalloc_node(s, f, n) kmalloc(s, f) | 282 | #define kmalloc_node(s, f, n) kmalloc(s, f) |
273 | #define kzalloc(s, f) __kzalloc(s, f) | 283 | #define kzalloc(s, f) __kzalloc(s, f) |
274 | #define ____kmalloc kmalloc | 284 | #define kmalloc_track_caller kmalloc |
275 | 285 | ||
276 | #endif /* CONFIG_SLOB */ | 286 | #endif /* CONFIG_SLOB */ |
277 | 287 | ||