The patch titled Subject: mm/hugetlb: avoid hardcoding while checking if cma is enabled has been removed from the -mm tree. Its filename was mm-hugetlb-avoid-hardcoding-while-checking-if-cma-is-enable.patch This patch was dropped because an updated version will be merged ------------------------------------------------------ From: Barry Song <song.bao.hua@xxxxxxxxxxxxx> Subject: mm/hugetlb: avoid hardcoding while checking if cma is enabled hugetlb_cma[0] can be NULL due to various reasons, for example, node0 has no memory. so NULL hugetlb_cma[0] doesn't necessarily mean cma is not enabled. gigantic pages might have been reserved on other nodes. Mike Kravetz said: : Based on the code changes, I believe the following could happen: : - Someone uses 'hugetlb_cma=' kernel command line parameter to reserve : CMA for gigantic pages. : - The system topology is such that no memory is on node 0. Therefore, : no CMA can be reserved for gigantic pages on node 0. CMA is reserved : on other nodes. : - The user also specifies a number of gigantic pages to pre-allocate on : the command line with hugepagesz=<gigantic_page_size> hugepages=<N> : - The routine which allocates gigantic pages from the bootmem allocator : will not detect CMA has been reserved as there is no memory on node 0. : Therefore, pages will be pre-allocated from bootmem allocator as well : as reserved in CMA. : : This double allocation (bootmem and CMA) is the worst case scenario. Not : sure if this is what Barry saw, and I suspect this would rarely happen. Link: http://lkml.kernel.org/r/20200707040204.30132-1-song.bao.hua@xxxxxxxxxxxxx Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma") Signed-off-by: Barry Song <song.bao.hua@xxxxxxxxxxxxx> Acked-by: Roman Gushchin <guro@xxxxxx> Acked-by: Mike Rapoport <rppt@xxxxxxxxxxxxx> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Cc: Jonathan Cameron <jonathan.cameron@xxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/hugetlb.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/mm/hugetlb.c~mm-hugetlb-avoid-hardcoding-while-checking-if-cma-is-enable +++ a/mm/hugetlb.c @@ -2546,6 +2546,20 @@ static void __init gather_bootmem_preall } } +bool __init hugetlb_cma_enabled(void) +{ +#ifdef CONFIG_CMA + int node; + + for_each_online_node(node) { + if (hugetlb_cma[node]) + return true; + } +#endif + + return false; +} + static void __init hugetlb_hstate_alloc_pages(struct hstate *h) { unsigned long i; @@ -2571,7 +2585,7 @@ static void __init hugetlb_hstate_alloc_ for (i = 0; i < h->max_huge_pages; ++i) { if (hstate_is_gigantic(h)) { - if (IS_ENABLED(CONFIG_CMA) && hugetlb_cma[0]) { + if (hugetlb_cma_enabled()) { pr_warn_once("HugeTLB: hugetlb_cma is enabled, skip boot time allocation\n"); break; } _ Patches currently in -mm which might be from song.bao.hua@xxxxxxxxxxxxx are mm-hugetlb-split-hugetlb_cma-in-nodes-with-memory.patch mm-cma-fix-the-name-of-cma-areas.patch mm-hugetlb-fix-the-name-of-hugetlb-cma.patch mm-hugetlb-avoid-hardcoding-while-checking-if-cma-is-enabled.patch