public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Phillip Susi <psusi@cfl.rr.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: bcrl@kvack.org, drepper@gmail.com, da-x@monatomic.org,
	linux-kernel@vger.kernel.org
Subject: Re: Status of AIO
Date: Mon, 06 Mar 2006 23:07:05 -0500	[thread overview]
Message-ID: <440D06E9.1020901@cfl.rr.com> (raw)
In-Reply-To: <20060306.190428.23731173.davem@davemloft.net>

David S. Miller wrote:
> You didn't google hard enough, my blog entry on the topic
> comes up as the first entry when you google for "Van Jacobson
> net channels".
> 

Thanks, I read the page... I find it to be a little extreme, and zero 
copy aio can get the same benefits without all that hassle.  Let me 
write this as a reply to the article itself:


> With SMP systems this "end host" concept really should be extended to
> the computing entities within the system, that being cpus and threads
> within the box.


I agree; all threads and cpus should be able to concurrently process 
network IO, and without wasting cpu cycles copying the data around 6 
times.  That does not, and should not mean moving the TCP/IP protocol to 
user space.


> So, given all that, how do you implement network packet receive
> properly? Well, first of all, you stop doing so much work in interrupt
> (both hard and soft) context. Jamal Hadi Salim and others understood
> this quite well, and NAPI is a direct consequence of that understanding.
> But what Van is trying to show in his presentation is that you can take
> this further, in fact a _lot_ further.


I agree; a minimum of work should be done in interrupt context. 
Specifically the interrupt handler should simply insert and remove 
packets from the queue and program the hardware registers for DMA access 
to the packet buffer memory.  If the hardware supports scatter/gather 
DMA, then the upper layers can enqueue packet buffers to send/recieve 
into/from and the interrupt handler just pulls packets off this queue 
when the hardware raises an interrupt to indicate it has completed the 
DMA transfer.


This is how NT and I believe BSD have been doing things for some time 
now, and the direction the Linux kernel is moving in.

> A Van Jacobson channel is a path for network packets. It is
> implemented as an array'd queue of packets. There is state for the
> producer and the consumer, and it all sits in different cache lines so
> that it is never the case that both the consumer and producer write to
> shared cache lines. Network cards want to know purely about packets, yet
> for years we've been enforcing an OS determined model and abstraction
> for network packets upon the drivers for such cards. This has come in
> the form of "mbufs" in BSD and "SKBs" under Linux, but the channels are
> designed so that this is totally unnecessary. Drivers no longer need to
> know about what the OS packet buffers look like, channels just contain
> pointers to packet data.

I must admit, I am a bit confused by this.  It sounds a lot like the pot 
calling the kettle black to me.  Aren't SKBs and mbufs already just a 
form of the very queue of packets being advocated here?  Don't they 
simply list memory ranges for the driver to transfer to the nic as a 
packet?

> The next step is to build channels to sockets. We need some
> intelligence in order to map packets to channels, and this comes in the
> form of a tiny packet classifier the drivers use on input. It reads the
> protocol, ports, and addresses to determine the flow ID and uses this to
> find a channel. If no matching flow is found, we fall back to the basic
> channel we created in the first step. As sockets are created, channel
> mappings are installed and thus the driver classifier can find them
> later. The socket wakes up, and does protocol input processing and
> copying into userspace directly out of the channel.

How is this any different from what we have now, other than bypassing 
the kernel buffer?  The tcp/ip layer looks at the incoming packet to 
decide what socket it goes with, and copies it to the waiting buffer. 
Right now that waiting buffer is a kernel buffer, because at the time 
the packet arrives, the kernel does not have any user buffers.

If the user process uses aio though, it can hand the kernel a few 
buffers to receive into ahead of time so when the packets have been 
classified, they can be copied directly to the user buffer.

> And in the next step you can have the socket ask for a channel ID
> (with a getsockopt or something like that), have it mmap() a receive
> ring buffer into user space, and the mapped channel just tosses the
> packet data into that mmap()'d area and wakes up the process. The
> process has a mini TCP receive engine in user space.

There is no need to use mmap() and burden the user code with 
implementing TCP itself ( which is quite a lot of work ).  It can hand 
the kernel buffers by queuing multiple O_DIRECT aio requests and the 
kernel can directly dump the data stream there after stripping off the 
headers.  When sending it can program the hardware to directly 
scatter/gather DMA from the user buffer attached to the aio request.

> And you can take this even further than that (think, remote systems).
> At each stage Van presents a table of profiled measurements for a normal
> bulk TCP data transfer. The final stage of channeling all the way to
> userspace is some 6 times faster than what we're doing today, yes I said
> 6 times faster that isn't a typo.


Yes, we can and should have a 6 times speed up, but as I've explained 
above, NT has had that for 10 years without having to push TCP into user 
space.


  reply	other threads:[~2006-03-07  4:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-06  6:24 Status of AIO Dan Aloni
2006-03-06 15:05 ` Phillip Susi
2006-03-06 21:18 ` Benjamin LaHaise
2006-03-06 22:53   ` Ulrich Drepper
2006-03-06 23:15     ` Phillip Susi
2006-03-08  7:09       ` Ulrich Drepper
2006-03-08 15:58         ` Phillip Susi
2006-03-06 23:33     ` Benjamin LaHaise
2006-03-07  0:24       ` David S. Miller
2006-03-07  0:42         ` Benjamin LaHaise
2006-03-07  0:51           ` David S. Miller
2006-03-07  1:39             ` Benjamin LaHaise
2006-03-07  2:04               ` Dan Aloni
2006-03-07  2:07                 ` Benjamin LaHaise
2006-03-07  3:11                   ` David S. Miller
2006-03-07  7:33                   ` Dan Aloni
2006-03-07  3:06               ` David S. Miller
2006-03-07 16:35                 ` Benjamin LaHaise
2006-03-07  1:34         ` Phillip Susi
2006-03-07  3:04           ` David S. Miller
2006-03-07  4:07             ` Phillip Susi [this message]
2006-03-07  6:02               ` David S. Miller
2006-03-07 16:06                 ` Phillip Susi
2006-03-07  1:30   ` Dan Aloni
2006-03-07  1:37     ` Nicholas Miell
2006-03-07  1:37     ` Phillip Susi
2006-03-07  1:40     ` Benjamin LaHaise
2006-03-06 23:18 ` Phillip Susi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=440D06E9.1020901@cfl.rr.com \
    --to=psusi@cfl.rr.com \
    --cc=bcrl@kvack.org \
    --cc=da-x@monatomic.org \
    --cc=davem@davemloft.net \
    --cc=drepper@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox