Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a0e1d1be204612ee83b3afe8aa24c5d27e63d464
Commit:     a0e1d1be204612ee83b3afe8aa24c5d27e63d464
Parent:     434e245ddd3f14aa8eef97cae16c71b863ab092a
Author:     Christoph Lameter <[EMAIL PROTECTED]>
AuthorDate: Tue Jul 17 04:03:31 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Jul 17 10:23:02 2007 -0700

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 mm/slub.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index f976d28..1c5d6a0 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2192,12 +2192,13 @@ void kmem_cache_destroy(struct kmem_cache *s)
        s->refcount--;
        if (!s->refcount) {
                list_del(&s->list);
+               up_write(&slub_lock);
                if (kmem_cache_close(s))
                        WARN_ON(1);
                sysfs_slab_remove(s);
                kfree(s);
-       }
-       up_write(&slub_lock);
+       } else
+               up_write(&slub_lock);
 }
 EXPORT_SYMBOL(kmem_cache_destroy);
 
@@ -2679,25 +2680,26 @@ struct kmem_cache *kmem_cache_create(const char *name, 
size_t size,
                 */
                s->objsize = max(s->objsize, (int)size);
                s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
+               up_write(&slub_lock);
                if (sysfs_slab_alias(s, name))
                        goto err;
-       } else {
-               s = kmalloc(kmem_size, GFP_KERNEL);
-               if (s && kmem_cache_open(s, GFP_KERNEL, name,
+               return s;
+       }
+       s = kmalloc(kmem_size, GFP_KERNEL);
+       if (s) {
+               if (kmem_cache_open(s, GFP_KERNEL, name,
                                size, align, flags, ctor)) {
-                       if (sysfs_slab_add(s)) {
-                               kfree(s);
-                               goto err;
-                       }
                        list_add(&s->list, &slab_caches);
-               } else
-                       kfree(s);
+                       up_write(&slub_lock);
+                       if (sysfs_slab_add(s))
+                               goto err;
+                       return s;
+               }
+               kfree(s);
        }
        up_write(&slub_lock);
-       return s;
 
 err:
-       up_write(&slub_lock);
        if (flags & SLAB_PANIC)
                panic("Cannot create slabcache %s\n", name);
        else
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to