diff options
author | Johannes Weiner <[email protected]> | 2012-05-29 15:06:34 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2012-05-29 16:22:21 -0700 |
commit | ab3818432294a19ad793a0965d89867b4ce6255b (patch) | |
tree | 1cffc6d97b2735b9ce776874e02b35adfc890e5e | |
parent | c12ab504aa6076d1f1d37ee32431608ed11a1c3b (diff) |
mm: bootmem: allocate in order node+goal, goal, node, anywhere
Match the nobootmem version of __alloc_bootmem_node. Try to satisfy both
the node and the goal, then just the goal, then just the node, then
allocate anywhere before panicking.
Signed-off-by: Johannes Weiner <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Acked-by: David S. Miller <[email protected]>
Cc: Yinghai Lu <[email protected]>
Cc: Gavin Shan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | mm/bootmem.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/mm/bootmem.c b/mm/bootmem.c index bafeb2c171c7..b5babdfb9ef8 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c @@ -704,6 +704,7 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, { void *ptr; +again: ptr = alloc_arch_preferred_bootmem(bdata, size, align, goal, limit); if (ptr) return ptr; @@ -712,7 +713,18 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, if (ptr) return ptr; - return ___alloc_bootmem(size, align, goal, limit); + ptr = alloc_bootmem_core(size, align, goal, limit); + if (ptr) + return ptr; + + if (goal) { + goal = 0; + goto again; + } + + printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size); + panic("Out of memory"); + return NULL; } /** |