Skip to content

Commit

Permalink
mm: nobootmem: panic on node-specific allocation failure
Browse files Browse the repository at this point in the history
__alloc_bootmem_node and __alloc_bootmem_low_node documentation claims
the functions panic on allocation failure.  Do it.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: David S. Miller <davem@davemloft.net>
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>
  • Loading branch information
Johannes Weiner authored and Linus Torvalds committed May 29, 2012
1 parent 421456e commit 2c478ea
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions mm/nobootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,17 @@ void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,

ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
goal, -1ULL);
if (!ptr && goal) {
if (ptr)
return ptr;

if (goal) {
goal = 0;
goto again;
}
return ptr;

printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
panic("Out of memory");
return NULL;
}

void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
Expand Down Expand Up @@ -407,6 +413,12 @@ void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
if (ptr)
return ptr;

return __alloc_memory_core_early(MAX_NUMNODES, size, align,
goal, ARCH_LOW_ADDRESS_LIMIT);
ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
goal, ARCH_LOW_ADDRESS_LIMIT);
if (ptr)
return ptr;

printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
panic("Out of memory");
return NULL;
}

0 comments on commit 2c478ea

Please sign in to comment.