aboutsummaryrefslogtreecommitdiff
path: root/mm/slub.c
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2012-09-05 00:20:34 +0000
committerPekka Enberg <penberg@kernel.org>2012-09-05 12:00:36 +0300
commit278b1bb1313664d4999a7f7d47a8a8d964862d02 (patch)
tree65e05bc30338a24fd4afd4c4e8b49b8d3e002218 /mm/slub.c
parent96d17b7be0a9849d381442030886211dbb2a7061 (diff)
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/slub.c')
-rw-r--r--mm/slub.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 8d00fd78df2..0ad3fffc7d2 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3034,7 +3034,6 @@ static int kmem_cache_open(struct kmem_cache *s,
size_t align, unsigned long flags,
void (*ctor)(void *))
{
- memset(s, 0, kmem_size);
s->name = name;
s->ctor = ctor;
s->object_size = size;
@@ -3109,7 +3108,7 @@ static int kmem_cache_open(struct kmem_cache *s,
goto error;
if (alloc_kmem_cache_cpus(s))
- return 1;
+ return 0;
free_kmem_cache_nodes(s);
error:
@@ -3118,7 +3117,7 @@ error:
"order=%u offset=%u flags=%lx\n",
s->name, (unsigned long)size, s->size, oo_order(s->oo),
s->offset, flags);
- return 0;
+ return -EINVAL;
}
/*
@@ -3260,13 +3259,13 @@ static struct kmem_cache *__init create_kmalloc_cache(const char *name,
{
struct kmem_cache *s;
- s = kmem_cache_alloc(kmem_cache, GFP_NOWAIT);
+ s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT);
/*
* This function is called with IRQs disabled during early-boot on
* single CPU so there's no need to take slab_mutex here.
*/
- if (!kmem_cache_open(s, name, size, ARCH_KMALLOC_MINALIGN,
+ if (kmem_cache_open(s, name, size, ARCH_KMALLOC_MINALIGN,
flags, NULL))
goto panic;
@@ -3944,20 +3943,11 @@ struct kmem_cache *__kmem_cache_alias(const char *name, size_t size,
return s;
}
-struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
+int __kmem_cache_create(struct kmem_cache *s,
+ const char *name, size_t size,
size_t align, unsigned long flags, void (*ctor)(void *))
{
- struct kmem_cache *s;
-
- s = kmem_cache_alloc(kmem_cache, GFP_KERNEL);
- if (s) {
- if (kmem_cache_open(s, name,
- size, align, flags, ctor)) {
- return s;
- }
- kmem_cache_free(kmem_cache, s);
- }
- return NULL;
+ return kmem_cache_open(s, name, size, align, flags, ctor);
}
#ifdef CONFIG_SMP