mm/sl[aou]b: Move sysfs_slab_add to common
Simplify locking by moving the slab_add_sysfs after all locks have been
dropped. Eases the upcoming move to provide sysfs support for all
allocators.
Reviewed-by: Glauber Costa <glommer@parallels.com>
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
diff --git a/mm/slab_common.c b/mm/slab_common.c
index adc42b0..4f72208 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -152,6 +152,14 @@
return NULL;
}
+ if (s->refcount == 1) {
+ err = sysfs_slab_add(s);
+ if (err)
+ printk(KERN_WARNING "kmem_cache_create(%s) failed to"
+ " create sysfs entry. Error %d\n",
+ name, err);
+ }
+
return s;
}
EXPORT_SYMBOL(kmem_cache_create);