How does Linux initialize on a specific on a given "sparse node" for its memory allocator?
It 1st defers to another initializer which carefully allocates a dynamic amount of memory or outputs an error message to the log. Then it allocates (via a couple helpers) a dynamic amount of memory for a buffer, compiletime-possibly iterates over the NID's huge-bootpages & carefully considers updating some bitflags, iterates over all present sections, & (via more helpers) cleans up.
1/3?
For each present section Linux extracts the "PFN" (via a bitshifting helper) from the section number, validates the loop var, carefully look ups (via another helper) from some table or other, checks both build flags & a flag on the section, if set allocates (via another helper) a page map with a fallback allocator, propagates any errors cleaning up, atomically sums an allocation counter, & indirectly defers to one of these helpers to set these bitflags.
2/2 Fin on memory-allocator init!