mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Jones <stefan.jones@churchillrandoms.co.uk>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [BUG][2.6.13.4] Memoryleak - idr_layer_cache slab - inotify?
Date: Fri, 21 Oct 2005 14:35:34 -0700	[thread overview]
Message-ID: <43595F26.9010308@churchillrandoms.co.uk> (raw)
In-Reply-To: <20051021134843.497921fd.akpm@osdl.org>

Andrew Morton wrote:

>Something like this?
>
>  
>
Yep, that fixes it. The  idr_layer_cache slab is now stable. Thanks

>diff -puN lib/idr.c~inotify-idr-leak-fix lib/idr.c
>--- 25/lib/idr.c~inotify-idr-leak-fix	Fri Oct 21 13:44:23 2005
>+++ 25-akpm/lib/idr.c	Fri Oct 21 13:46:09 2005
>@@ -346,6 +346,19 @@ void idr_remove(struct idr *idp, int id)
> EXPORT_SYMBOL(idr_remove);
> 
> /**
>+ * idr_destroy - release all cached layers within an idr tree
>+ * idp: idr handle
>+ */
>+void idr_destroy(struct idr *idp)
>+{
>+	while (idp->id_free_cnt) {
>+		struct idr_layer *p = alloc_layer(idp);
>+		kmem_cache_free(idr_layer_cache, p);
>+	}
>+}
>+EXPORT_SYMBOL(idr_destroy);
>+
>+/**
>  * idr_find - return pointer for given id
>  * @idp: idr handle
>  * @id: lookup key
>diff -puN include/linux/idr.h~inotify-idr-leak-fix include/linux/idr.h
>--- 25/include/linux/idr.h~inotify-idr-leak-fix	Fri Oct 21 13:44:23 2005
>+++ 25-akpm/include/linux/idr.h	Fri Oct 21 13:46:19 2005
>@@ -75,4 +75,5 @@ int idr_pre_get(struct idr *idp, unsigne
> int idr_get_new(struct idr *idp, void *ptr, int *id);
> int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
> void idr_remove(struct idr *idp, int id);
>+void idr_destroy(struct idr *idp);
> void idr_init(struct idr *idp);
>diff -puN fs/inotify.c~inotify-idr-leak-fix fs/inotify.c
>--- 25/fs/inotify.c~inotify-idr-leak-fix	Fri Oct 21 13:47:27 2005
>+++ 25-akpm/fs/inotify.c	Fri Oct 21 13:47:38 2005
>@@ -176,6 +176,7 @@ static inline void put_inotify_dev(struc
> 	if (atomic_dec_and_test(&dev->count)) {
> 		atomic_dec(&dev->user->inotify_devs);
> 		free_uid(dev->user);
>+		idr_destroy(&dev->idr);
> 		kfree(dev);
> 	}
> }
>_
>
>
>  
>


      reply	other threads:[~2005-10-21 21:35 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
2005-10-21 20:48   ` Andrew Morton
2005-10-21 21:35     ` Stefan Jones [this message]

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=43595F26.9010308@churchillrandoms.co.uk \
    --to=stefan.jones@churchillrandoms.co.uk \
    --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

all inboxes | Powered by JetHome®