kmemtrace: SLUB hooks for caller-tracking functions.
Subsystems (2)
PATCH 1/1 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.)
--- mm/slub.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-)
mm/slub.c +18 -2
@@ -3254,6 +3254,7 @@ static struct notifier_block __cpuinitdata slab_notifier = {void *__kmalloc_track_caller (size_t size,gfp_t gfpflags,void *caller) {struct kmem_cache *s; +void *ret;if (unlikely (size >PAGE_SIZE ))return kmalloc_large (size, gfpflags);
@@ -3263,13 +3264,21 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, void *caller)if (unlikely (ZERO_OR_NULL_PTR (s)))return s; -return slab_alloc (s, gfpflags,-1 , caller); + ret =slab_alloc (s, gfpflags,-1 , caller); + +/* Honor the call site pointer we recieved. */ +kmemtrace_mark_alloc (KMEMTRACE_TYPE_KMALLOC , + (unsigned long ) caller, ret, + size, s->size, gfpflags); + +return ret; }void *__kmalloc_node_track_caller (size_t size,gfp_t gfpflags,int node,void *caller) {struct kmem_cache *s; +void *ret;if (unlikely (size >PAGE_SIZE ))return kmalloc_large_node (size, gfpflags, node);
@@ -3279,7 +3288,14 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,if (unlikely (ZERO_OR_NULL_PTR (s)))return s; -return slab_alloc (s, gfpflags, node, caller); + ret =slab_alloc (s, gfpflags, node, caller); + +/* Honor the call site pointer we recieved. */ +kmemtrace_mark_alloc_node (KMEMTRACE_TYPE_KMALLOC , + (unsigned long ) caller, ret, + size, s->size, gfpflags, node); + +return ret; }#ifdef CONFIG_SLUB_DEBUG
Signature · 7 lines
1.5.6.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Pekka Enberg
AppliedQuoted 6 lines · Eduard - Gabriel Munteanu
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 <[email protected]>
Applied. I had to do some manual tweaking, so can you please double-check the result:
Thanks!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Pekka Enberg
Quoted 5 lines · Eduard - Gabriel Munteanu
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 <[email protected]>
Quoted 6 lines
Applied. I had to do some manual tweaking, so can you please double-check the result:
Thanks!
Looks fine to me. However, you can now remove the casts to unsigned long from 'caller', i.e. "s/(unsigned long) caller/caller/g"
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Eduard - Gabriel Munteanu
Quoted 6 lines · Pekka Enberg
Quoted 5 lines · Eduard - Gabriel Munteanu
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 <[email protected]>
Quoted 8 lines
Quoted 5 lines
Applied. I had to do some manual tweaking, so can you please double-check the result:
Thanks!
Looks fine to me. However, you can now remove the casts to unsigned long from 'caller', i.e. "s/(unsigned long) caller/caller/g"
Fixed, thanks!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>