slab: setup allocators earlier in the boot sequence
[sfrench/cifs-2.6.git] / mm / slub.c
index 65ffda5934b09b8220e9a00332945dc19ba88de6..c1815a63807a3dcf2651ae01d5173714d7a7a9cb 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -17,7 +17,7 @@
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
-#include <trace/kmemtrace.h>
+#include <linux/kmemtrace.h>
 #include <linux/cpu.h>
 #include <linux/cpuset.h>
 #include <linux/mempolicy.h>
@@ -2557,13 +2557,16 @@ static struct kmem_cache *create_kmalloc_cache(struct kmem_cache *s,
        if (gfp_flags & SLUB_DMA)
                flags = SLAB_CACHE_DMA;
 
-       down_write(&slub_lock);
+       /*
+        * This function is called with IRQs disabled during early-boot on
+        * single CPU so there's no need to take slub_lock here.
+        */
        if (!kmem_cache_open(s, gfp_flags, name, size, ARCH_KMALLOC_MINALIGN,
                                                                flags, NULL))
                goto panic;
 
        list_add(&s->list, &slab_caches);
-       up_write(&slub_lock);
+
        if (sysfs_slab_add(s))
                goto panic;
        return s;
@@ -3021,7 +3024,7 @@ void __init kmem_cache_init(void)
         * kmem_cache_open for slab_state == DOWN.
         */
        create_kmalloc_cache(&kmalloc_caches[0], "kmem_cache_node",
-               sizeof(struct kmem_cache_node), GFP_KERNEL);
+               sizeof(struct kmem_cache_node), GFP_NOWAIT);
        kmalloc_caches[0].refcount = -1;
        caches++;
 
@@ -3034,16 +3037,16 @@ void __init kmem_cache_init(void)
        /* Caches that are not of the two-to-the-power-of size */
        if (KMALLOC_MIN_SIZE <= 64) {
                create_kmalloc_cache(&kmalloc_caches[1],
-                               "kmalloc-96", 96, GFP_KERNEL);
+                               "kmalloc-96", 96, GFP_NOWAIT);
                caches++;
                create_kmalloc_cache(&kmalloc_caches[2],
-                               "kmalloc-192", 192, GFP_KERNEL);
+                               "kmalloc-192", 192, GFP_NOWAIT);
                caches++;
        }
 
        for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
                create_kmalloc_cache(&kmalloc_caches[i],
-                       "kmalloc", 1 << i, GFP_KERNEL);
+                       "kmalloc", 1 << i, GFP_NOWAIT);
                caches++;
        }
 
@@ -3080,7 +3083,7 @@ void __init kmem_cache_init(void)
        /* Provide the correct kmalloc names now that the caches are up */
        for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++)
                kmalloc_caches[i]. name =
-                       kasprintf(GFP_KERNEL, "kmalloc-%d", 1 << i);
+                       kasprintf(GFP_NOWAIT, "kmalloc-%d", 1 << i);
 
 #ifdef CONFIG_SMP
        register_cpu_notifier(&slab_notifier);