aboutsummaryrefslogtreecommitdiffstats
path: root/mm/bootmem.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2012-05-29 18:06:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-29 19:22:21 -0400
commitab3818432294a19ad793a0965d89867b4ce6255b (patch)
tree1cffc6d97b2735b9ce776874e02b35adfc890e5e /mm/bootmem.c
parentc12ab504aa6076d1f1d37ee32431608ed11a1c3b (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 <hannes@cmpxchg.org> Acked-by: Tejun Heo <tj@kernel.org> Acked-by: David S. Miller <davem@davemloft.net> Cc: Yinghai Lu <yinghai@kernel.org> Cc: Gavin Shan <shangw@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/bootmem.c')
-rw-r--r--mm/bootmem.c14
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,
704{ 704{
705 void *ptr; 705 void *ptr;
706 706
707again:
707 ptr = alloc_arch_preferred_bootmem(bdata, size, align, goal, limit); 708 ptr = alloc_arch_preferred_bootmem(bdata, size, align, goal, limit);
708 if (ptr) 709 if (ptr)
709 return ptr; 710 return ptr;
@@ -712,7 +713,18 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
712 if (ptr) 713 if (ptr)
713 return ptr; 714 return ptr;
714 715
715 return ___alloc_bootmem(size, align, goal, limit); 716 ptr = alloc_bootmem_core(size, align, goal, limit);
717 if (ptr)
718 return ptr;
719
720 if (goal) {
721 goal = 0;
722 goto again;
723 }
724
725 printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
726 panic("Out of memory");
727 return NULL;
716} 728}
717 729
718/** 730/**