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 /mm | |
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 'mm')
-rw-r--r-- | mm/slab.c | 13 | ||||
-rw-r--r-- | mm/util.c | 6 |
2 files changed, 11 insertions, 8 deletions
@@ -3488,22 +3488,25 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags, | |||
3488 | } | 3488 | } |
3489 | 3489 | ||
3490 | 3490 | ||
3491 | #ifdef CONFIG_DEBUG_SLAB | ||
3491 | void *__kmalloc(size_t size, gfp_t flags) | 3492 | void *__kmalloc(size_t size, gfp_t flags) |
3492 | { | 3493 | { |
3493 | #ifndef CONFIG_DEBUG_SLAB | ||
3494 | return __do_kmalloc(size, flags, NULL); | ||
3495 | #else | ||
3496 | return __do_kmalloc(size, flags, __builtin_return_address(0)); | 3494 | return __do_kmalloc(size, flags, __builtin_return_address(0)); |
3497 | #endif | ||
3498 | } | 3495 | } |
3499 | EXPORT_SYMBOL(__kmalloc); | 3496 | EXPORT_SYMBOL(__kmalloc); |
3500 | 3497 | ||
3501 | #ifdef CONFIG_DEBUG_SLAB | ||
3502 | void *__kmalloc_track_caller(size_t size, gfp_t flags, void *caller) | 3498 | void *__kmalloc_track_caller(size_t size, gfp_t flags, void *caller) |
3503 | { | 3499 | { |
3504 | return __do_kmalloc(size, flags, caller); | 3500 | return __do_kmalloc(size, flags, caller); |
3505 | } | 3501 | } |
3506 | EXPORT_SYMBOL(__kmalloc_track_caller); | 3502 | EXPORT_SYMBOL(__kmalloc_track_caller); |
3503 | |||
3504 | #else | ||
3505 | void *__kmalloc(size_t size, gfp_t flags) | ||
3506 | { | ||
3507 | return __do_kmalloc(size, flags, NULL); | ||
3508 | } | ||
3509 | EXPORT_SYMBOL(__kmalloc); | ||
3507 | #endif | 3510 | #endif |
3508 | 3511 | ||
3509 | /** | 3512 | /** |
@@ -11,7 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | void *__kzalloc(size_t size, gfp_t flags) | 12 | void *__kzalloc(size_t size, gfp_t flags) |
13 | { | 13 | { |
14 | void *ret = ____kmalloc(size, flags); | 14 | void *ret = kmalloc_track_caller(size, flags); |
15 | if (ret) | 15 | if (ret) |
16 | memset(ret, 0, size); | 16 | memset(ret, 0, size); |
17 | return ret; | 17 | return ret; |
@@ -33,7 +33,7 @@ char *kstrdup(const char *s, gfp_t gfp) | |||
33 | return NULL; | 33 | return NULL; |
34 | 34 | ||
35 | len = strlen(s) + 1; | 35 | len = strlen(s) + 1; |
36 | buf = ____kmalloc(len, gfp); | 36 | buf = kmalloc_track_caller(len, gfp); |
37 | if (buf) | 37 | if (buf) |
38 | memcpy(buf, s, len); | 38 | memcpy(buf, s, len); |
39 | return buf; | 39 | return buf; |
@@ -51,7 +51,7 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp) | |||
51 | { | 51 | { |
52 | void *p; | 52 | void *p; |
53 | 53 | ||
54 | p = ____kmalloc(len, gfp); | 54 | p = kmalloc_track_caller(len, gfp); |
55 | if (p) | 55 | if (p) |
56 | memcpy(p, src, len); | 56 | memcpy(p, src, len); |
57 | return p; | 57 | return p; |