From: Valdis.Kletnieks@vt.edu
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] 2.6.16-rc1-mm1 - produce useful info for kzalloc with DEBUG_SLAB
Date: Thu, 19 Jan 2006 03:30:16 -0500 [thread overview]
Message-ID: <200601190830.k0J8UG9Q008899@turing-police.cc.vt.edu> (raw)
[-- 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 --]
next reply other threads:[~2006-01-19 8:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-19 8:30 Valdis.Kletnieks [this message]
2006-01-19 8:58 ` [PATCH] 2.6.16-rc1-mm1 - produce useful info for kzalloc with DEBUG_SLAB Pekka Enberg
2006-01-19 9:47 ` Valdis.Kletnieks
2006-01-19 13:14 ` Pekka J Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200601190830.k0J8UG9Q008899@turing-police.cc.vt.edu \
--to=valdis.kletnieks@vt.edu \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).