public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: How many copies to get from NIC RX to user read()?
@ 2002-07-10 15:52 niv
  2002-07-10 21:15 ` Hurwitz Justin W.
  0 siblings, 1 reply; 7+ messages in thread
From: niv @ 2002-07-10 15:52 UTC (permalink / raw)
  To: hurwitz; +Cc: linux-kernel


> I could've sworn I heard the stack was single-copy 
> on both the TX and RX sides. But, it doesn't look to 
> me like it is. Rather, it looks like there is one copy 
> in tcp_rcv_estabilshed() (via tcp_copy_to_iovec()), and a
> second copy in tcp_recvmsg() (which is called when the 
> user calls read()). Both of these copies are, I believe, 
> done by skb_copy_datagram_iovec().

tcp_recvmsg() only does the copy from the receive_queue
or the backlog queue. tcp_rcv_established() does the copy
directly into the iovec or queues it onto the receive_queue 
or backlog queue for tcp_recvmsg() to complete the work. So 
there arent two copies of the same data happening, just a 
question of one or the other function doing the work depending 
on whether there is currently a process doing a read or not..

hth,

thanks,
Nivedita



^ permalink raw reply	[flat|nested] 7+ messages in thread
* How many copies to get from NIC RX to user read()?
@ 2002-07-09 22:29 Hurwitz Justin W.
  2002-07-09 23:11 ` Alan Cox
  2002-07-10  8:29 ` Matti Aarnio
  0 siblings, 2 replies; 7+ messages in thread
From: Hurwitz Justin W. @ 2002-07-09 22:29 UTC (permalink / raw)
  To: linux-kernel

Please Cc: me in your responses.

The story so far: 

I've been continuing to muck around with the stack, trying both to improve
overall performance, and specifically to improve rx relative to tx
performance, primarily in gig-and-beyond (e.g., Quadrics)  environments.

To this end, I have begun by profiling and analyzing the RX side stack.
The profiling is being done as I write, and the analysis is what prompts
me to write.


The direct question:

How many times is data copied between the time that it is received at the
NIC and when the user's call to read() returns the data?


The reason for the question:

I could've sworn I heard the stack was single-copy on both the TX and RX
sides. But, it doesn't look to me like it is. Rather, it looks like there
is one copy in tcp_rcv_estabilshed() (via tcp_copy_to_iovec()), and a
second copy in tcp_recvmsg() (which is called when the user calls read()).
Both of these copies are, I believe, done by skb_copy_datagram_iovec().


The ancilary questions:

If I am wrong about this- does anyone care to publicly humiliate me by
telling me how/why (and possibly calling me stupid)?

If I am right about this- is there a specific reason that it is
implemented this way? Are there any thoughts on changing it? Our specific
inclination is to keep the skbs around until the user calls read(), at
which point we do an iovec memcopy to the userspace buffer, eliminating a
copy- the danger here is if the user doesn't read from the socket, this
might needlessly lock up skbs. To avoid this, we can implement either some
watermark or timeout for skb-consilidation- if the user doesn't call
read() soon enough or before too many skbs are used we copy the skbs to a
socket buffer like normal.


Cheers,
--Gus


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-07-11  2:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-10 15:52 How many copies to get from NIC RX to user read()? niv
2002-07-10 21:15 ` Hurwitz Justin W.
2002-07-10 21:27   ` Nivedita Singhvi
  -- strict thread matches above, loose matches on Subject: below --
2002-07-09 22:29 Hurwitz Justin W.
2002-07-09 23:11 ` Alan Cox
2002-07-10  8:29 ` Matti Aarnio
2002-07-11  2:12   ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox