Skip to content

Commit

Permalink
memblock: Fix size aligning of memblock_alloc_base_nid()
Browse files Browse the repository at this point in the history
memblock allocator aligns @SiZe to @align to reduce the amount
of fragmentation.  Commit:

 7bd0b0f ("memblock: Reimplement memblock allocation using reverse free area iterator")

Broke it by incorrectly relocating @SiZe aligning to
memblock_find_in_range_node().  As the aligned size is not
propagated back to memblock_alloc_base_nid(), the actually
reserved size isn't aligned.

While this increases memory use for memblock reserved array,
this shouldn't cause any critical failure; however, it seems
that the size aligning was hiding a use-beyond-allocation bug in
sparc64 and losing the aligning causes boot failure.

The underlying problem is currently being debugged but this is a
proper fix in itself, it's already pretty late in -rc cycle for
boot failures and reverting the change for debugging isn't
difficult. Restore the size aligning moving it to
memblock_alloc_base_nid().

Reported-by: Meelis Roos <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Grant Likely <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Andrew Morton <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
LKML-Reference: <[email protected]>
  • Loading branch information
htejun authored and Ingo Molnar committed Mar 1, 2012
1 parent 88ebdda commit 847854f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t start,
phys_addr_t this_start, this_end, cand;
u64 i;

/* align @size to avoid excessive fragmentation on reserved array */
size = round_up(size, align);

/* pump up @end */
if (end == MEMBLOCK_ALLOC_ACCESSIBLE)
end = memblock.current_limit;
Expand Down Expand Up @@ -731,6 +728,9 @@ static phys_addr_t __init memblock_alloc_base_nid(phys_addr_t size,
{
phys_addr_t found;

/* align @size to avoid excessive fragmentation on reserved array */
size = round_up(size, align);

found = memblock_find_in_range_node(0, max_addr, size, align, nid);
if (found && !memblock_reserve(found, size))
return found;
Expand Down

0 comments on commit 847854f

Please sign in to comment.