aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-07-17 07:03:31 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:02 -0400
commita0e1d1be204612ee83b3afe8aa24c5d27e63d464 (patch)
treea32092a7eda82c84c5e195de5efd2cb6c0bff553 /mm/slub.c
parent434e245ddd3f14aa8eef97cae16c71b863ab092a (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>
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/mm/slub.c b/mm/slub.c
index f976d2866e73..1c5d6a068556 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -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}
2202EXPORT_SYMBOL(kmem_cache_destroy); 2203EXPORT_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
2699err: 2702err:
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