[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Mbufs stored in RX queues
garg.vineet1%gmail.com@localhost (vineet garg) writes:
>I would understand that initial buffer allocations are there to
>prevent buf allocation in data path. So, the packet should be read
>into a buffer from pool and returned to pool when upper layer returns
>it. In case pool is empty in worst case, then we should allocate a new
>buf. but is that a real situation? can't we handle that by optimizing
>the size of pool to ensure that chances of running out of buffers in
>pool reduces a lot....
- you first allocate one or more buffers
- then you arm the hardware to use these buffers for incoming packets
- the hardware interrupts you when one or more buffers are filled
- the interrupt routine allocates new buffers as a replacement
- the interrupt routine passes the filled buffers up to the protocol layer
- the interrupt routine arms the hardware to use the new buffers
You need at least one buffer for the hardware in advance. It cannot
receive a packet without such a buffer.
If the allocation of new buffers fails, there is little you can do
but drop the incoming data and reuse the old buffer. For some hardware
you could reduce the number of receive buffers instead until there
is only one buffer left. But if there is really an mbuf shortage,
this will happen so quickly that there is no advantage.
Things are different with network hardware that has its own
private receive buffers. But with modern hardware the 'private
buffer' is mostly just an on-chip FIFO and often smaller than
a single packet. All incoming packets are delivered directly
to the preallocated mbufs.
Michael van Elst
"A potential Snark may lurk in every tree."
Main Index |
Thread Index |