diff options
Diffstat (limited to 'include/linux/slab.h')
-rw-r--r-- | include/linux/slab.h | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index 66d6eb78d1c6..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 | */ |
@@ -60,7 +60,7 @@ extern void __init kmem_cache_init(void); | |||
60 | extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long, | 60 | extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long, |
61 | void (*)(void *, kmem_cache_t *, unsigned long), | 61 | void (*)(void *, kmem_cache_t *, unsigned long), |
62 | void (*)(void *, kmem_cache_t *, unsigned long)); | 62 | void (*)(void *, kmem_cache_t *, unsigned long)); |
63 | extern int kmem_cache_destroy(kmem_cache_t *); | 63 | extern void kmem_cache_destroy(kmem_cache_t *); |
64 | extern int kmem_cache_shrink(kmem_cache_t *); | 64 | extern int kmem_cache_shrink(kmem_cache_t *); |
65 | extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t); | 65 | extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t); |
66 | extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); | 66 | extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); |
@@ -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 | /** |
@@ -249,7 +259,7 @@ struct kmem_cache *kmem_cache_create(const char *c, size_t, size_t, | |||
249 | unsigned long, | 259 | unsigned long, |
250 | void (*)(void *, struct kmem_cache *, unsigned long), | 260 | void (*)(void *, struct kmem_cache *, unsigned long), |
251 | void (*)(void *, struct kmem_cache *, unsigned long)); | 261 | void (*)(void *, struct kmem_cache *, unsigned long)); |
252 | int kmem_cache_destroy(struct kmem_cache *c); | 262 | void kmem_cache_destroy(struct kmem_cache *c); |
253 | void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags); | 263 | void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags); |
254 | void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); | 264 | void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); |
255 | void kmem_cache_free(struct kmem_cache *c, void *b); | 265 | void kmem_cache_free(struct kmem_cache *c, void *b); |
@@ -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 | ||