From: Steve VanDeBogart <vandebo-lkml@NerdBox.Net>
To: linux-kernel@vger.kernel.org,
user-mode-linux-devel@lists.sourceforge.net, jiayingz@google.com,
dkegel@google.com
Subject: [uml-devel] [PATCH 5/6] slab: Annotate slab
Date: Fri, 29 Aug 2008 16:17:34 -0700 (PDT) [thread overview]
Message-ID: <alpine.DEB.1.00.0808291616560.15543@abydos.NerdBox.Net> (raw)
In-Reply-To: <alpine.DEB.1.00.0808281139420.15543@abydos.NerdBox.Net>
Valgrind annotations for the slab allocator: Malloc-like and free-like
for cache_alloc and free. Telling Valgrind a region is free-like clears
all the valid bits, so slabs with constructors need different treatment;
tell Valgrind about slab objects when first constructed and free them
when the slab is destroyed.
Signed-off-by: Steve VanDeBogart <vandebo-lkml@nerdbox.net>
---
Index: linux-2.6.27-rc5/mm/slab.c
===================================================================
--- linux-2.6.27-rc5.orig/mm/slab.c 2008-08-29 14:24:25.000000000 -0700
+++ linux-2.6.27-rc5/mm/slab.c 2008-08-29 14:24:42.000000000 -0700
@@ -111,6 +111,7 @@
#include <linux/rtmutex.h>
#include <linux/reciprocal_div.h>
#include <linux/debugobjects.h>
+#include <linux/memcheck.h>
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>
@@ -1906,6 +1907,8 @@
int i;
for (i = 0; i < cachep->num; i++) {
void *objp = index_to_obj(cachep, slabp, i);
+ if (cachep->ctor)
+ VALGRIND_FREELIKE_BLOCK(objp, 0);
if (cachep->flags & SLAB_POISON) {
#ifdef CONFIG_DEBUG_PAGEALLOC
@@ -1932,6 +1935,15 @@
#else
static void slab_destroy_debugcheck(struct kmem_cache *cachep, struct slab *slabp)
{
+#ifdef CONFIG_VALGRIND_SUPPORT
+ int i;
+ if (cachep->ctor) {
+ for (i = 0; i < cachep->num; i++) {
+ void *objp = index_to_obj(cachep, slabp, i);
+ VALGRIND_FREELIKE_BLOCK(objp, 0);
+ }
+ }
+#endif
}
#endif
@@ -2635,6 +2647,9 @@
for (i = 0; i < cachep->num; i++) {
void *objp = index_to_obj(cachep, slabp, i);
+ if (cachep->ctor)
+ VALGRIND_MALLOCLIKE_BLOCK(objp, cachep->buffer_size,
+ 0, 0);
#if DEBUG
/* need to poison the objs? */
if (cachep->flags & SLAB_POISON)
@@ -3466,6 +3481,8 @@
objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);
prefetchw(objp);
+ if (!cachep->ctor)
+ VALGRIND_MALLOCLIKE_BLOCK(objp, cachep->buffer_size, 0, 0);
if (unlikely((flags & __GFP_ZERO) && objp))
memset(objp, 0, obj_size(cachep));
@@ -3578,6 +3595,9 @@
{
struct array_cache *ac = cpu_cache_get(cachep);
+ if (!cachep->ctor)
+ VALGRIND_FREELIKE_BLOCK(objp, 0);
+
check_irq_off();
objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2008-08-29 23:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-29 23:12 [uml-devel] [PATCH 0/6] support valgrinding uml Steve VanDeBogart
2008-08-29 23:14 ` [uml-devel] [PATCH 1/6] base: Valgrind headers and Kconfig Steve VanDeBogart
2008-09-01 9:32 ` Andi Kleen
2008-09-01 14:06 ` Jeff Dike
2008-09-01 14:22 ` Andi Kleen
2008-09-01 15:47 ` Jeff Dike
2008-08-29 23:15 ` [uml-devel] [PATCH 2/6] UML: Don't valgrind userspace Steve VanDeBogart
2008-09-05 16:37 ` Jeff Dike
2008-09-06 20:55 ` John Reiser
2008-09-06 22:12 ` Jeff Dike
2008-08-29 23:16 ` [uml-devel] [PATCH 3/6] UML and sched: Annotate stacks Steve VanDeBogart
2008-08-29 23:16 ` [uml-devel] [PATCH 4/6] VM: Annotate pagealloc Steve VanDeBogart
2008-08-30 10:57 ` Pekka Enberg
2008-09-03 5:25 ` Steve VanDeBogart
2008-09-03 9:35 ` Pekka Enberg
2008-08-29 23:17 ` Steve VanDeBogart [this message]
2008-08-30 10:50 ` [uml-devel] [PATCH 5/6] slab: Annotate slab Pekka Enberg
2008-09-03 2:54 ` John Reiser
2008-09-03 9:39 ` Pekka J Enberg
2008-09-03 5:08 ` Steve VanDeBogart
2008-09-03 9:27 ` Pekka Enberg
2008-09-03 9:40 ` Pekka Enberg
2008-09-03 15:42 ` Steve VanDeBogart
2008-09-04 7:33 ` Pekka Enberg
2008-08-29 23:18 ` [uml-devel] [PATCH 6/6] VM: Annotate vmalloc Steve VanDeBogart
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=alpine.DEB.1.00.0808291616560.15543@abydos.NerdBox.Net \
--to=vandebo-lkml@nerdbox.net \
--cc=dkegel@google.com \
--cc=jiayingz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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).