add slab_is_available() routine for boot code
Subsystems (3)
PATCH 1/1 add slab_is_available() routine for boot code
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.
include/linux/slab.h +1 -0
@@ -150,6 +150,7 @@ static inline void *kcalloc(size_t n, siextern 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);
mm/slab.c +8 -0
@@ -694,6 +694,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,
mm/sparse.c +1 -1
@@ -32,7 +32,7 @@ static struct mem_section *sparse_index_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);
Quoted 22 lines · Mike Kravetz
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 <[email protected]>diff -Naupr
linux-2.6.17-rc3-mm1/include/linux/slab.hlinux-2.6.17-rc3-mm1.work3/include/linux/slab.hinclude/linux/slab.h +1
-0@@ -150,6 +150,7 @@ static inline void *kcalloc(size_t n, siextern 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);diff -Naupr
linux-2.6.17-rc3-mm1/mm/slab.clinux-2.6.17-rc3-mm1.work3/mm/slab.c
mm/slab.c static enum { · line 703
Quoted 10 lines
mm/slab.c +7
-0@@ -694,6 +694,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 ; +}
Even I can understand this ;)
Quoted 7 lines
mm/slab.c +0
-0static DEFINE_PER_CPU(struct work_struct, reap_work); static void free_block(struct kmem_cache *cachep, void **objpp, int len,diff -Naupr
linux-2.6.17-rc3-mm1/mm/sparse.clinux-2.6.17-rc3-mm1.work3/mm/sparse.c
mm/sparse.c static struct mem_section *sparse_index_ · line 38
Quoted 8 lines
mm/sparse.c +1
-1@@ -32,7 +32,7 @@ static struct mem_section *sparse_index_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);
Is this a needed-for-2.6.17 fix?
Quoted 8 lines · Andrew Morton
Quoted 7 lines · Mike Kravetz
diff -Naupr
linux-2.6.17-rc3-mm1/mm/sparse.clinux-2.6.17-rc3-mm1.work3/mm/sparse.cmm/sparse.c +0
-0@@ -32,7 +32,7 @@ static struct mem_section *sparse_index_unsigned long array_size =SECTIONS_PER_ROOT *sizeof (struct mem_section );
Quoted 7 lines
mm/sparse.c static struct mem_section *sparse_index_ · line 38
Quoted 5 lines
mm/sparse.c +1
-1-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);Is this a needed-for-2.6.17 fix?
I'll let Arnd answer. He ran into this when doing some Cell work. Not sure where in the development cycle the code is that exposes this bug.
Signature · 1 line
Mike
Quoted 3 lines
I'll let Arnd answer. He ran into this when doing some Cell work. Not sure where in the development cycle the code is that exposes this bug.
I want that too for some other unrelated patches :) I want request_irq() to use alloc_bootmem when slab is not available so that some low level arch irqs can be requested at init_IRQ() time.
(Typically IRQs for cascaded controllers). We currently define statically irqaction structures for them and call setup_irq() on them, this is gross :)
Cheers,
Ben.
Quoted 6 lines · Mike Kravetz
Quoted 2 lines · Andrew Morton
Is this a needed-for-2.6.17 fix?
I'll let Arnd answer. He ran into this when doing some Cell work. Not sure where in the development cycle the code is that exposes this bug.
The code in 2.6.17 breaks when spufs is non-modular. Currently, this is a compile-time option so users can work around it by building spufs as a loadable module.
For 2.6.18, we want to make the part of spufs that calls this non-modular in order to avoid adding further EXPORT_SYMBOLs. I would much prefer to have the fix in 2.6.17 already, but we could alternatively force spufs to be a loadable module in 2.6.17 and change it later.
Arnd <><
mm/slab.c static enum { · line 704
Quoted 8 lines · Mike Kravetz
mm/slab.c +8
-0+/* +* used by boot code to determine if it can use slab based allocator +*/ +int slab_is_available (void ) +{ +return g_cpucache_up ==FULL ; +} +
Please use proper kerneldoc format so you don't create extra work for janitors.
Pekka