The Pidfd Store is an internal CRIU mechanism used during iterative migration to reliably identify processes across multiple pre-dump iterations. It leverages the Linux kernel’s pidfd interface to eliminate the risks associated with PID reuse.
In an iterative migration workflow, CRIU performs multiple pre-dump operations. Each iteration captures memory pages that have changed since the previous snapshot. To do this safely, CRIU must ensure that it is still talking to the exact same process it was in the previous iteration.
If a process dies between iterations and the kernel assigns its old PID to a new, unrelated process, a naive check based only on the PID would fail to detect this change. Performing an incremental dump on a new process using the state of an old one would lead to corrupted images and a failed restoration.
The Pidfd Store allows CRIU to maintain a persistent, race-free handle for every process in the tree.
During the first pre-dump, CRIU calls pidfd_open() for every task it captures. Unlike a numeric PID, a pidfd is a file descriptor that refers to a specific process instance. If that process terminates, its pidfd becomes invalid and will never refer to a subsequent process, even if the numeric PID is reused.
CRIU often operates as a service, receiving commands via RPC. To keep pidfds alive between independent RPC calls, CRIU uses a clever “socket trick”:
SCM_RIGHTS mechanism.In each subsequent pre-dump or the final dump command:
The Pidfd Store requires modern kernel features (automatically detected via Kerndat):
pidfd_open() (Kernel v5.3+)pidfd_getfd() (Kernel v5.6+, used to transfer the storage socket between service components).