pub struct UmemSlab { /* private fields */ }Expand description
Dedicated per-core / per-queue UMEM chunk slab for lock-free AF_XDP multi-worker scaling.
Each UmemSlab manages an isolated, non-overlapping range of UMEM chunk addresses
allocated from a parent UmemPool. Worker threads allocate and recycle chunks
locally from their dedicated slab without cross-core coordination, atomic locks,
or MESI cache-line invalidation.
Implementations§
Source§impl UmemSlab
impl UmemSlab
Sourcepub fn base_addr(&self) -> u64
pub fn base_addr(&self) -> u64
Base memory address offset of this slab within the parent UMEM area.
Sourcepub fn end_addr(&self) -> u64
pub fn end_addr(&self) -> u64
Upper non-inclusive address boundary of this slab within the parent UMEM area.
Sourcepub fn num_chunks(&self) -> usize
pub fn num_chunks(&self) -> usize
Total number of chunks assigned to this slab.
Sourcepub fn total_chunks(&self) -> usize
pub fn total_chunks(&self) -> usize
Total number of chunks assigned to this slab (alias for num_chunks).
Sourcepub fn free_chunk_count(&self) -> usize
pub fn free_chunk_count(&self) -> usize
Number of free chunks currently available in this slab.
Sourcepub fn chunk_size(&self) -> usize
pub fn chunk_size(&self) -> usize
Chunk size in bytes.
Sourcepub fn contains_addr(&self, addr: u64) -> bool
pub fn contains_addr(&self, addr: u64) -> bool
Returns true if addr is an aligned chunk address belonging to this slab.
Sourcepub fn contains_addr_range(&self, addr: u64, len: usize) -> bool
pub fn contains_addr_range(&self, addr: u64, len: usize) -> bool
Returns true if addr..addr+len lies completely within this slab’s memory range.
Sourcepub fn alloc_chunk(&mut self) -> Option<u64>
pub fn alloc_chunk(&mut self) -> Option<u64>
Allocates a chunk address from this slab, returning None if exhausted.
Sourcepub fn free_chunk(&mut self, addr: u64)
pub fn free_chunk(&mut self, addr: u64)
Returns a chunk address to this slab’s free pool.
Sourcepub fn alloc_batch(&mut self, out: &mut [u64]) -> usize
pub fn alloc_batch(&mut self, out: &mut [u64]) -> usize
Allocates up to out.len() chunk addresses into out. Returns count allocated.
Sourcepub fn free_batch(&mut self, addrs: &[u64])
pub fn free_batch(&mut self, addrs: &[u64])
Frees a slice of chunk addresses back to this slab.
Sourcepub fn populate_fill_ring(
&mut self,
fill_ring: &mut FillRing,
max_count: usize,
) -> usize
pub fn populate_fill_ring( &mut self, fill_ring: &mut FillRing, max_count: usize, ) -> usize
Pre-populates a FillRing with chunks from this slab up to max_count.
Allocates in batches of 64 chunks to maximize memory pipeline throughput. Returns the total number of chunks enqueued into the fill ring.
Sourcepub fn recycle_from_rings(
&mut self,
comp_ring: &mut CompletionRing,
fill_ring: &mut FillRing,
max_batch: usize,
) -> usize
pub fn recycle_from_rings( &mut self, comp_ring: &mut CompletionRing, fill_ring: &mut FillRing, max_batch: usize, ) -> usize
Recycles completed chunk descriptors from CompletionRing directly back into FillRing.
Consumes up to max_batch descriptors from comp_ring and attempts to produce them
directly into fill_ring. Any surplus chunks that do not fit into fill_ring are
returned to this slab’s free pool without heap allocations.
Returns the total number of completed descriptors consumed from comp_ring.