memory hotplug: fix early allocation handling
Subsystems (2)
PATCH 1/1 memory hotplug: fix early allocation handling
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.
--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
@@ -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 {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 32 lines · Heiko Carstens
From: Heiko Carstens <[email protected]>
Trying to add memory via
add_memory()from within an initcall function results inbootmem alloc of 163840 bytes failed!
Kernel panic - not syncing: Out of memoryThis is caused by
zone_wait_table_init()which usessystem_stateto decide if it should use the bootmem allocator or not. When initcalls are handled thesystem_stateis stillSYSTEM_BOOTINGbut 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 <[email protected]>Cc Dave Hansen <[email protected]>Cc Gerald Schaefer <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>Cc Yasunori Goto <[email protected]>Signed-off-by Heiko Carstens <[email protected]>--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
linux-2.6/mm/page_alloc.c
===================================================================
mm/page_alloc.c int zone_wait_table_init(struct zone *zo · line 2810
Quoted 8 lines
mm/page_alloc.c +1
-1@@ -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.
-apw
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Looks good to me.
Thanks.
Quoted 40 lines
From: Heiko Carstens <[email protected]>
Trying to add memory via
add_memory()from within an initcall function results inbootmem alloc of 163840 bytes failed!
Kernel panic - not syncing: Out of memoryThis is caused by
zone_wait_table_init()which usessystem_stateto decide if it should use the bootmem allocator or not. When initcalls are handled thesystem_stateis stillSYSTEM_BOOTINGbut 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 <[email protected]>Cc Dave Hansen <[email protected]>Cc Gerald Schaefer <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>Cc Yasunori Goto <[email protected]>Signed-off-by Heiko Carstens <[email protected]>--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
linux-2.6/mm/page_alloc.c
===================================================================mm/page_alloc.c +1
-1@@ -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 {
Signature · 8 lines
Yasunori Goto -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>