[PATCH V3] ARM: mm: restrict early_alloc to section-aligned memory

Stephen Warren swarren at wwwdotorg.org
Tue Jul 16 18:12:17 EDT 2013


On 07/10/2013 12:43 PM, Stephen Warren wrote:
> From: Russell King <rmk at arm.linux.org.uk>
> 
> When map_lowmem() runs, and processes a memory bank whose start or end
> is not section-aligned, memory must be allocated to store the 2nd-level
> page tables. Those allocations are made by calling memblock_alloc().
> 
> At this point, the only memory that is free *and* mapped is memory which
> has already been mapped by map_lowmem() itself. For this reason, we must
> calculate the first point at which map_lowmem() will need to allocate
> memory, and set the memblock allocation limit to a lower address, so that
> memblock_alloc() is guaranteed to return memory that is already mapped.
> 
> This patch enhances sanity_check_meminfo() to calculate that memory
> address, and pass it to memblock_set_current_limit(), rather than just
> assuming the limit is arm_lowmem_limit.
> 
> The algorithm applied is:
> 
> * Default memblock_limit to arm_lowmem_limit in the absence of any other
>   limit; arm_lowmem_limit is the highest memory that is mapped by
>   map_lowmem().
> 
> * While walking the list of memblocks, if the start of a block is not
>   aligned, 2nd-level page tables will need to be allocated to map the
>   first few pages of the block. Hence, the memblock_limit must be before
>   the start of the block.
> 
> * Similarly, if the end of any block is not aligned, 2nd-level page
>   tables will need to be allocated to map the last few pages of the
>   block. Hence, the memblock_limit must point at the end of the block,
>   rounded down to section-alignment.
> 
> * The memory blocks are assumed to be sorted in address order, so the
>   first unaligned block start or end is used to set the limit.
> 
> With this algorithm, the start or end of almost any bank can be non-
> section-aligned. The only exception is that the start of bank 0 must
> be section-aligned, since otherwise memory would need to be allocated
> when mapping the start of bank 0, which occurs before any free memory
> is mapped.
> 
> Not-yet-signed-off-by: Russell King <rmk at arm.linux.org.uk>
> [swarren, wrote commit description, rewrote calculation of memblock_limit]
> Signed-off-by: Stephen Warren <swarren at nvidia.com>
> ---
> V3: completely new implementation based on Russell's suggestion.
> 
> Russell, since this is strongly based on your patch, I set you as the
> author in git. I assume that's OK. If not, let me know and I'll change
> the patch to my authorship and add a note to the commit description
> that it's based on your original.

Russell, should I assume that no comment implies this is OK and I should
send it to the ARM patch tracker?



More information about the linux-arm-kernel mailing list