Commit a0e1d1be authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

SLUB: Move sysfs operations outside of slub_lock

Sysfs can do a gazillion things when called.  Make sure that we do not call
any sysfs functions while holding the slub_lock.

Just protect the essentials:

1. The list of all slab caches
2. The kmalloc_dma array
3. The ref counters of the slabs.
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 434e245d
...@@ -2192,11 +2192,12 @@ void kmem_cache_destroy(struct kmem_cache *s) ...@@ -2192,11 +2192,12 @@ void kmem_cache_destroy(struct kmem_cache *s)
s->refcount--; s->refcount--;
if (!s->refcount) { if (!s->refcount) {
list_del(&s->list); list_del(&s->list);
up_write(&slub_lock);
if (kmem_cache_close(s)) if (kmem_cache_close(s))
WARN_ON(1); WARN_ON(1);
sysfs_slab_remove(s); sysfs_slab_remove(s);
kfree(s); kfree(s);
} } else
up_write(&slub_lock); up_write(&slub_lock);
} }
EXPORT_SYMBOL(kmem_cache_destroy); EXPORT_SYMBOL(kmem_cache_destroy);
...@@ -2679,25 +2680,26 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, ...@@ -2679,25 +2680,26 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
*/ */
s->objsize = max(s->objsize, (int)size); s->objsize = max(s->objsize, (int)size);
s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
up_write(&slub_lock);
if (sysfs_slab_alias(s, name)) if (sysfs_slab_alias(s, name))
goto err; goto err;
} else { return s;
}
s = kmalloc(kmem_size, GFP_KERNEL); s = kmalloc(kmem_size, GFP_KERNEL);
if (s && kmem_cache_open(s, GFP_KERNEL, name, if (s) {
if (kmem_cache_open(s, GFP_KERNEL, name,
size, align, flags, ctor)) { size, align, flags, ctor)) {
if (sysfs_slab_add(s)) { list_add(&s->list, &slab_caches);
kfree(s); up_write(&slub_lock);
if (sysfs_slab_add(s))
goto err; goto err;
return s;
} }
list_add(&s->list, &slab_caches);
} else
kfree(s); kfree(s);
} }
up_write(&slub_lock); up_write(&slub_lock);
return s;
err: err:
up_write(&slub_lock);
if (flags & SLAB_PANIC) if (flags & SLAB_PANIC)
panic("Cannot create slabcache %s\n", name); panic("Cannot create slabcache %s\n", name);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment