The x86-64 memory mapping scheme is defined in arch/x86/mm/mmap.c. As you can see, two strategies are used: top to bottom and bottom to top.
Top-down distribution by default. It starts with 128 MB below the maximum stack length (as determined by the riffit stack), is configured with a random offset, and then allocates subsequent mappings down in memory from there.
Highlighting the bottom is a reserve. It is used if:
- Unlimited stack size
- The process has a set
ADDR_COMPAT_LAYOUT; or vm.legacy_va_layout sysctl is nonzero.
, TASK_SIZE / 3, . TASK_SIZE x86-64 0x800000000000, 0x2AAAAAAAAAAA.
, 2 * TASK_SIZE / 3 - 0x500000000000.