Skip to content

Commit 6cf06c1

Browse files
committed
powerpc/mm: Move CMA reservations after initmem_init()
After commit 11ac3e8 ("mm: cma: use pageblock_order as the single alignment") there is an error at boot about the KVM CMA reservation failing, eg: kvm_cma_reserve: reserving 6553 MiB for global area cma: Failed to reserve 6553 MiB That makes it impossible to start KVM guests using the hash MMU with more than 2G of memory, because the VM is unable to allocate a large enough region for the hash page table, eg: $ qemu-system-ppc64 -enable-kvm -M pseries -m 4G ... qemu-system-ppc64: Failed to allocate KVM HPT of order 25: Cannot allocate memory Aneesh pointed out that this happens because when kvm_cma_reserve() is called, pageblock_order has not been initialised yet, and is still zero, causing the checks in cma_init_reserved_mem() against CMA_MIN_ALIGNMENT_PAGES to fail. Fix it by moving the call to kvm_cma_reserve() after initmem_init(). The pageblock_order is initialised in sparse_init() which is called from initmem_init(). Also move the hugetlb CMA reservation. Fixes: 11ac3e8 ("mm: cma: use pageblock_order as the single alignment") Reviewed-by: Aneesh Kumar K.V <[email protected]> Reviewed-by: Zi Yan <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b13bacc commit 6cf06c1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

arch/powerpc/kernel/setup-common.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -935,12 +935,6 @@ void __init setup_arch(char **cmdline_p)
935935
/* Print various info about the machine that has been gathered so far. */
936936
print_system_info();
937937

938-
/* Reserve large chunks of memory for use by CMA for KVM. */
939-
kvm_cma_reserve();
940-
941-
/* Reserve large chunks of memory for us by CMA for hugetlb */
942-
gigantic_hugetlb_cma_reserve();
943-
944938
klp_init_thread_info(&init_task);
945939

946940
setup_initial_init_mm(_stext, _etext, _edata, _end);
@@ -955,6 +949,13 @@ void __init setup_arch(char **cmdline_p)
955949

956950
initmem_init();
957951

952+
/*
953+
* Reserve large chunks of memory for use by CMA for KVM and hugetlb. These must
954+
* be called after initmem_init(), so that pageblock_order is initialised.
955+
*/
956+
kvm_cma_reserve();
957+
gigantic_hugetlb_cma_reserve();
958+
958959
early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
959960

960961
if (ppc_md.setup_arch)

0 commit comments

Comments
 (0)