Subject: Re: Request for comments: sharing memory between user/kernel space
To: Zeljko Vrba <zvrba@globalnet.hr>
From: Allen Briggs <briggs@netbsd.org>
List: tech-kern
Date: 03/21/2007 09:18:36
On Wed, Mar 21, 2007 at 09:13:09AM +0100, Zeljko Vrba wrote:
> That's what I assumed.  Is TCP receive also 0-copy?

0-copy TCP receive is somewhat problematic.  Usually, you want a stream
of data, but that data is broken up on the wire into ethernet frames
that have essentially arbitrary headers and for which the payload is
rarely, if ever, page-sized and page-aligned (even if you're using
jumbo frames, cleverly aligned), and they can come in out of order.
And interspersed in the TCP stream are other packets--other TCP packets,
UDP packets, non-IP, etc.

So, without a rather intelligent NIC and associated driver, I don't
see a 0-copy rx that makes sense over current ethernet technology--
perhaps you have something else in mind...  Even with an intelligent
NIC, it's not 0-copy--it's just 0-kernel-copy--the NIC has to do the
assembly and copy for you.

Now...  0-copy disk/network I/O is more interesting in the kernel,
because the kernel-native structures for handling network data are
mbuf chains--which have the scatter/gather information you want for
this.  Getting it to a disk just requires massaging it properly for
the disk's descriptors.  And transmit is similar--read from the disk
and create mbuf chains that point into the read buffers.

So it sounds to me like you kind of want a kernel application instead
of a userspace application.

-allen

-- 
Allen Briggs  |  http://www.ninthwonder.com/~briggs/  |  briggs@ninthwonder.com