From: Andrew Morton <akpm@osdl.org>
To: Valdis.Kletnieks@vt.edu
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.6.16-rc5-mm2 - kzalloc() considered harmful for debugging.
Date: Mon, 19 Dec 2005 02:20:59 -0800 [thread overview]
Message-ID: <20051219022059.36443421.akpm@osdl.org> (raw)
In-Reply-To: <200512181258.jBICwMdj003410@turing-police.cc.vt.edu>
Valdis.Kletnieks@vt.edu wrote:
>
> So I've got a (probably self-inflicted) memory leak in slab-64 and slab-32.
> Rebuild the kernel with CONFIG_DEBUG_SLAB, reboot, and wait for a bit of
> leak to pile up, and then echo 'slab-32 0 0 0' > /proc/slabinfo
>
> And ta-DA! the top offender is... (drum roll): <kzalloc+0xe/0x36>
>
> Blargh. It's tempting to do something like this in include/linux/slab.h:
>
> #ifdef CONFIG_SLAB_DEBUG
> static 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);
> #end
That would work.
Or we could special-case kzalloc() and kstrdup() in slab.c - use
builtin_return_address(1) if builtin_return_address(0) is within those
functions. Dunno if that's worth the fuss though.
next prev parent reply other threads:[~2005-12-19 10:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-18 12:58 Valdis.Kletnieks
2005-12-18 20:41 ` Pekka Enberg
2005-12-19 10:20 ` Andrew Morton [this message]
2005-12-22 5:05 ` Keith Owens
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=20051219022059.36443421.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=Valdis.Kletnieks@vt.edu \
--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
all inboxes | Powered by JetHome®