Skip to content

Commit

Permalink
mm: bootmem: allocate in order node+goal, goal, node, anywhere
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
hnaz authored and torvalds committed May 29, 2012
1 parent c12ab50 commit ab38184
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mm/bootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit ab38184

Please sign in to comment.