On 5/16/25 11:49, wangtao wrote:
Please try using udmabuf with sendfile() as confirmed to be working by
T.J.
[wangtao] Using buffer IO with dmabuf file read/write requires one
memory copy.
Direct IO removes this copy to enable zero-copy. The sendfile system call reduces memory copies from two (read/write) to one. However, with udmabuf, sendfile still keeps at least one copy, failing zero-copy.
Then please work on fixing this.
[wangtao] What needs fixing? Does sendfile achieve zero-copy? sendfile reduces memory copies (from 2 to 1) for network sockets, but still requires one copy and cannot achieve zero copies.
Well why not? See sendfile() is the designated Linux uAPI for moving data between two files, maybe splice() is also appropriate.
The memory file descriptor and your destination file are both a files. So those uAPIs apply.
Now what you suggest is to add a new IOCTL to do this in a very specific manner just for the system DMA-buf heap. And as far as I can see that is in general a complete no-go.
I mean I understand why you do this. Instead of improving the existing functionality you're just hacking something together because it is simple for you.
It might be possible to implement that generic for DMA-buf heaps if udmabuf allocation overhead can't be reduced, but that is then just the second step.
Regards, Christian.