]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] add slab_is_available() routine for boot code
authorMike Kravetz <kravetz@us.ibm.com>
Mon, 15 May 2006 16:44:13 +0000 (09:44 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 15 May 2006 18:20:56 +0000 (11:20 -0700)
slab_is_available() indicates slab based allocators are available for use.
SPARSEMEM code needs to know this as it can be called at various times
during the boot process.

Signed-off-by: Mike Kravetz <kravetz@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/slab.h
mm/slab.c
mm/sparse.c

index 3af03b19c9830275c77ef99f98c6a22e76a79a7f..2d985d59c7b86759663761c3ec333ec196730026 100644 (file)
@@ -150,6 +150,7 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
 
 extern void kfree(const void *);
 extern unsigned int ksize(const void *);
+extern int slab_is_available(void);
 
 #ifdef CONFIG_NUMA
 extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node);
index c32af7e7581ef0ff11ef112f94b6a84da50cafc4..b1d643b5238de2f74ab3911d2bab4479c8745385 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -700,6 +700,14 @@ static enum {
        FULL
 } g_cpucache_up;
 
+/*
+ * used by boot code to determine if it can use slab based allocator
+ */
+int slab_is_available(void)
+{
+       return g_cpucache_up == FULL;
+}
+
 static DEFINE_PER_CPU(struct work_struct, reap_work);
 
 static void free_block(struct kmem_cache *cachep, void **objpp, int len,
index d7c32de99ee8c49d0e850a06084d5efe508a7625..c5e89eb9ac8ff10e1e15fced114de41058df4a7e 100644 (file)
@@ -32,7 +32,7 @@ static struct mem_section *sparse_index_alloc(int nid)
        unsigned long array_size = SECTIONS_PER_ROOT *
                                   sizeof(struct mem_section);
 
-       if (system_state == SYSTEM_RUNNING)
+       if (slab_is_available())
                section = kmalloc_node(array_size, GFP_KERNEL, nid);
        else
                section = alloc_bootmem_node(NODE_DATA(nid), array_size);