Thank you Christos and Joerg! On Tue, Apr 12, 2022 at 10:26 PM Christos Zoulas <chris...@astron.com> wrote: > > In article <YlV0WgcFGhH/v...@bec.de>, Joerg Sonnenberger <jo...@bec.de> > wrote: > > >>> I would look into porting the FreeBSD implementation of sendfile to > >>> NetBSD. >
I had a look at the FreeBSD implementation. What I found was- - linux_sendfile() function in freebsd-src/sys/compat/linux/linux_socket.c ends up calling linux_sendfile_common() (in the same file) which in turn calls fo_sendfile(). I am guessing, this is supported by sendfile(2) syscall which is present in the FreeBSD kernel. - Therefore in case the implementation just needs to be ported, then it would make for a very simple project. > > >> sendfile(2) for Linux compat can be emulated in the kernel without > >> backing. Joerg, would you please explain to me how this will be possible? As I understand, anything in the compat layer needs backing functions, and I didn't find anything pertaining to sendfile(2) as a syscall in the NetBSD kernel. Or maybe you are talking about using in-kernel support functions, which would have been used to support sendfile(2) had it been present? In this case, I guess, these functions support zero-copy and it will be great if you could point me to them. > > That said, a real splice(2) or even splicev(2) would be really > >> nice to have. But that's a different project and arguable, a potentially > >> more generally useful one, too. > > > > > Yes, splice is more general (as opposed to send a file to a socket), but I > > think splice has limitations too (one of the fds needs to be a pipe). > > Is that true only for linux? > splice(2) for sure is an amazing project, and as Christos said, splice(2) requires one of the fds to be a pipe. Given that splice is only implemented in linux (from what I found), we can have a slightly different implementation in the NetBSD kernel according to requirements (if allowed). I haven't found sendfile(2) or splice(2) syscall in the NetBSD kernel. I did find a reference to sendfile(), but that was for the tftp daemon. It will make an interesting project, to add support for these calls in the NetBSD kernel first. Later these very syscalls can back functionality for the linux compat layer as well. What I wish to know is, what other zero-copy functionality is already present in the NetBSD kernel, which can support these two system calls. I hope this makes some sense and please do correct me where I have made a wrong assumption. Hope to hear from you soon -- Regards, Piyush