Subject: Re: CVS commit: syssrc/sys/net
To: Atsushi Onoe <onoe@sm.sony.co.jp>
From: None <itojun@iijlab.net>
List: tech-net
Date: 09/30/2002 16:46:05
>>   I ask because it seems like mbufs whose reference/dereference
>>   implementation can be overridden open interesting opportunities for
>>   optimization.  For example, if you have some NIC whose receive buffer
>>   is mapped into the host's virtual memory, then a driver can hand up
>>   an mbuf which points into the NIC's receive buffer. The mbuf has a
>>   special 'free' method assigned, which indicates to the NIC that the
>>   mbuf's range in the receive buffer is eligible for re-use. In this way,
>>   you avoid a copy to the host's memory.
>> 
>>   Is this optimization too complicated to consider?
>
>The problem is we have no way to force release the receive buffer once
>the corresponding mbuf is passed into the stack.  The mbuf can be left
>referenced long time in socket if the application doesn't read or even
>suspended.  To handle shortage of free receiving buffer, the driver
>implementation should take care of allocate other mbuf cluster.
>
>And much headache would be considering fragmentation.  If the hardware
>fills data in manner of one buffer per packet, it can handled easier,
>though the efficiency in usage is not so good.  If the hardware fills
>data continuously among packets, the fragmentation in buffer is serious.
>Again, there is no way to collect garbage in the unit smaller than page.

	see sys/pci/if_{ti,bge}.c, they use ext_free in an interesting way.

itojun