Skip to content

Commit

Permalink
mm: nobootmem: Correct alloc_bootmem semantics.
Browse files Browse the repository at this point in the history
The comments above __alloc_bootmem_node() claim that the code will
first try the allocation using 'goal' and if that fails it will
try again but with the 'goal' requirement dropped.

Unfortunately, this is not what the code does, so fix it to do so.

This is important for nobootmem conversions to architectures such
as sparc where MAX_DMA_ADDRESS is infinity.

On such architectures all of the allocations done by generic spots,
such as the sparse-vmemmap implementation, will pass in:

	__pa(MAX_DMA_ADDRESS)

as the goal, and with the limit given as "-1" this will always fail
unless we add the appropriate fallback logic here.

Signed-off-by: David S. Miller <[email protected]>
Acked-by: Yinghai Lu <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
davem330 authored and torvalds committed Apr 26, 2012
1 parent af3a3ab commit 4e1c2b2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mm/nobootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,19 @@ void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
if (WARN_ON_ONCE(slab_is_available()))
return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);

again:
ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
goal, -1ULL);
if (ptr)
return ptr;

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

void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
Expand Down

0 comments on commit 4e1c2b2

Please sign in to comment.