Interleave a process's memory across nodes with numactl --interleave=all
Run a program under numactl --interleave=all so its pages spread round-robin over every NUMA node, and confirm the policy took effect.
A large shared structure, such as an in-memory index read by threads on every socket, can overload one node's memory controller if first-touch placement puts all of it there. Interleaving spreads its pages round-robin across the nodes, so the bandwidth is shared out evenly.
numactl --interleave=all ./myserverYou can check that the policy applies by asking numactl to show what a child process inherits:
numactl --interleave=all numactl --showOn a two-node machine the first lines read:
policy: interleave
preferred node: 0 (interleave next)
interleavemask: 0 1The remaining lines list the allowed CPUs and memory nodes, and they depend on the machine.
The policy is inherited by child processes and applies to pages allocated after it is set, so wrap the program that allocates, not a launcher script that starts it later without the policy. Interleaving is the right default when access is spread across all threads. It is the wrong choice when each thread works on its own data: there the better placement is local, with --cpunodebind and --membind on one node, because interleaving makes half of the accesses remote.
The options are described in numactl(8). Under systemd, the same policy can be set in a unit with NUMAPolicy=interleave and NUMAMask=.