From: Stefan Jones <stefan.jones@churchillrandoms.co.uk>
To: linux-kernel@vger.kernel.org
Subject: Re: [BUG][2.6.13.4] Memoryleak - idr_layer_cache slab - inotify?
Date: Fri, 21 Oct 2005 13:17:26 -0700 [thread overview]
Message-ID: <43594CD6.3020308@churchillrandoms.co.uk> (raw)
In-Reply-To: <43593240.9020806@churchillrandoms.co.uk>
Stefan Jones wrote:
Made a standalone testcase, run this and the kernel will eat up your
memory (seen via slabtop):
[ creates a inotify_dev, and a watch and exits ; repeat via fork ... ]
Tracked it down me thinks:
struct inotify_device {
...
struct idr idr; /* idr mapping wd -> watch */
...
}
idr gets allocated each time inotify_init() is called:
asmlinkage long sys_inotify_init(void)
{
..
idr_init(&dev->idr);
..
}
Looking in lib/idr.c you see:
* You can release ids at any time. When all ids are released, most of
* the memory is returned (we keep IDR_FREE_MAX) in a local pool so we
* don't need to go to the memory "store" during an id allocate, just
* so you don't need to be too concerned about locking and conflicts
* with the slab allocator.
So even if you free all ids which create_watch->inotify_dev_get_wd
creates you will still have menory in your struct idr.
So when
static inline void put_inotify_dev(struct inotify_device *dev)
{
if (atomic_dec_and_test(&dev->count)) {
atomic_dec(&dev->user->inotify_devs);
free_uid(dev->user);
kfree(dev);
}
}
is called I think this is whre the memory gets lost. ( linux/idr.h has
not free function I see )
Stefan
next prev parent reply other threads:[~2005-10-21 20:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-21 18:24 Stefan Jones
2005-10-21 18:53 ` Stefan Jones
2005-10-21 20:17 ` Stefan Jones [this message]
2005-10-21 20:48 ` Andrew Morton
2005-10-21 21:35 ` Stefan Jones
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=43594CD6.3020308@churchillrandoms.co.uk \
--to=stefan.jones@churchillrandoms.co.uk \
--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®