Skip to content

Commit f6bc87c

Browse files
ARM64: mm: Restore memblock limit when map_mem finished.
In paging_init the memblock limit is set to restrict any addresses returned by early_alloc to fit within the initial direct kernel mapping in swapper_pg_dir. This allows map_mem to allocate puds, pmds and ptes from the initial direct kernel mapping. The limit stays low after paging_init() though, meaning any bootmem allocations will be from a restricted subset of memory. Gigabyte huge pages, for instance, are normally allocated from bootmem as their order (18) is too large for the default buddy allocator (MAX_ORDER = 11). This patch restores the memblock limit when map_mem has finished, allowing gigabyte huge pages (and other objects) to be allocated from all of bootmem. Signed-off-by: Steve Capper <steve.capper@linaro.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent dfa5e23 commit f6bc87c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

arch/arm64/mm/mmu.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,16 @@ static void __init map_mem(void)
297297
{
298298
struct memblock_region *reg;
299299

300+
/*
301+
* Temporarily limit the memblock range. We need to do this as
302+
* create_mapping requires puds, pmds and ptes to be allocated from
303+
* memory addressable from the initial direct kernel mapping.
304+
*
305+
* The initial direct kernel mapping, located at swapper_pg_dir,
306+
* gives us PGDIR_SIZE memory starting from PHYS_OFFSET (aligned).
307+
*/
308+
memblock_set_current_limit((PHYS_OFFSET & PGDIR_MASK) + PGDIR_SIZE);
309+
300310
/* map all the memory banks */
301311
for_each_memblock(memory, reg) {
302312
phys_addr_t start = reg->base;
@@ -307,6 +317,9 @@ static void __init map_mem(void)
307317

308318
create_mapping(start, __phys_to_virt(start), end - start);
309319
}
320+
321+
/* Limit no longer required. */
322+
memblock_set_current_limit(MEMBLOCK_ALLOC_ANYWHERE);
310323
}
311324

312325
/*
@@ -317,12 +330,6 @@ void __init paging_init(void)
317330
{
318331
void *zero_page;
319332

320-
/*
321-
* Maximum PGDIR_SIZE addressable via the initial direct kernel
322-
* mapping in swapper_pg_dir.
323-
*/
324-
memblock_set_current_limit((PHYS_OFFSET & PGDIR_MASK) + PGDIR_SIZE);
325-
326333
init_mem_pgprot();
327334
map_mem();
328335

0 commit comments

Comments
 (0)