CRIU provides comprehensive support for capturing and reconstructing the various ways processes share memory in Linux. This includes anonymous shared regions, file-backed shared mappings, and System V IPC segments.
CRIU categorizes shared memory into three primary types, each with a dedicated restoration strategy:
Created via mmap(..., MAP_SHARED | MAP_ANONYMOUS, ...), these regions have no persistent backing file on disk but are shared between a parent and its children after a fork(), or between unrelated processes that inherit the mapping.
/proc/$pid/maps. For shared anonymous regions, the kernel assigns a unique internal inode number (often appearing in the inode column of maps). CRIU uses this inode number as a shmid to group and identify identical mappings across the entire process tree.memfd_create() system call to create an anonymous, RAM-backed file.
shmid) creates the memfd, populates it with the memory contents captured in pages-shmem.img, and maps it.memfd file descriptor, ensuring that any subsequent writes are visible to all participants, just as they were before the checkpoint.Created via mmap(..., MAP_SHARED, fd, ...), these regions are backed by a regular file on the filesystem.
mmap() with the MAP_SHARED flag. The Linux kernel’s standard page cache mechanism automatically handles the sharing and synchronization between processes.Managed via the legacy shmget() and shmat() APIs, these segments are part of the kernel’s IPC subsystem.
shmget() with the original parameters and repopulates the data. The restored processes then attach to these segments using shmat(), ensuring that IPC-based communication continues seamlessly.CRIU leverages modern kernel features to handle complex sharing accurately:
KCMP_VM), ensuring that shared resources are only dumped once.