Subject: Re: Socket Buffers and Memory Managment

From: Roy Pledge <[email-masked]>
Date: Wed, 18 Jul 2007 13:13:21 -0400

Stephen Hemminger wrote:
> 
> You could play tricks with skb frags but it would be fragile
> and not worth the trouble. The problem is that the receive
> skb can stay in the system for a really long time (until the application
> reads the data) so your fixed size buffer pool in hardware
> would get exhausted.
>  
Perhaps you could elaborate on why this is considered fragile?  It seems to me 
that as long as proper page management is performed, this mechanism should be 
stable for processing non-contiguous receive buffers.  I agree that 
replenishment needs to be addressed, but I see that as an independent issue from 
using frag lists on receive.

>> Also, if the h/w gives me a single packet in multiple
>> locations (i.e. non-contiguous chunks of memory), can
>> socket buffers handle chains of buffers?  I am looking
>> for a facility like mbuf's in netbsd where one can
>> chain multiple buffers together to make construct a
>> single packet.
> 
> Yes, skb frag list could be used for that but you don't
> want to do that. See above. Copy the data into an new
> skb and reserve any necessary bytes so IP header is
> aligned.  I.e. if using ethernet header (14 bytes), do
> skb_reserve(skb, 2) before copying the data.

But isn't avoiding the copy the point of all this?  With some hardware models 
using skbs as receive buffers is inconvenient and can be wasteful if jumbo 
frames are required.  Wouldn't a mechanism where it is possible to create (or 
populate) an skb from data in a pre existing buffer without copying be more 
general and address more hardware models?  It seems to me that more and more 
hardware is supporting scatter/gather output for received data, but the page* 
model in the frag list can be restrictive in how data is placed before being 
passed into the stack.

Thanks

Roy