kmemtrace: trace kfree() calls with NULL or zero-length objects
Subsystems (2)
PATCH 1/1 kmemtrace: trace kfree() calls with NULL or zero-length objects
From: Pekka Enberg <[email protected]>
Impact: improve tracing
This patch moves the trace_kfree() calls before the ZERO_OR_NULL_PTR check so that we can trace call-sites that call kfree() with NULL many times which might be an indication of a bug.
---
Eduard, does this require some changes in the user-space tools?
mm/slab.c | 4 ++-- mm/slob.c | 4 ++-- mm/slub.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
mm/slab.c +2 -2
@@ -3773,6 +3773,8 @@ void kfree(const void *objp)struct kmem_cache *c;unsigned long flags; +trace_kfree (_RET_IP_, objp); +if (unlikely (ZERO_OR_NULL_PTR (objp)))return ;local_irq_save (flags);
@@ -3782,8 +3784,6 @@ void kfree(const void *objp)debug_check_no_obj_freed (objp,obj_size (c));__cache_free (c, (void *)objp);local_irq_restore (flags); - -trace_kfree (_RET_IP_, objp); }EXPORT_SYMBOL (kfree);
mm/slob.c +2 -2
@@ -503,6 +503,8 @@ void kfree(const void *block) {struct slob_page *sp; +trace_kfree (_RET_IP_, block); +if (unlikely (ZERO_OR_NULL_PTR (block)))return ;
@@ -513,8 +515,6 @@ void kfree(const void *block)slob_free (m, *m + align); }else put_page (&sp->page); - -trace_kfree (_RET_IP_, block); }EXPORT_SYMBOL (kfree);
mm/slub.c +2 -2
@@ -2791,6 +2791,8 @@ void kfree(const void *x)struct page *page;void *object = (void *)x; +trace_kfree (_RET_IP_, x); +if (unlikely (ZERO_OR_NULL_PTR (x)))return ;
@@ -2801,8 +2803,6 @@ void kfree(const void *x)return ; }slab_free (page->slab, page, object, _RET_IP_); - -trace_kfree (_RET_IP_, x); }EXPORT_SYMBOL (kfree);
Signature · 1 line
1.5.4.3
Commit-ID: ceff33f2fe894601b5e6805f88ea2b6a9622ce75 Gitweb: http://git.kernel.org/tip/ceff33f2fe894601b5e6805f88ea2b6a9622ce75 Author: Pekka Enberg <[email protected]> AuthorDate: Wed, 25 Mar 2009 11:05:57 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 25 Mar 2009 10:15:20 +0100
kmemtrace: trace kfree() calls with NULL or zero-length objects
Impact: also output kfree(NULL) entries
This patch moves the trace_kfree() calls before the ZERO_OR_NULL_PTR check so that we can trace call-sites that call kfree() with NULL many times which might be an indication of a bug.
LKML-Reference: <1237971957.30175.18.camel@penberg-laptop>
--- mm/slab.c | 4 ++-- mm/slob.c | 4 ++-- mm/slub.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
mm/slab.c +2 -2
@@ -3773,6 +3773,8 @@ void kfree(const void *objp)struct kmem_cache *c;unsigned long flags; +trace_kfree (_RET_IP_, objp); +if (unlikely (ZERO_OR_NULL_PTR (objp)))return ;local_irq_save (flags);
@@ -3782,8 +3784,6 @@ void kfree(const void *objp)debug_check_no_obj_freed (objp,obj_size (c));__cache_free (c, (void *)objp);local_irq_restore (flags); - -trace_kfree (_RET_IP_, objp); }EXPORT_SYMBOL (kfree);
mm/slob.c +2 -2
@@ -503,6 +503,8 @@ void kfree(const void *block) {struct slob_page *sp; +trace_kfree (_RET_IP_, block); +if (unlikely (ZERO_OR_NULL_PTR (block)))return ;
@@ -513,8 +515,6 @@ void kfree(const void *block)slob_free (m, *m + align); }else put_page (&sp->page); - -trace_kfree (_RET_IP_, block); }EXPORT_SYMBOL (kfree);
mm/slub.c +2 -2
@@ -2791,6 +2791,8 @@ void kfree(const void *x)struct page *page;void *object = (void *)x; +trace_kfree (_RET_IP_, x); +if (unlikely (ZERO_OR_NULL_PTR (x)))return ;
@@ -2801,8 +2803,6 @@ void kfree(const void *x)return ; }slab_free (page->slab, page, object, _RET_IP_); - -trace_kfree (_RET_IP_, x); }EXPORT_SYMBOL (kfree);
Commit-ID: 2121db74ba0fd2259f0e2265511684fadda9ac49 Gitweb: http://git.kernel.org/tip/2121db74ba0fd2259f0e2265511684fadda9ac49 Author: Pekka Enberg <[email protected]> AuthorDate: Wed, 25 Mar 2009 11:05:57 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 3 Apr 2009 12:23:10 +0200
kmemtrace: trace kfree() calls with NULL or zero-length objects
Impact: also output kfree(NULL) entries
This patch moves the trace_kfree() calls before the ZERO_OR_NULL_PTR check so that we can trace call-sites that call kfree() with NULL many times which might be an indication of a bug.
LKML-Reference: <1237971957.30175.18.camel@penberg-laptop>
--- mm/slab.c | 4 ++-- mm/slob.c | 4 ++-- mm/slub.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
mm/slab.c +2 -2
@@ -3773,6 +3773,8 @@ void kfree(const void *objp)struct kmem_cache *c;unsigned long flags; +trace_kfree (_RET_IP_, objp); +if (unlikely (ZERO_OR_NULL_PTR (objp)))return ;local_irq_save (flags);
@@ -3782,8 +3784,6 @@ void kfree(const void *objp)debug_check_no_obj_freed (objp,obj_size (c));__cache_free (c, (void *)objp);local_irq_restore (flags); - -trace_kfree (_RET_IP_, objp); }EXPORT_SYMBOL (kfree);
mm/slob.c +2 -2
@@ -514,6 +514,8 @@ void kfree(const void *block) {struct slob_page *sp; +trace_kfree (_RET_IP_, block); +if (unlikely (ZERO_OR_NULL_PTR (block)))return ;
@@ -524,8 +526,6 @@ void kfree(const void *block)slob_free (m, *m + align); }else put_page (&sp->page); - -trace_kfree (_RET_IP_, block); }EXPORT_SYMBOL (kfree);
mm/slub.c +2 -2
@@ -2792,6 +2792,8 @@ void kfree(const void *x)struct page *page;void *object = (void *)x; +trace_kfree (_RET_IP_, x); +if (unlikely (ZERO_OR_NULL_PTR (x)))return ;
@@ -2802,8 +2804,6 @@ void kfree(const void *x)return ; }slab_free (page->slab, page, object, _RET_IP_); - -trace_kfree (_RET_IP_, x); }EXPORT_SYMBOL (kfree);