Skip to main content

UmemSlab

Struct UmemSlab 

Source
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

Source

pub fn slab_id(&self) -> usize

Slab identifier (e.g. core ID or queue ID).

Source

pub fn base_addr(&self) -> u64

Base memory address offset of this slab within the parent UMEM area.

Source

pub fn end_addr(&self) -> u64

Upper non-inclusive address boundary of this slab within the parent UMEM area.

Source

pub fn num_chunks(&self) -> usize

Total number of chunks assigned to this slab.

Source

pub fn total_chunks(&self) -> usize

Total number of chunks assigned to this slab (alias for num_chunks).

Source

pub fn free_chunk_count(&self) -> usize

Number of free chunks currently available in this slab.

Source

pub fn chunk_size(&self) -> usize

Chunk size in bytes.

Source

pub fn pool(&self) -> &Arc<UmemPool> ⓘ

Reference to the parent UmemPool.

Source

pub fn contains_addr(&self, addr: u64) -> bool

Returns true if addr is an aligned chunk address belonging to this slab.

Source

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.

Source

pub fn alloc_chunk(&mut self) -> Option<u64>

Allocates a chunk address from this slab, returning None if exhausted.

Source

pub fn free_chunk(&mut self, addr: u64)

Returns a chunk address to this slab’s free pool.

Source

pub fn alloc_batch(&mut self, out: &mut [u64]) -> usize

Allocates up to out.len() chunk addresses into out. Returns count allocated.

Source

pub fn free_batch(&mut self, addrs: &[u64])

Frees a slice of chunk addresses back to this slab.

Source

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.

Source

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.

Source

pub fn chunk_slice(&self, addr: u64, len: usize) -> &[u8] ⓘ

Returns a bounds-checked immutable slice into the chunk starting at addr.

Source

pub fn chunk_slice_mut(&mut self, addr: u64, len: usize) -> &mut [u8] ⓘ

Returns a bounds-checked mutable slice into the chunk starting at addr.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.