public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kmemtrace: trace kfree() calls with NULL or zero-length objects
@ 2009-03-25  9:05 Pekka Enberg
  2009-03-25  9:45 ` [tip:tracing/kmemtrace] " Pekka Enberg
  2009-04-03 10:37 ` [tip:tracing/kmemtrace-v2] " Pekka Enberg
  0 siblings, 2 replies; 3+ messages in thread
From: Pekka Enberg @ 2009-03-25  9:05 UTC (permalink / raw)
  To: mingo; +Cc: rostedt, eduard.munteanu, linux-kernel

From: Pekka Enberg <penberg@cs.helsinki.fi>

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.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
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(-)

diff --git a/mm/slab.c b/mm/slab.c
index fa00fd6..b584002 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -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);
 
diff --git a/mm/slob.c b/mm/slob.c
index 2ccd31d..5bd7ecc 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -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);
 
diff --git a/mm/slub.c b/mm/slub.c
index c3a905b..988ef33 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -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);
 
-- 
1.5.4.3




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-04-03 10:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-25  9:05 [PATCH] kmemtrace: trace kfree() calls with NULL or zero-length objects Pekka Enberg
2009-03-25  9:45 ` [tip:tracing/kmemtrace] " Pekka Enberg
2009-04-03 10:37 ` [tip:tracing/kmemtrace-v2] " Pekka Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox