aboutsummaryrefslogtreecommitdiff
path: root/mm/slab_common.c
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2012-09-04 23:18:33 +0000
committerPekka Enberg <penberg@kernel.org>2012-09-05 12:00:37 +0300
commit8a13a4cc80bb25c9eab2e7e56bab724fcfa55fce (patch)
treea212edb3d0b139b0743ca5ca34c14037a6ada4dc /mm/slab_common.c
parent278b1bb1313664d4999a7f7d47a8a8d964862d02 (diff)
mm/sl[aou]b: Shrink __kmem_cache_create() parameter lists
Do the initial settings of the fields in common code. This will allow us to push more processing into common code later and improve readability. Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slab_common.c')
-rw-r--r--mm/slab_common.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/mm/slab_common.c b/mm/slab_common.c
index f50d2ed4fbf..8a85a19d90e 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -100,7 +100,6 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, size_t align
{
struct kmem_cache *s = NULL;
int err = 0;
- char *n;
get_online_cpus();
mutex_lock(&slab_mutex);
@@ -109,32 +108,33 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, size_t align
goto out_locked;
- n = kstrdup(name, GFP_KERNEL);
- if (!n) {
- err = -ENOMEM;
- goto out_locked;
- }
-
s = __kmem_cache_alias(name, size, align, flags, ctor);
if (s)
goto out_locked;
s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL);
if (s) {
- err = __kmem_cache_create(s, n, size, align, flags, ctor);
+ s->object_size = s->size = size;
+ s->align = align;
+ s->ctor = ctor;
+ s->name = kstrdup(name, GFP_KERNEL);
+ if (!s->name) {
+ kmem_cache_free(kmem_cache, s);
+ err = -ENOMEM;
+ goto out_locked;
+ }
+
+ err = __kmem_cache_create(s, flags);
if (!err)
list_add(&s->list, &slab_caches);
else {
- kfree(n);
+ kfree(s->name);
kmem_cache_free(kmem_cache, s);
}
-
- } else {
- kfree(n);
+ } else
err = -ENOMEM;
- }
out_locked:
mutex_unlock(&slab_mutex);