diff options
Diffstat (limited to 'include/linux/slab.h')
-rw-r--r-- | include/linux/slab.h | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index a96fd9310d55..c4947b8a2c03 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/mm/slab.h | 2 | * linux/include/linux/slab.h |
3 | * Written by Mark Hemment, 1996. | 3 | * Written by Mark Hemment, 1996. |
4 | * (markhe@nextd.demon.co.uk) | 4 | * (markhe@nextd.demon.co.uk) |
5 | */ | 5 | */ |
@@ -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 | ||