Starting my study of Linux's early initialization of its memory management, the 1st subroutine here prepares the "HugeTLB CMA". On CPUs which support it.
After a little validation it does so by asking CPU-specific how much it should allocate & validates the answer, transfers (via a helper) from an array* to a large bitmask, iterates over that bitmask validating it, validates that its size, ...
1/?
*Presumably populated by the CPU-specific I failed to follow.
... possibly rounds up pool size for each individual CPU's heap space, iterates over bitmask validating each entry & carefully allocates (via a helper, & more in turn) those NUMA nodes some memory using one of several techniques, & validates that this has reserved some memory.
Or it does something like that, this is my best understanding of v7.1.3.
I'm not digging into that allocation logic. It is interesting but it is a massive rabbithole!
2/2 Fin for today! Tomorrow: HugeTLB bootmem.