Do not use kmalloc() but kmem_cache_alloc() for the allocation of the kmem_cache structures in slub. This is the way its supposed to be. Recent merges lost the freeing of the kmem_cache structure and so this is also fixing memory leak on kmem_cache_destroy() by adding the missing free action to sysfs_slab_remove(). Signed-off-by: Christoph Lameter <cl@xxxxxxxxx> Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2012-08-01 13:02:18.897656578 -0500 +++ linux-2.6/mm/slub.c 2012-08-01 13:06:02.673597753 -0500 @@ -213,7 +213,7 @@ static inline void sysfs_slab_remove(struct kmem_cache *s) { kfree(s->name); - kfree(s); + kmem_cache_free(kmem_cache, s); } #endif @@ -3962,7 +3962,7 @@ if (!n) return NULL; - s = kmalloc(kmem_size, GFP_KERNEL); + s = kmem_cache_alloc(kmem_cache, GFP_KERNEL); if (s) { if (kmem_cache_open(s, n, size, align, flags, ctor)) { @@ -3979,7 +3979,7 @@ list_del(&s->list); kmem_cache_close(s); } - kfree(s); + kmem_cache_free(kmem_cache, s); } kfree(n); return NULL; @@ -5217,7 +5217,7 @@ struct kmem_cache *s = to_slab(kobj); kfree(s->name); - kfree(s); + kmem_cache_free(kmem_cache, s); } static const struct sysfs_ops slab_sysfs_ops = { @@ -5342,6 +5342,8 @@ kobject_uevent(&s->kobj, KOBJ_REMOVE); kobject_del(&s->kobj); kobject_put(&s->kobj); + kfree(s->name); + kmem_cache_free(kmem_cache, s); } /* -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>