chmem
Configure the system's memory
TLDR
Set a memory block offline
Set a memory block online
Set a memory range offline using hexadecimal addresses
Set a memory range online using hexadecimal addresses
Set memory online and assign it to a specific zone (e.g., Movable)
Display help
SYNOPSIS
chmem [options] <pid>
PARAMETERS
--hugepages
Set fixed number of huge pages for the process
--hugepages-min
Set minimum number of huge pages allowed
--hugepages-max
Set maximum number of huge pages allowed
--hugepagesize
Specify huge page size (2M or 1G, default from kernel)
--mpol-default
Set default memory policy
--mpol-prefer
Prefer memory allocation from specific NUMA node
--mpol-bind
Bind allocations to comma-separated list of NUMA nodes
--mpol-interleave
Interleave allocations across NUMA nodes
--mpol-local
Prefer local NUMA node for allocations
--ismemorypolicy
Enable (yes) or disable (no) memory policy enforcement (default: yes)
--help
Display help message
--version
Show version information
DESCRIPTION
chmem is a utility from the util-linux package that modifies the memory policy or huge page allocation settings for a running process. It allows administrators to adjust how a process allocates memory, particularly in NUMA (Non-Uniform Memory Access) systems or when using huge pages for performance optimization.
Huge pages reduce TLB (Translation Lookaside Buffer) overhead by using larger memory pages (e.g., 2MB or 1GB instead of 4KB), improving performance for memory-intensive applications like databases or virtual machines. chmem can set the number of huge pages a process is allowed to use, either as a fixed amount, minimum, or maximum.
Additionally, it supports setting NUMA memory policies, such as preferring local memory, binding to specific nodes, or interleaving across nodes. This is crucial on multi-socket systems where memory access latency varies by node. Policies can be default, prefer, bind, interleave, or local.
The command requires root privileges and operates on a specified PID. Changes apply immediately but may not retroactively affect already allocated memory. It's useful for tuning workloads dynamically without restarting processes. Note that support depends on kernel features like CONFIG_TRANSPARENT_HUGEPAGE and NUMA awareness.
CAVEATS
Requires root privileges; changes may not affect existing allocations; kernel must support huge pages and NUMA policies; invalid options or PID cause failure without warning.
EXAMPLES
chmem --hugepages=1024 1234
Sets 1024 huge pages for PID 1234.
chmem --mpol-prefer=1 --ismemorypolicy=yes 5678
Prefer NUMA node 1 for PID 5678.
HISTORY
Introduced in util-linux 2.27 (2014); enhanced in later versions for better NUMA support and huge page options.


