[Bug 18473] Using inotify causes massive kernel memory leak
bugzilla-daemon at bugzilla.ubuntu.com
bugzilla-daemon at bugzilla.ubuntu.com
Tue Oct 25 23:03:12 UTC 2005
Please do not reply to this email. You can add comments at
http://bugzilla.ubuntu.com/show_bug.cgi?id=18473
Ubuntu | kernel-package
------- Additional Comments From ttb at tentacle.dhs.org 2005-10-26 00:03 UTC -------
Patch that went into 2.6.14:
Signed-off-by: Andrew Morton <akpm at osdl.org>
---
fs/inotify.c | 1 +
include/linux/idr.h | 1 +
lib/idr.c | 13 +++++++++++++
3 files changed, 15 insertions(+)
diff -puN lib/idr.c~inotify-idr-leak-fix lib/idr.c
--- devel/lib/idr.c~inotify-idr-leak-fix 2005-10-23 12:31:31.000000000 -0700
+++ devel-akpm/lib/idr.c 2005-10-23 12:31:31.000000000 -0700
@@ -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
--- devel/include/linux/idr.h~inotify-idr-leak-fix 2005-10-23
12:31:31.000000000 -0700
+++ devel-akpm/include/linux/idr.h 2005-10-23 12:31:31.000000000 -0700
@@ -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
--- devel/fs/inotify.c~inotify-idr-leak-fix 2005-10-23 12:31:31.000000000 -0700
+++ devel-akpm/fs/inotify.c 2005-10-23 12:31:31.000000000 -0700
@@ -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);
}
}
--
Configure bugmail: http://bugzilla.ubuntu.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.
More information about the kernel-bugs
mailing list