diff options
author | Christoph Lameter <cl@linux.com> | 2012-09-05 00:20:34 +0000 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2012-09-05 12:00:36 +0300 |
commit | 278b1bb1313664d4999a7f7d47a8a8d964862d02 (patch) | |
tree | 65e05bc30338a24fd4afd4c4e8b49b8d3e002218 /mm/slab_common.c | |
parent | 96d17b7be0a9849d381442030886211dbb2a7061 (diff) | |
download | linux-278b1bb1313664d4999a7f7d47a8a8d964862d02.tar.gz linux-278b1bb1313664d4999a7f7d47a8a8d964862d02.tar.bz2 linux-278b1bb1313664d4999a7f7d47a8a8d964862d02.zip |
mm/sl[aou]b: Move kmem_cache allocations into common code
Shift the allocations to common code. That way the allocation and
freeing of the kmem_cache structures is handled by common code.
Reviewed-by: Glauber Costa <glommer@parallels.com>
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.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/mm/slab_common.c b/mm/slab_common.c index 4f722084baed..f50d2ed4fbf1 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -119,19 +119,21 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, size_t align if (s) goto out_locked; - s = __kmem_cache_create(n, size, align, flags, ctor); - + s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL); if (s) { - /* - * Check if the slab has actually been created and if it was a - * real instatiation. Aliases do not belong on the list - */ - if (s->refcount == 1) + err = __kmem_cache_create(s, n, size, align, flags, ctor); + if (!err) + list_add(&s->list, &slab_caches); + else { + kfree(n); + kmem_cache_free(kmem_cache, s); + } + } else { kfree(n); - err = -ENOSYS; /* Until __kmem_cache_create returns code */ + err = -ENOMEM; } out_locked: |