mm, sl[aou]b: Extract common code for kmem_cache_create()
Kmem_cache_create() does a variety of sanity checks but those vary depending on the allocator. Use the strictest tests and put them into a slab_common file. Make the tests conditional on CONFIG_DEBUG_VM. This patch has the effect of adding sanity checks for SLUB and SLOB under CONFIG_DEBUG_VM and removes the checks in SLAB for !CONFIG_DEBUG_VM. Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:

committed by
Pekka Enberg

vanhempi
068ce415be
commit
039363f38b
11
mm/slub.c
11
mm/slub.c
@@ -3920,15 +3920,12 @@ static struct kmem_cache *find_mergeable(size_t size,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct kmem_cache *kmem_cache_create(const char *name, size_t size,
|
||||
struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
|
||||
size_t align, unsigned long flags, void (*ctor)(void *))
|
||||
{
|
||||
struct kmem_cache *s;
|
||||
char *n;
|
||||
|
||||
if (WARN_ON(!name))
|
||||
return NULL;
|
||||
|
||||
down_write(&slub_lock);
|
||||
s = find_mergeable(size, align, flags, name, ctor);
|
||||
if (s) {
|
||||
@@ -3972,14 +3969,8 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
|
||||
kfree(n);
|
||||
err:
|
||||
up_write(&slub_lock);
|
||||
|
||||
if (flags & SLAB_PANIC)
|
||||
panic("Cannot create slabcache %s\n", name);
|
||||
else
|
||||
s = NULL;
|
||||
return s;
|
||||
}
|
||||
EXPORT_SYMBOL(kmem_cache_create);
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/*
|
||||
|
Viittaa uudesa ongelmassa
Block a user