Re: [PATCH 0/3] vmsplice: make vmsplice a trivial wrapper for preadv2/pwritev2
From: Andrei Vagin <hidden>
Date: 2026-06-23 17:29:26
Also in:
fuse-devel, linux-fsdevel, linux-mm, linux-patches, lkml, netdev
On Tue, Jun 23, 2026 at 2:42 AM Askar Safin [off-list ref] wrote:
Andrei Vagin [off-list ref]:quoted
Actually, this change introduces a performance and functional regression for CRIU. Here is a brief overview of how CRIU currently dumps memory pages: CRIU injects a parasite code blob into the target process's address space. The parasite invokes vmsplice() with the SPLICE_F_GIFT flag to pin physical pages directly inside a pipe without copying them. The main CRIU process then takes over from outside the target context, calling splice() on the other end of the pipe to stream the data directly into checkpoint image files or a remote network socket. I ran a simple test that creates an anonymous mapping and touches every page within it: Without this patch, CRIU takes 9 seconds to dump the test process. With this patch, It takes 18 seconds... Plus, it obviously introduces some memory overhead. If these changes are merged, we will need to completely rework the memory dumping mechanism in CRIU. Using vmsplice() in this proposed form no longer makes any sense for our architecture...I just have read some docs for CRIU. I found this statement:quoted
#### Why `splice` is Better: * **Consistency via COW**: The `SPLICE_F_GIFT` flag ensures that if the process modifies a "gifted" page after resuming, the kernel performs a **Copy-on-Write (COW)**. The pipe buffer > continues to hold the *original* version of the page as it existed at the moment of the `vmsplice()` call, ensuring a perfectly consistent snapshot of that page.This is wrong (with released kernels). I confirmed this by testing this on my current kernel (6.12.90). See the code in the end of this message. If you actually rely on mentioned consistency, then, it seems, CRIU is broken. So, in fact, my patch actually brings consistency to CRIU. :)
Askar, unfortunately, the statement about "Consistency via COW" is just "AI imagination". The under-the-hood docs were recently transferred from the criu.org wiki using some AI transformations, which introduced this wrong statement. The original document can be found here: https://criu.org/Memory_dumping_and_restoring. To clarify, CRIU does not rely on page consistency for intermediate pre-dumps. The pre-dump mechanism is designed to be iterative: During a pre-dump, tasks are briefly frozen to vmsplice dirty pages into pipes. Then the tasks are resumed, and CRIU drains the pipes. If the process modifies a page after it has been spliced, the data in the pipe may become inconsistent. However, any such modification is tracked by the soft-dirty page tracker. In the next pre-dump iteration (or the final dump), these modified pages will be identified as dirty again and re-dumped. During restore, the images are applied sequentially, and the final dump (taken while the process is fully frozen) ensures we reconstruct a consistent final state. But what really matters in this scheme is the vmsplice performance. The proposed change significantly slows it down. In the case of CRIU, vmsplice performance is critical because the target process is frozen during these calls. Minimizing the freeze time is the primary goal of pre-dumping to make migration almost invisible to the user workload. Thanks, Andrei