Messages in this thread Patch in this message | | | Subject | [PATCH] 2.6.16-rc1-mm1 - produce useful info for kzalloc with DEBUG_SLAB | From | Valdis.Kletnieks@vt ... | Date | Thu, 19 Jan 2006 03:30:16 -0500 |
| |
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
[unhandled content-type:application/pgp-signature] | |