diff options
-rw-r--r-- | include/linux/slab.h | 1 | ||||
-rw-r--r-- | mm/slab.c | 8 | ||||
-rw-r--r-- | mm/sparse.c | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index 3af03b19c983..2d985d59c7b8 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -150,6 +150,7 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags) | |||
150 | 150 | ||
151 | extern void kfree(const void *); | 151 | extern void kfree(const void *); |
152 | extern unsigned int ksize(const void *); | 152 | extern unsigned int ksize(const void *); |
153 | extern int slab_is_available(void); | ||
153 | 154 | ||
154 | #ifdef CONFIG_NUMA | 155 | #ifdef CONFIG_NUMA |
155 | extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node); | 156 | extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node); |
@@ -700,6 +700,14 @@ static enum { | |||
700 | FULL | 700 | FULL |
701 | } g_cpucache_up; | 701 | } g_cpucache_up; |
702 | 702 | ||
703 | /* | ||
704 | * used by boot code to determine if it can use slab based allocator | ||
705 | */ | ||
706 | int slab_is_available(void) | ||
707 | { | ||
708 | return g_cpucache_up == FULL; | ||
709 | } | ||
710 | |||
703 | static DEFINE_PER_CPU(struct work_struct, reap_work); | 711 | static DEFINE_PER_CPU(struct work_struct, reap_work); |
704 | 712 | ||
705 | static void free_block(struct kmem_cache *cachep, void **objpp, int len, | 713 | static void free_block(struct kmem_cache *cachep, void **objpp, int len, |
diff --git a/mm/sparse.c b/mm/sparse.c index d7c32de99ee8..c5e89eb9ac8f 100644 --- a/mm/sparse.c +++ b/mm/sparse.c | |||
@@ -32,7 +32,7 @@ static struct mem_section *sparse_index_alloc(int nid) | |||
32 | unsigned long array_size = SECTIONS_PER_ROOT * | 32 | unsigned long array_size = SECTIONS_PER_ROOT * |
33 | sizeof(struct mem_section); | 33 | sizeof(struct mem_section); |
34 | 34 | ||
35 | if (system_state == SYSTEM_RUNNING) | 35 | if (slab_is_available()) |
36 | section = kmalloc_node(array_size, GFP_KERNEL, nid); | 36 | section = kmalloc_node(array_size, GFP_KERNEL, nid); |
37 | else | 37 | else |
38 | section = alloc_bootmem_node(NODE_DATA(nid), array_size); | 38 | section = alloc_bootmem_node(NODE_DATA(nid), array_size); |