mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] 2.6.16-rc1-mm1 - produce useful info for kzalloc with DEBUG_SLAB
@ 2006-01-19  8:30 Valdis.Kletnieks
  2006-01-19  8:58 ` Pekka Enberg
  0 siblings, 1 reply; 4+ messages in thread
From: Valdis.Kletnieks @ 2006-01-19  8:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2398 bytes --]

The following patch makes a few minor changes so the CONFIG_DEBUG_SLAB
statistics report the actual caller for kzalloc() - otherwise its call to
kmalloc() just points at kzalloc().  Basically, we force __always_inline on
several routines, so the __builtin_return_address calls point where we
want them to point, even if gcc wouldn't otherwise do it.

Signed-Off-By: Valdis Kletnieks <valdis.kletnieks@vt.edu>
---
 include/linux/slab.h |   10 ++++++++++
 mm/slab.c            |    4 ++--
 mm/util.c            |    2 ++
 3 files changed, 14 insertions(+), 2 deletions(-)

--- linux-2.6.16-rc1-mm1/include/linux/slab.h.slab	2006-01-18 16:12:08.000000000 -0500
+++ linux-2.6.16-rc1-mm1/include/linux/slab.h	2006-01-18 16:12:10.000000000 -0500
@@ -101,7 +101,17 @@ found:
 	return __kmalloc(size, flags);
 }
 
+#ifdef CONFIG_DEBUG_SLAB
+static __always_inline void  *kzalloc(size_t size, gfp_t flags)
+{
+	void *ret = __kmalloc(size, flags);
+	if (ret)
+		memset(ret, 0, size);
+	return ret;
+}
+#else
 extern void *kzalloc(size_t, gfp_t);
+#endif
 
 /**
  * kcalloc - allocate memory for an array. The memory is set to zero.
--- linux-2.6.16-rc1-mm1/mm/slab.c.slab	2006-01-18 16:12:08.000000000 -0500
+++ linux-2.6.16-rc1-mm1/mm/slab.c	2006-01-19 03:13:29.000000000 -0500
@@ -2407,7 +2407,7 @@ static void kfree_debugcheck(const void 
 	}
 }
 
-static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
+static __always_inline void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
 				   void *caller)
 {
 	struct page *page;
@@ -2614,7 +2614,7 @@ cache_alloc_debugcheck_before(struct kme
 }
 
 #if DEBUG
-static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, gfp_t flags,
+static __always_inline void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, gfp_t flags,
 					void *objp, void *caller)
 {
 	if (!objp)
--- linux-2.6.16-rc1-mm1/mm/util.c.slab	2006-01-18 16:11:46.000000000 -0500
+++ linux-2.6.16-rc1-mm1/mm/util.c	2006-01-18 16:12:10.000000000 -0500
@@ -2,6 +2,7 @@
 #include <linux/string.h>
 #include <linux/module.h>
 
+#ifndef CONFIG_DEBUG_SLAB
 /**
  * kzalloc - allocate memory. The memory is set to zero.
  * @size: how many bytes of memory are required.
@@ -15,6 +16,7 @@ void *kzalloc(size_t size, gfp_t flags)
 	return ret;
 }
 EXPORT_SYMBOL(kzalloc);
+#endif
 
 /*
  * kstrdup - allocate space for and copy an existing string



[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

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

end of thread, other threads:[~2006-01-19 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-19  8:30 [PATCH] 2.6.16-rc1-mm1 - produce useful info for kzalloc with DEBUG_SLAB Valdis.Kletnieks
2006-01-19  8:58 ` Pekka Enberg
2006-01-19  9:47   ` Valdis.Kletnieks
2006-01-19 13:14     ` Pekka J Enberg

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

all inboxes | Powered by JetHome®