Re: [PATCH 0/3] vmsplice: make vmsplice a trivial wrapper for preadv2/pwritev2
From: The 8472 <hidden>
Date: 2026-06-05 20:58:01
Also in:
linux-api, linux-fsdevel, linux-mm, linux-patches, lkml
On 04/06/2026 17:58, Linus Torvalds wrote:
On Thu, 4 Jun 2026 at 08:53, Willy Tarreau [off-list ref] wrote:quoted
quoted
It looks like you're actually doing exactly the thing that I thought was crazy and wouldn't even work reliably: you change the common_response[] contents dynamically *after* the vmsplice, and depend on the fact that changing it in user space changes the buffer in the pipe too.No no, it's definitely not doing that (or it's a bug, but it's not supposed to happen). I'm perfectly aware that one must definitely not do that, and it's a guarantee the user of vmsplice() must provide.Whew, good. In that case, can you just try the vmsplice patch series (Christian already found a bug, but I don't think it will necessarily matter in practice - famous last words) and that test patch of mine, and see if it all (a) works for you and (b) if you have any numbers for performance that would be *great*. There aren't many obvious splice users out there, and even if they were to exist they are typically specialized enough that you have to have a real use case to then tell if the patches make a difference in real life or not.
In the Rust standard library we use splice as one of several strategies in our generic io::copy[0] routine. It selects the strategy[1] based on source and sink types. It tries - copy_file_range - sendfile - splice - fallback to userspace read-write loop sendfile or splice are skipped when we can't uphold the "callers must ensure transferred portions in_fd remain unmodified" condition on the manpage, which unfortunately includes some particularly desirable combinations of sinks and sources (such as mutable files -> socket). We primarily want this for reflink copies and to avoid the syscall overhead of a read-write loop with a small stack buffer. Any additional zerocopy benefit, when it doesn't lead to unstable data, is welcome but not critical. E.g. it'd be nice if sendfile could do the following: For a 1MB source and a socket with a 64kB sendbuffer it could zerocopy first ~900kB safely and then memcpy the last 64kB to ensure it can't be modified after the syscall returns. But a "just memcpy in kernel space instead of zerocopy" flag for sendfile would be ok too. We're currently not making use of vmsplice. In theory we'd like to use it for copying from `&'static [u8]` sources since the type upholds the requirements of vmsplice, but type specialization currently is not powerful enough to select based on this lifetime and it's unclear if it'll ever be. [0] https://doc.rust-lang.org/nightly/std/io/fn.copy.html [1] https://github.com/rust-lang/rust/blob/ac6f3a3e778a586854bdbf8f15202e11e2348d9f/library/std/src/sys/io/kernel_copy/linux.rs#L210-L259
So you testing that thing would seem to be a great first test of
whether any of this is realistic..
Linus