How Linux Manages Persistent Memory (NVDIMM)
This article explores how the Linux operating system integrates and
manages Non-Volatile Dual In-line Memory Modules (NVDIMMs). It covers
the core kernel architecture, specifically the libnvdimm
subsystem, the Direct Access (DAX) mechanism that bypasses standard
caching, the primary device operating modes, and the management tools
used to configure persistent memory for high-performance enterprise
workloads.
The libnvdimm
Subsystem
Linux manages persistent memory primarily through the
libnvdimm kernel subsystem. This framework discovers,
configures, and controls NVDIMMs exposed by system firmware.
During the boot process, the kernel queries the ACPI (Advanced
Configuration and Power Interface) tables—specifically the NVDIMM
Firmware Interface Table (NFIT). The NFIT outlines the physical
topology, memory ranges, and capabilities of the installed modules. The
libnvdimm driver processes this data to generate device
abstractions, representing physical modules as regions that can be
sliced into usable namespaces.
NVDIMM Operating Modes and Namespaces
Linux allows administrators to allocate persistent memory into distinct namespaces depending on the performance requirements and safety guarantees of the target workload.
- FSDAX (Filesystem Direct Access): The default and most common mode. It creates a block device capable of supporting direct memory access via modern filesystems (such as ext4 or XFS).
- DEVDAX (Device Direct Access): Provides raw,
character-device access to persistent memory. This mode bypasses both
the filesystem and the page cache, allowing specialized applications to
directly
mmapranges of persistent memory with zero kernel intervention. - Sector Mode: Designed for legacy applications and standard filesystems that expect traditional block-storage semantics. It utilizes the Block Translation Table (BTT) to provide atomic sector-update guarantees, preventing torn writes during unexpected power loss.
- System RAM (
kmem): Assigns persistent memory directly to the kernel's volatile memory management system. The kernel treats the NVDIMM as an additional, slower tier of regular system RAM rather than non-volatile storage.
Direct Access (DAX)
Traditional storage subsystems in Linux rely heavily on the page
cache, copying data from a storage drive into DRAM before making it
available to applications. Because NVDIMMs are directly accessible on
the memory bus via standard CPU instructions (load and
store), the page cache creates unnecessary latency and
consumes redundant DRAM.
The Linux Direct Access (DAX) mechanism removes this overhead. When an application reads or writes to a DAX-enabled filesystem, the kernel maps the physical persistent memory addresses directly into the process's virtual address space. This bypasses the I/O software stack entirely, delivering byte-addressability and nanosecond-level latency.
Memory Flushing and Data Durability
Operating at the memory bus level changes how data persistence is
guaranteed. Standard dirty-page flushes (fsync) do not
apply to direct memory writes. Instead, Linux relies on specific CPU
instructions to flush data out of CPU caches and write-combining buffers
down to the NVDIMM's non-volatile domain (Asynchronous DRAM Refresh, or
ADR).
Applications interacting with DAX devices use user-space
cache-flushing instructions (such as clwb or
clflushopt on x86-64) followed by a memory barrier
(sfence). This guarantees that data is physically committed
to non-volatile media before the application acknowledges the write as
durable.
User-Space Configuration
with ndctl
System administrators manage persistent memory resources in Linux
using ndctl, the standard user-space utility for the
libnvdimm subsystem. The tool enables users to:
- Enumerate physical NVDIMM modules and health states.
- Aggregate physical modules into interleaved sets called regions.
- Carve regions into namespaces (e.g., configuring
/dev/pmem0for FSDAX or/dev/dax0.0for DEVDAX). - Monitor hardware wear levels, media errors, and lifecycle events.