diff options
author | Christoph Lameter <clameter@sgi.com> | 2007-07-17 07:03:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-17 13:23:02 -0400 |
commit | a0e1d1be204612ee83b3afe8aa24c5d27e63d464 (patch) | |
tree | a32092a7eda82c84c5e195de5efd2cb6c0bff553 | |
parent | 434e245ddd3f14aa8eef97cae16c71b863ab092a (diff) |
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: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/slub.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -2192,12 +2192,13 @@ void kmem_cache_destroy(struct kmem_cache *s) | |||
2192 | s->refcount--; | 2192 | s->refcount--; |
2193 | if (!s->refcount) { | 2193 | if (!s->refcount) { |
2194 | list_del(&s->list); | 2194 | list_del(&s->list); |
2195 | up_write(&slub_lock); | ||
2195 | if (kmem_cache_close(s)) | 2196 | if (kmem_cache_close(s)) |
2196 | WARN_ON(1); | 2197 | WARN_ON(1); |
2197 | sysfs_slab_remove(s); | 2198 | sysfs_slab_remove(s); |
2198 | kfree(s); | 2199 | kfree(s); |
2199 | } | 2200 | } else |
2200 | up_write(&slub_lock); | 2201 | up_write(&slub_lock); |
2201 | } | 2202 | } |
2202 | EXPORT_SYMBOL(kmem_cache_destroy); | 2203 | EXPORT_SYMBOL(kmem_cache_destroy); |
2203 | 2204 | ||
@@ -2679,25 +2680,26 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, | |||
2679 | */ | 2680 | */ |
2680 | s->objsize = max(s->objsize, (int)size); | 2681 | s->objsize = max(s->objsize, (int)size); |
2681 | s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); | 2682 | s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); |
2683 | up_write(&slub_lock); | ||
2682 | if (sysfs_slab_alias(s, name)) | 2684 | if (sysfs_slab_alias(s, name)) |
2683 | goto err; | 2685 | goto err; |
2684 | } else { | 2686 | return s; |
2685 | s = kmalloc(kmem_size, GFP_KERNEL); | 2687 | } |
2686 | if (s && kmem_cache_open(s, GFP_KERNEL, name, | 2688 | s = kmalloc(kmem_size, GFP_KERNEL); |
2689 | if (s) { | ||
2690 | if (kmem_cache_open(s, GFP_KERNEL, name, | ||
2687 | size, align, flags, ctor)) { | 2691 | size, align, flags, ctor)) { |
2688 | if (sysfs_slab_add(s)) { | ||
2689 | kfree(s); | ||
2690 | goto err; | ||
2691 | } | ||
2692 | list_add(&s->list, &slab_caches); | 2692 | list_add(&s->list, &slab_caches); |
2693 | } else | 2693 | up_write(&slub_lock); |
2694 | kfree(s); | 2694 | if (sysfs_slab_add(s)) |
2695 | goto err; | ||
2696 | return s; | ||
2697 | } | ||
2698 | kfree(s); | ||
2695 | } | 2699 | } |
2696 | up_write(&slub_lock); | 2700 | up_write(&slub_lock); |
2697 | return s; | ||
2698 | 2701 | ||
2699 | err: | 2702 | err: |
2700 | up_write(&slub_lock); | ||
2701 | if (flags & SLAB_PANIC) | 2703 | if (flags & SLAB_PANIC) |
2702 | panic("Cannot create slabcache %s\n", name); | 2704 | panic("Cannot create slabcache %s\n", name); |
2703 | else | 2705 | else |