__alloc_bootmem_node should not panic when it fails
PATCH 1/1 __alloc_bootmem_node should not panic when it fails
__alloc_bootmem_node currently panics if it cant satisfy an allocation for a particular node. Thats rather antisocial, we should at the very least return NULL and allow the caller to proceed (eg try another node).
A quick look at alloc_bootmem_node usage suggests we should fall back to allocating from other nodes if it fails (as arch/alpha/kernel/pci_iommu.c and arch/x86_64/kernel/setup64.c do).
The following patch does that. We fall back to the regular __alloc_bootmem when __alloc_bootmem_node fails, which means all other nodes are checked for available memory.
mm/bootmem.c renamed from mm/bootmem.c~debugit +1 -6
@@ -371,11 +371,6 @@ void * __init __alloc_bootmem_node (pg_dif (ptr)return (ptr); -/* -* Whoops, we cannot satisfy the allocation request. -*/ -printk (KERN_ALERT "bootmem alloc of %lu bytes failed!\n" , size); -panic ("Out of memory" ); -return NULL ; +return __alloc_bootmem (size, align, goal); }
_
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 3 lines · Anton Blanchard
The following patch does that. We fall back to the regular
__alloc_bootmemwhen__alloc_bootmem_nodefails, which means all other nodes are checked for available memory.
But allocating from other nodes has performance implications, which might be quite big, depending on the specific architecture. So you should at least print an KERN_INFO or even KERN_WARNING message, if this happens.
mm/bootmem.c void * __init __alloc_bootmem_node (pg_d · line 377
Quoted 13 lines
Signed-off-by Anton Blanchard <[email protected]>diff -puN
mm/bootmem.c~debugitmm/bootmem.cmm/bootmem.c renamed from mm/bootmem.c~debugit +0
-4@@ -371,11 +371,6 @@ void * __init __alloc_bootmem_node (pg_dif (ptr)return (ptr); -/* -* Whoops, we cannot satisfy the allocation request. -*/ -printk (KERN_ALERT "bootmem alloc of %lu bytes failed!\n" , size);
Maybe changing this message to:
printk(KERN_WARNING "Failed to alloc %lu bytes from local node.\n" " Allocating from distant node instead. Performance may drop!\n", size);
mm/bootmem.c void * __init __alloc_bootmem_node (pg_d · line 375
Quoted 4 lines
mm/bootmem.c renamed from mm/bootmem.c~debugit +1
-2-panic ("Out of memory" ); -return NULL ; +return __alloc_bootmem (size, align, goal); }
So now the user knows what is going on and that this node might need more memory ;-)
Regards
Ingo Oeser
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFA3mjOU56oYWuOrkARAuQGAJ9lasSDYLgMDzAGnGYxnH4OpSHXNQCg0uy3 12GFsxYaaptUIZkYHYUw9Is=
=1ydw
-----END PGP SIGNATURE-----
Quoted 5 lines
But allocating from other nodes has performance implications, which might be quite big, depending on the specific architecture. So you should at least print an
KERN_INFOor evenKERN_WARNINGmessage, if this happens.
...
Quoted 2 lines
So now the user knows what is going on and that this node might need more memory ;-)
Unfortunately nodes without memory is relatively common on ppc64, and I believe x86-64. From a ppc64 perspective Im fine with best effort, perhaps someone from the heavily NUMA camp (ia64?) could comment.
Anton
Quoted 4 lines · Anton Blanchard
Unfortunately nodes without memory is relatively common on ppc64, and I believe x86-64. From a ppc64 perspective Im fine with best effort, perhaps someone from the heavily NUMA camp (ia64?) could comment.
Does anyone make ia64 NUMA hardware where you can have memory-less nodes?
--cw
Quoted 11 lines · Chris Wedgwood
Quoted 6 lines · Anton Blanchard
Unfortunately nodes without memory is relatively common on ppc64, and I believe x86-64. From a ppc64 perspective Im fine with best effort, perhaps someone from the heavily NUMA camp (ia64?) could comment.
Quoted 8 lines
Does anyone make ia64 NUMA hardware where you can have memory-less nodes?
--cw
HP ships IA64 NUMA hardware where the default memory configuration is memory-less. There are N-1 cpu-nodes and 1 memory node.
Bob
Quoted 9 lines · Chris Wedgwood
Quoted 4 lines · Anton Blanchard
Unfortunately nodes without memory is relatively common on ppc64, and I believe x86-64. From a ppc64 perspective Im fine with best effort, perhaps someone from the heavily NUMA camp (ia64?) could comment.
Does anyone make ia64 NUMA hardware where you can have memory-less nodes?
Altix SN2 can have memoryless nodes
mh
Signature · 2 lines
Martin Hicks Wild Open Source Inc. [email protected] 613-266-2296