Understanding Zone Reclaim Mode in Linux NUMA

Zone reclaim mode in a Non-Uniform Memory Access (NUMA) Linux system controls whether the kernel reclaims local memory or allocates from remote nodes when a specific NUMA node runs low on free pages. This setting directly balances the trade-off between memory access latency and CPU overhead, defining how aggressively the operating system prioritizes NUMA locality over immediate allocation speed.

The Role of Zone Reclaim in NUMA Systems

In a NUMA architecture, physical memory is partitioned across multiple nodes, each directly attached to a specific CPU socket. A CPU accessing its local memory experiences minimal latency, whereas accessing memory on a remote socket over interconnect buses (such as Intel UPI or AMD Infinity Fabric) incurs a noticeable latency penalty.

When a process requests memory on a node that lacks free pages, the Linux kernel faces two choices:

  1. Reclaim local memory: Evict cached data, write back dirty pages, or swap to free space on the local node to preserve memory locality.
  2. Allocate remotely: Immediately satisfy the request using available free memory from a neighbor node, avoiding the delay of page reclamation at the cost of higher subsequent access latencies.

The vm.zone_reclaim_mode sysctl parameter dictates this decision.

Configuration Values and Behaviors

The vm.zone_reclaim_mode parameter is configured via a bitmask that specifies which operations the kernel is permitted to perform to free local pages:

These flags can be combined. For example, a value of 3 enables clean page cache reclamation and dirty page writebacks, while 7 enables all reclamation methods including swapping.

Performance Implications

Enabling zone reclaim mode creates a significant risk of execution stalls. While accessing local memory reduces memory bus latency, the process of scanning zones, shrinking caches, and writing to disk consumes significant CPU cycles and introduces direct reclaim latency.

Inspecting and Modifying Zone Reclaim

To check the current zone reclaim configuration:

sysctl vm.zone_reclaim_mode

To set the value dynamically without rebooting (for example, disabling it):

sysctl -w vm.zone_reclaim_mode=0

To make the setting permanent, append vm.zone_reclaim_mode = 0 to /etc/sysctl.conf or an appropriate file in /etc/sysctl.d/.