Re: [PATCH 0/3] vmsplice: make vmsplice a trivial wrapper for preadv2/pwritev2
From: Askar Safin <hidden>
Date: 2026-06-03 22:43:22
Also in:
linux-fsdevel, linux-mm, linux-patches, lkml, netdev
Andy Lutomirski [off-list ref]:
Maybe we should keep an API that does an optimized copy, from one fd to another, that can send from a file to the network with at most ONE cpu-side copy. Not aiming for zero like sendfile / splice. Aiming for one.
Yes, this is what my hypothetical future patch will do. One copy from pagecache to pipe, and then network uses that buffer directly.
But splice_to_socket involves MSG_SPLACE_PAGES, which I think is a part of the mess that you dislike. And the path where one does copy_splice_read and then splice_to_socket has to be a bit complex because of tee and (I think) because splice_to_socket cannot assume that the incoming data is just ordinary unshared buffers.
My future patch will provide new guarantee: pipe buffers are always stable, i. e. they will not be externally-modified. So hopefully network code will be adjusted to use this guarantee. But pipe buffers will not be "ordinary unshared buffers". They still may be shared with other things because of tee(2). (But they are still stable! They will not be randomly modified!) But network code can do "pipe_buf_try_steal" and thus ensure that these buffers are not shared with anything else. So, network code can be modified to use "pipe_buf_try_steal", and you will get "ordinary unshared buffers" exactly as you want. This will give you in total exactly one copy. Also: as well as I understand, previously, pipe_buf_try_steal was kind of lie. It may return true for buffers created via vmsplice with GIFT. (I did not check this, but I think so.) I. e. pipe_buf_try_steal will return "true" in this case, but pages are still shared! But, thanks to my vmsplice patchset (which is already applied), this is no longer true! So now pipe_buf_try_steal is absolutely safe to use! Finally, we can degrade tee(2) to copy, and hopefully this will allow us to always be sure that pipe buffers are not shared with anything. This is possible future direction. -- Askar Safin