__get_free_pages can allocate up to 4 MB, distributed by distribution size.
Thus, you can select two 4 MB blocks, each of which is aligned to 4 MB.
You cannot align 8MB in this way.
At boot time, if you allocate 3 * 4 MB, it is very likely that the blocks will be contiguous, so either the first, second, or second and third will be aligned at 8 MB. But I would not rely on it.
Please note that you must do this earlier at boot time, anyway. Otherwise, it is very likely that the memory is fragmented and you cannot get your memory.
source share