diff options
author | Christoph Hellwig <hch@lst.de> | 2006-12-06 23:32:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 11:39:22 -0500 |
commit | 8b98c1699eba23cfd2e8b366625c50ff5fd1415b (patch) | |
tree | 24462eaefeb4e2fa85e77d392a94a60316ad2349 /include/linux/slab.h | |
parent | 881e4aabe4c6b3fce93674b67c6adc646fe2683b (diff) |
[PATCH] leak tracking for kmalloc_node
We have variants of kmalloc and kmem_cache_alloc that leave leak tracking to
the caller. This is used for subsystem-specific allocators like skb_alloc.
To make skb_alloc node-aware we need similar routines for the node-aware slab
allocator, which this patch adds.
Note that the code is rather ugly, but it mirrors the non-node-aware code 1:1:
[akpm@osdl.org: add module export]
Signed-off-by: Christoph Hellwig <hch@lst.de>
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 | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index c4947b8a2c03..66c4640d3656 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -236,7 +236,25 @@ found: | |||
236 | } | 236 | } |
237 | return __kmalloc_node(size, flags, node); | 237 | return __kmalloc_node(size, flags, node); |
238 | } | 238 | } |
239 | |||
240 | /* | ||
241 | * kmalloc_node_track_caller is a special version of kmalloc_node that | ||
242 | * records the calling function of the routine calling it for slab leak | ||
243 | * tracking instead of just the calling function (confusing, eh?). | ||
244 | * It's useful when the call to kmalloc_node comes from a widely-used | ||
245 | * standard allocator where we care about the real place the memory | ||
246 | * allocation request comes from. | ||
247 | */ | ||
248 | #ifndef CONFIG_DEBUG_SLAB | ||
249 | #define kmalloc_node_track_caller(size, flags, node) \ | ||
250 | __kmalloc_node(size, flags, node) | ||
239 | #else | 251 | #else |
252 | extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *); | ||
253 | #define kmalloc_node_track_caller(size, flags, node) \ | ||
254 | __kmalloc_node_track_caller(size, flags, node, \ | ||
255 | __builtin_return_address(0)) | ||
256 | #endif | ||
257 | #else /* CONFIG_NUMA */ | ||
240 | static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node) | 258 | static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node) |
241 | { | 259 | { |
242 | return kmem_cache_alloc(cachep, flags); | 260 | return kmem_cache_alloc(cachep, flags); |
@@ -245,6 +263,9 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node) | |||
245 | { | 263 | { |
246 | return kmalloc(size, flags); | 264 | return kmalloc(size, flags); |
247 | } | 265 | } |
266 | |||
267 | #define kmalloc_node_track_caller(size, flags, node) \ | ||
268 | kmalloc_track_caller(size, flags) | ||
248 | #endif | 269 | #endif |
249 | 270 | ||
250 | extern int FASTCALL(kmem_cache_reap(int)); | 271 | extern int FASTCALL(kmem_cache_reap(int)); |
@@ -283,6 +304,8 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags) | |||
283 | #define kzalloc(s, f) __kzalloc(s, f) | 304 | #define kzalloc(s, f) __kzalloc(s, f) |
284 | #define kmalloc_track_caller kmalloc | 305 | #define kmalloc_track_caller kmalloc |
285 | 306 | ||
307 | #define kmalloc_node_track_caller kmalloc_node | ||
308 | |||
286 | #endif /* CONFIG_SLOB */ | 309 | #endif /* CONFIG_SLOB */ |
287 | 310 | ||
288 | /* System wide caches */ | 311 | /* System wide caches */ |