Skip to contentSkip to conversation

add slab_is_available() routine for boot code

PATCH In review Mike Kravetz 5 participants 6 messages May 10, 2006 – May 11, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
diff -Naupr linux-2.6.17-rc3-mm1/include/linux/slab.h linux-2.6.17-rc3-mm1.work3/include/linux/slab.h
@@ -150,6 +150,7 @@ static inline void *kcalloc(size_t n, si
 
 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);
mm/slab.c +8 -0
diff -Naupr linux-2.6.17-rc3-mm1/mm/slab.c linux-2.6.17-rc3-mm1.work3/mm/slab.c
@@ -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
diff -Naupr linux-2.6.17-rc3-mm1/mm/sparse.c linux-2.6.17-rc3-mm1.work3/mm/sparse.c
@@ -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);
#1 lore raw
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.

diff -Naupr linux-2.6.17-rc3-mm1/include/linux/slab.h linux-2.6.17-rc3-mm1.work3/include/linux/slab.h

include/linux/slab.h +1 -0
@@ -150,6 +150,7 @@ static inline void *kcalloc(size_t n, si
 
 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);

diff -Naupr linux-2.6.17-rc3-mm1/mm/slab.c linux-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 -0
 static 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.c linux-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?

#2 lore raw
Quoted 8 lines · Andrew Morton
Quoted 7 lines · Mike Kravetz

diff -Naupr linux-2.6.17-rc3-mm1/mm/sparse.c linux-2.6.17-rc3-mm1.work3/mm/sparse.c

mm/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
#3 lore raw
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.

#4 lore raw
In reply to Mike Kravetz
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 <><
#5 lore raw
In reply to Mike Kravetz

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