aboutsummaryrefslogtreecommitdiffstats
path: root/mm/kmemleak.c
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2014-06-06 17:38:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-06 19:08:17 -0400
commitffe2c748e283c5dc1b9b9ac116299dbfc11a609b (patch)
treeef16269fb598e941c9e0c90004a8cc20f2133760 /mm/kmemleak.c
parentaae0ad7ae5a997bff1862e6e5eebed39cdf08ff3 (diff)
mm: introduce kmemleak_update_trace()
The memory allocation stack trace is not always useful for debugging a memory leak (e.g. radix_tree_preload). This function, when called, updates the stack trace for an already allocated object. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/kmemleak.c')
-rw-r--r--mm/kmemleak.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 5d4aec44982e..3cda50c1e394 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -990,6 +990,40 @@ void __ref kmemleak_free_percpu(const void __percpu *ptr)
990EXPORT_SYMBOL_GPL(kmemleak_free_percpu); 990EXPORT_SYMBOL_GPL(kmemleak_free_percpu);
991 991
992/** 992/**
993 * kmemleak_update_trace - update object allocation stack trace
994 * @ptr: pointer to beginning of the object
995 *
996 * Override the object allocation stack trace for cases where the actual
997 * allocation place is not always useful.
998 */
999void __ref kmemleak_update_trace(const void *ptr)
1000{
1001 struct kmemleak_object *object;
1002 unsigned long flags;
1003
1004 pr_debug("%s(0x%p)\n", __func__, ptr);
1005
1006 if (!kmemleak_enabled || IS_ERR_OR_NULL(ptr))
1007 return;
1008
1009 object = find_and_get_object((unsigned long)ptr, 1);
1010 if (!object) {
1011#ifdef DEBUG
1012 kmemleak_warn("Updating stack trace for unknown object at %p\n",
1013 ptr);
1014#endif
1015 return;
1016 }
1017
1018 spin_lock_irqsave(&object->lock, flags);
1019 object->trace_len = __save_stack_trace(object->trace);
1020 spin_unlock_irqrestore(&object->lock, flags);
1021
1022 put_object(object);
1023}
1024EXPORT_SYMBOL(kmemleak_update_trace);
1025
1026/**
993 * kmemleak_not_leak - mark an allocated object as false positive 1027 * kmemleak_not_leak - mark an allocated object as false positive
994 * @ptr: pointer to beginning of the object 1028 * @ptr: pointer to beginning of the object
995 * 1029 *