Re: [PATCH V2] mm/hugetlb: Ensure adequate CMA areas available for hugetlb_cma[]

From: Andrew Morton
Date: Thu Feb 15 2024 - 20:22:40 EST


On Thu, 15 Feb 2024 10:04:05 +0530 Anshuman Khandual <anshuman.khandual@xxxxxxx> wrote:

> HugeTLB CMA area array is being created for possible MAX_NUMNODES without
> ensuring corresponding MAX_CMA_AREAS support in CMA. This fails the build
> for such scenarios indicating need for CONFIG_CMA_AREAS adjustment.
>
> ...
>
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -7743,6 +7743,13 @@ void __init hugetlb_cma_reserve(int order)
> }
>
> reserved = 0;
> +
> + /*
> + * There needs to be enough MAX_CMA_AREAS to accommodate
> + * MAX_NUMNODES heap areas being created here. Otherwise
> + * adjust CONFIG_CMA_AREAS as required.
> + */
> + BUILD_BUG_ON(MAX_CMA_AREAS < MAX_NUMNODES);
> for_each_online_node(nid) {
> int res;

This blew up my x86_64 allmodconfig build. I didn't check whether this
is because x86_64 kconfig is broken or because the test is bogus.

I won't be releasing a kernel which fails x86_64 allmodconfig.

So before adding a new assertion can we please first make a best effort
to implement the fixes which are required to prevent the new assertion
from triggering?