linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add slab_is_available() routine for boot code
@ 2006-05-10 20:55 Mike Kravetz
  2006-05-10 22:50 ` Andrew Morton
  2006-05-11  6:15 ` Pekka J Enberg
  0 siblings, 2 replies; 6+ messages in thread
From: Mike Kravetz @ 2006-05-10 20:55 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Pekka J Enberg, Christoph Lameter, Dave Hansen, linux-kernel

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>

diff -Naupr linux-2.6.17-rc3-mm1/include/linux/slab.h linux-2.6.17-rc3-mm1.work3/include/linux/slab.h
--- linux-2.6.17-rc3-mm1/include/linux/slab.h	2006-05-03 22:19:15.000000000 +0000
+++ linux-2.6.17-rc3-mm1.work3/include/linux/slab.h	2006-05-10 19:15:20.000000000 +0000
@@ -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
--- linux-2.6.17-rc3-mm1/mm/slab.c	2006-05-03 22:19:16.000000000 +0000
+++ linux-2.6.17-rc3-mm1.work3/mm/slab.c	2006-05-10 21:43:08.000000000 +0000
@@ -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,
diff -Naupr linux-2.6.17-rc3-mm1/mm/sparse.c linux-2.6.17-rc3-mm1.work3/mm/sparse.c
--- linux-2.6.17-rc3-mm1/mm/sparse.c	2006-05-03 22:19:16.000000000 +0000
+++ linux-2.6.17-rc3-mm1.work3/mm/sparse.c	2006-05-10 19:15:56.000000000 +0000
@@ -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);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add slab_is_available() routine for boot code
  2006-05-10 20:55 [PATCH] add slab_is_available() routine for boot code Mike Kravetz
@ 2006-05-10 22:50 ` Andrew Morton
  2006-05-10 23:00   ` Mike Kravetz
  2006-05-11  6:15 ` Pekka J Enberg
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2006-05-10 22:50 UTC (permalink / raw)
  To: Mike Kravetz; +Cc: penberg, clameter, haveblue, linux-kernel

Mike Kravetz <kravetz@us.ibm.com> wrote:
>
> 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>
> 
> diff -Naupr linux-2.6.17-rc3-mm1/include/linux/slab.h linux-2.6.17-rc3-mm1.work3/include/linux/slab.h
> --- linux-2.6.17-rc3-mm1/include/linux/slab.h	2006-05-03 22:19:15.000000000 +0000
> +++ linux-2.6.17-rc3-mm1.work3/include/linux/slab.h	2006-05-10 19:15:20.000000000 +0000
> @@ -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
> --- linux-2.6.17-rc3-mm1/mm/slab.c	2006-05-03 22:19:16.000000000 +0000
> +++ linux-2.6.17-rc3-mm1.work3/mm/slab.c	2006-05-10 21:43:08.000000000 +0000
> @@ -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 ;)

>  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
> --- linux-2.6.17-rc3-mm1/mm/sparse.c	2006-05-03 22:19:16.000000000 +0000
> +++ linux-2.6.17-rc3-mm1.work3/mm/sparse.c	2006-05-10 19:15:56.000000000 +0000
> @@ -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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add slab_is_available() routine for boot code
  2006-05-10 22:50 ` Andrew Morton
@ 2006-05-10 23:00   ` Mike Kravetz
  2006-05-11  3:07     ` Benjamin Herrenschmidt
  2006-05-11 12:40     ` Arnd Bergmann
  0 siblings, 2 replies; 6+ messages in thread
From: Mike Kravetz @ 2006-05-10 23:00 UTC (permalink / raw)
  To: Andrew Morton, Arnd Bergmann; +Cc: penberg, clameter, haveblue, linux-kernel

On Wed, May 10, 2006 at 03:50:26PM -0700, Andrew Morton wrote:
> Mike Kravetz <kravetz@us.ibm.com> wrote:
> > diff -Naupr linux-2.6.17-rc3-mm1/mm/sparse.c linux-2.6.17-rc3-mm1.work3/mm/sparse.c
> > --- linux-2.6.17-rc3-mm1/mm/sparse.c	2006-05-03 22:19:16.000000000 +0000
> > +++ linux-2.6.17-rc3-mm1.work3/mm/sparse.c	2006-05-10 19:15:56.000000000 +0000
> > @@ -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?

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.

-- 
Mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add slab_is_available() routine for boot code
  2006-05-10 23:00   ` Mike Kravetz
@ 2006-05-11  3:07     ` Benjamin Herrenschmidt
  2006-05-11 12:40     ` Arnd Bergmann
  1 sibling, 0 replies; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2006-05-11  3:07 UTC (permalink / raw)
  To: Mike Kravetz
  Cc: Andrew Morton, Arnd Bergmann, penberg, clameter, haveblue, linux-kernel


> 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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add slab_is_available() routine for boot code
  2006-05-10 20:55 [PATCH] add slab_is_available() routine for boot code Mike Kravetz
  2006-05-10 22:50 ` Andrew Morton
@ 2006-05-11  6:15 ` Pekka J Enberg
  1 sibling, 0 replies; 6+ messages in thread
From: Pekka J Enberg @ 2006-05-11  6:15 UTC (permalink / raw)
  To: Mike Kravetz; +Cc: Andrew Morton, Christoph Lameter, Dave Hansen, linux-kernel

On Wed, 10 May 2006, Mike Kravetz wrote:
> +/*
> + * 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add slab_is_available() routine for boot code
  2006-05-10 23:00   ` Mike Kravetz
  2006-05-11  3:07     ` Benjamin Herrenschmidt
@ 2006-05-11 12:40     ` Arnd Bergmann
  1 sibling, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2006-05-11 12:40 UTC (permalink / raw)
  To: Mike Kravetz; +Cc: Andrew Morton, penberg, clameter, haveblue, linux-kernel

On Thursday 11 May 2006 01:00, Mike Kravetz wrote:
> On Wed, May 10, 2006 at 03:50:26PM -0700, Andrew Morton wrote:
> >
> > 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 <><

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-05-11 12:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-10 20:55 [PATCH] add slab_is_available() routine for boot code Mike Kravetz
2006-05-10 22:50 ` Andrew Morton
2006-05-10 23:00   ` Mike Kravetz
2006-05-11  3:07     ` Benjamin Herrenschmidt
2006-05-11 12:40     ` Arnd Bergmann
2006-05-11  6:15 ` Pekka J Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).