linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory hotplug: fix early allocation handling
@ 2008-05-20 10:51 Heiko Carstens
  2008-05-20 14:48 ` Andy Whitcroft
  2008-05-21  7:29 ` Yasunori Goto
  0 siblings, 2 replies; 3+ messages in thread
From: Heiko Carstens @ 2008-05-20 10:51 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andy Whitcroft, Dave Hansen, Gerald Schaefer, KAMEZAWA Hiroyuki,
	Yasunori Goto, linux-mm, linux-kernel

From: Heiko Carstens <heiko.carstens@de.ibm.com>

Trying to add memory via add_memory() from within an initcall function
results in

bootmem alloc of 163840 bytes failed!
Kernel panic - not syncing: Out of memory

This is caused by zone_wait_table_init() which uses system_state to
decide if it should use the bootmem allocator or not.
When initcalls are handled the system_state is still SYSTEM_BOOTING
but the bootmem allocator doesn't work anymore. So the allocation
will fail.

To fix this use slab_is_available() instead as indicator like we do
it everywhere else.

Cc: Andy Whitcroft <apw@shadowen.org>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 mm/page_alloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c
+++ linux-2.6/mm/page_alloc.c
@@ -2804,7 +2804,7 @@ int zone_wait_table_init(struct zone *zo
 	alloc_size = zone->wait_table_hash_nr_entries
 					* sizeof(wait_queue_head_t);
 
- 	if (system_state == SYSTEM_BOOTING) {
+ 	if (!slab_is_available()) {
 		zone->wait_table = (wait_queue_head_t *)
 			alloc_bootmem_node(pgdat, alloc_size);
 	} else {

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

* Re: [PATCH] memory hotplug: fix early allocation handling
  2008-05-20 10:51 [PATCH] memory hotplug: fix early allocation handling Heiko Carstens
@ 2008-05-20 14:48 ` Andy Whitcroft
  2008-05-21  7:29 ` Yasunori Goto
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Whitcroft @ 2008-05-20 14:48 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Andrew Morton, Dave Hansen, Gerald Schaefer, KAMEZAWA Hiroyuki,
	Yasunori Goto, linux-mm, linux-kernel

On Tue, May 20, 2008 at 12:51:45PM +0200, Heiko Carstens wrote:
> From: Heiko Carstens <heiko.carstens@de.ibm.com>
> 
> Trying to add memory via add_memory() from within an initcall function
> results in
> 
> bootmem alloc of 163840 bytes failed!
> Kernel panic - not syncing: Out of memory
> 
> This is caused by zone_wait_table_init() which uses system_state to
> decide if it should use the bootmem allocator or not.
> When initcalls are handled the system_state is still SYSTEM_BOOTING
> but the bootmem allocator doesn't work anymore. So the allocation
> will fail.
> 
> To fix this use slab_is_available() instead as indicator like we do
> it everywhere else.
> 
> Cc: Andy Whitcroft <apw@shadowen.org>
> Cc: Dave Hansen <haveblue@us.ibm.com>
> Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
>  mm/page_alloc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux-2.6/mm/page_alloc.c
> ===================================================================
> --- linux-2.6.orig/mm/page_alloc.c
> +++ linux-2.6/mm/page_alloc.c
> @@ -2804,7 +2804,7 @@ int zone_wait_table_init(struct zone *zo
>  	alloc_size = zone->wait_table_hash_nr_entries
>  					* sizeof(wait_queue_head_t);
>  
> - 	if (system_state == SYSTEM_BOOTING) {
> + 	if (!slab_is_available()) {
>  		zone->wait_table = (wait_queue_head_t *)
>  			alloc_bootmem_node(pgdat, alloc_size);
>  	} else {

It would be nice to be able to check that bootmem is enabled separatly
from whether slab is available, as I am sure there is a time where
neither is available during the change over.  But the change looks
reasonable as we cannot use vmalloc until slab is working.

Reviewed-by: Andy Whitcroft <apw@shadowen.org>

-apw

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

* Re: [PATCH] memory hotplug: fix early allocation handling
  2008-05-20 10:51 [PATCH] memory hotplug: fix early allocation handling Heiko Carstens
  2008-05-20 14:48 ` Andy Whitcroft
@ 2008-05-21  7:29 ` Yasunori Goto
  1 sibling, 0 replies; 3+ messages in thread
From: Yasunori Goto @ 2008-05-21  7:29 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Andrew Morton, Andy Whitcroft, Dave Hansen, Gerald Schaefer,
	KAMEZAWA Hiroyuki, linux-mm, linux-kernel

Looks good to me.

Thanks.

Acked-by: Yasunori Goto <y-goto@jp.fujitsu.com>



> From: Heiko Carstens <heiko.carstens@de.ibm.com>
> 
> Trying to add memory via add_memory() from within an initcall function
> results in
> 
> bootmem alloc of 163840 bytes failed!
> Kernel panic - not syncing: Out of memory
> 
> This is caused by zone_wait_table_init() which uses system_state to
> decide if it should use the bootmem allocator or not.
> When initcalls are handled the system_state is still SYSTEM_BOOTING
> but the bootmem allocator doesn't work anymore. So the allocation
> will fail.
> 
> To fix this use slab_is_available() instead as indicator like we do
> it everywhere else.
> 
> Cc: Andy Whitcroft <apw@shadowen.org>
> Cc: Dave Hansen <haveblue@us.ibm.com>
> Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
> ---
>  mm/page_alloc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux-2.6/mm/page_alloc.c
> ===================================================================
> --- linux-2.6.orig/mm/page_alloc.c
> +++ linux-2.6/mm/page_alloc.c
> @@ -2804,7 +2804,7 @@ int zone_wait_table_init(struct zone *zo
>  	alloc_size = zone->wait_table_hash_nr_entries
>  					* sizeof(wait_queue_head_t);
>  
> - 	if (system_state == SYSTEM_BOOTING) {
> + 	if (!slab_is_available()) {
>  		zone->wait_table = (wait_queue_head_t *)
>  			alloc_bootmem_node(pgdat, alloc_size);
>  	} else {

-- 
Yasunori Goto 



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

end of thread, other threads:[~2008-05-21  7:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-20 10:51 [PATCH] memory hotplug: fix early allocation handling Heiko Carstens
2008-05-20 14:48 ` Andy Whitcroft
2008-05-21  7:29 ` Yasunori Goto

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