diff options
author | Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro> | 2008-08-24 13:49:35 -0400 |
---|---|---|
committer | Pekka Enberg <penberg@cs.helsinki.fi> | 2008-12-29 08:34:12 -0500 |
commit | 94b528d0564997d88e8bf166d8c9080536ad8bdc (patch) | |
tree | 257c157b40ce0384bff93640d2cfbb56d875d229 | |
parent | 73cd6af0413225b0ada8b8881c3e0cfd26506dfa (diff) |
kmemtrace: SLUB hooks for caller-tracking functions.
This patch adds kmemtrace hooks for __kmalloc_track_caller() and
__kmalloc_node_track_caller(). Currently, they set the call site pointer
to the value recieved as a parameter. (This could change if we implement
stack trace exporting in kmemtrace.)
Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
-rw-r--r-- | mm/slub.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -3256,6 +3256,7 @@ static struct notifier_block __cpuinitdata slab_notifier = { | |||
3256 | void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller) | 3256 | void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller) |
3257 | { | 3257 | { |
3258 | struct kmem_cache *s; | 3258 | struct kmem_cache *s; |
3259 | void *ret; | ||
3259 | 3260 | ||
3260 | if (unlikely(size > PAGE_SIZE)) | 3261 | if (unlikely(size > PAGE_SIZE)) |
3261 | return kmalloc_large(size, gfpflags); | 3262 | return kmalloc_large(size, gfpflags); |
@@ -3265,13 +3266,20 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller) | |||
3265 | if (unlikely(ZERO_OR_NULL_PTR(s))) | 3266 | if (unlikely(ZERO_OR_NULL_PTR(s))) |
3266 | return s; | 3267 | return s; |
3267 | 3268 | ||
3268 | return slab_alloc(s, gfpflags, -1, caller); | 3269 | ret = slab_alloc(s, gfpflags, -1, caller); |
3270 | |||
3271 | /* Honor the call site pointer we recieved. */ | ||
3272 | kmemtrace_mark_alloc(KMEMTRACE_TYPE_KMALLOC, (unsigned long) caller, | ||
3273 | ret, size, s->size, gfpflags); | ||
3274 | |||
3275 | return ret; | ||
3269 | } | 3276 | } |
3270 | 3277 | ||
3271 | void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, | 3278 | void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, |
3272 | int node, unsigned long caller) | 3279 | int node, unsigned long caller) |
3273 | { | 3280 | { |
3274 | struct kmem_cache *s; | 3281 | struct kmem_cache *s; |
3282 | void *ret; | ||
3275 | 3283 | ||
3276 | if (unlikely(size > PAGE_SIZE)) | 3284 | if (unlikely(size > PAGE_SIZE)) |
3277 | return kmalloc_large_node(size, gfpflags, node); | 3285 | return kmalloc_large_node(size, gfpflags, node); |
@@ -3281,7 +3289,14 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, | |||
3281 | if (unlikely(ZERO_OR_NULL_PTR(s))) | 3289 | if (unlikely(ZERO_OR_NULL_PTR(s))) |
3282 | return s; | 3290 | return s; |
3283 | 3291 | ||
3284 | return slab_alloc(s, gfpflags, node, caller); | 3292 | ret = slab_alloc(s, gfpflags, node, caller); |
3293 | |||
3294 | /* Honor the call site pointer we recieved. */ | ||
3295 | kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_KMALLOC, | ||
3296 | (unsigned long) caller, ret, | ||
3297 | size, s->size, gfpflags, node); | ||
3298 | |||
3299 | return ret; | ||
3285 | } | 3300 | } |
3286 | 3301 | ||
3287 | #ifdef CONFIG_SLUB_DEBUG | 3302 | #ifdef CONFIG_SLUB_DEBUG |