mbuf management facility
The mbuf management facility controls different buffer sizes that can range from 32 bytes up to 16384 bytes.
The pools are created from system memory by making an allocation request to the Virtual Memory Manager (VMM). The pools consist of pinned pieces of kernel virtual memory in which they always reside in physical memory and are never paged out. The result is that the real memory available for paging in application programs and data has been decreased by the amount that the mbuf pools have been increased.
The network memory pool is split evenly among each processor. Each sub-pool is then split up into buckets, with each bucket holding buffers ranging in size from 32 to 16384 bytes. Each bucket can borrow memory from other buckets on the same processor but a processor cannot borrow memory from another processor's network memory pool. When a network service needs to transport data, it can call a kernel service such as m_get() to obtain a memory buffer. If the buffer is already available and pinned, it can get it immediately. If the upper limit has not been reached and the buffer is not pinned, then a buffer is allocated and pinned. Once pinned, the memory stays pinned but can be freed back to the network pool. If the number of free buffers reaches a high-water mark, then a certain number is unpinned and given back to the system for general use. This unpinning is done by the netm() kernel process. The caller of the m_get() subroutine can specify whether to wait for a network memory buffer. If the M_DONTWAIT flag is specified and no pinned buffers are available at that time, a failed counter is incremented. If the M_WAIT flag is specified, the process is put to sleep until the buffer can be allocated and pinned.