mbind
TLDR
Set NUMA policy for memory range (C code)
$ mbind([addr], [length], MPOL_BIND, [&nodemask], [maxnode], 0)
Bind memory to specific node$ mbind([ptr], [size], MPOL_BIND, [&mask], [maxnode], MPOL_MF_MOVE)
Interleave memory across nodes$ mbind([addr], [len], MPOL_INTERLEAVE, [&nodemask], [maxnode], 0)
SYNOPSIS
long mbind(void *addr, unsigned long len, int mode, const unsigned long *nodemask, unsigned long maxnode, unsigned flags)
DESCRIPTION
mbind is a system call that sets the NUMA memory policy for a specified memory range. It controls which NUMA nodes are used for memory allocation within that range.
This is used for performance optimization on NUMA systems by controlling memory locality.
PARAMETERS
addr
Starting address of memory range.len
Length of memory range.mode
MPOLDEFAULT, MPOLBIND, MPOLINTERLEAVE, MPOLPREFERRED.nodemask
Bitmask of NUMA nodes.maxnode
Maximum node number + 1.flags
MPOLMFSTRICT, MPOLMFMOVE, MPOLMFMOVE_ALL.
POLICIES
$ MPOL_DEFAULT - Use process default
MPOL_BIND - Strict binding to nodes
MPOL_INTERLEAVE - Round-robin across nodes
MPOL_PREFERRED - Prefer specified node
MPOL_BIND - Strict binding to nodes
MPOL_INTERLEAVE - Round-robin across nodes
MPOL_PREFERRED - Prefer specified node
CAVEATS
Requires NUMA hardware. Only affects future allocations unless flags specify migration. Privileged flags may require CAPSYSNICE.
HISTORY
mbind was added to Linux kernel 2.6.7 as part of NUMA memory policy support, developed primarily by Andi Kleen at SUSE.
SEE ALSO
set_mempolicy(2), get_mempolicy(2), numactl(8), numa(7)


