From owner-freebsd-arch Sat Mar 17 9:18:35 2001 Delivered-To: freebsd-arch@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id A111337B719 for ; Sat, 17 Mar 2001 09:18:31 -0800 (PST) (envelope-from des@ofug.org) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.3) id SAA73983; Sat, 17 Mar 2001 18:18:29 +0100 (CET) (envelope-from des@ofug.org) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Maxime Henrion Cc: arch@FreeBSD.org Subject: Re: Proposal for a new syscall References: <20010317164411.A420@nebula.cybercable.fr> <20010317173444.B420@nebula.cybercable.fr> From: Dag-Erling Smorgrav Date: 17 Mar 2001 18:18:28 +0100 In-Reply-To: Maxime Henrion's message of "Sat, 17 Mar 2001 17:34:44 +0100" Message-ID: Lines: 48 User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Maxime Henrion writes: > Dag-Erling Smorgrav wrote: > > You don't seem to understand what funopen() really does... > I think I do, since I already used it successfully. Look at how it is > used in libfetch (AFAIK, you are the author of libfetch, I'm not sure > if you wrote this part though), Yes, I did. If you read that code you'll see it does a *lot* more than just pumping data from one file to another. > it's given a read function to read the > socket and a write function that will then write this into a file, and > this is used to download a file. This has absolutely nothing to do with zero-copy anything. The reader function doesn't need to be backed by a file - it can do *anything* it wants, even return a constant stream of "Maxime Henrion doesn't know what funopen() is for" :) > > > Having > > > such a syscall in the kernel would allow to implement "zero-copy" > > > wherever it is feasible. > > No. It would save you two copies and a bunch of syscalls, but it > > wouldn't be real zero-copy, just "n-2 copy" instead of "n copy". > And if n == 2 ? It's never the case. I think the best you can do in userland is n = 3, from a device to a file or socket, or from a file or socket to a device, by using mmap(2) on one side (can't do it on both - you have to mmap one device and write its contents to a file, or read from a file into an mmapped device). In the general case (file to file, file to socket, socket to file, socket to socket) the best you can do, even with mmap(), is n = 4. > > > Then, sendfile() would just be a particular case of this syscall, where > > > the input fd is a file and the output fd is a socket, and it could be > > > rewritten using it. > > No. Have you looked at the sendfile() code? > Probably not enough ; however I don't understand why it wouldn't be > possible to write a more generic function than sendfile() dealing with > any type of file descriptors that sendfile() could call then. It's not impossible, but it'd be a lot of work and it wouldn't be zero-copy. DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message