Skip to main content

UmemPool

Struct UmemPool 

Source
pub struct UmemPool { /* private fields */ }
Expand description

Pre-allocated page-aligned shared memory pool for AF_XDP kernel-bypass I/O.

Implementations§

Source§

impl UmemPool

Source

pub fn new(num_chunks: usize, chunk_size: usize) -> Result<Self>

Allocates an anonymous, page-aligned shared memory region for num_chunks chunks of size chunk_size with default pre-faulting (MAP_POPULATE) enabled.

Source

pub fn new_lazy(num_chunks: usize, chunk_size: usize) -> Result<Self>

Allocates a new UmemPool with lazy on-demand page allocation (MAP_POPULATE disabled), minimizing startup latency and initial RSS footprint.

Source

pub fn with_config(config: UmemPoolConfig) -> Result<Self>

Allocates a new UmemPool according to the provided UmemPoolConfig.

Source

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

Allocates a chunk address from the free pool, returning None if exhausted.

Source

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

Returns a chunk address to the free pool.

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.

Source

pub fn area_ptr(&self) -> *mut c_void

Raw pointer to the mapped UMEM memory area.

Source

pub fn size(&self) -> usize

Total size in bytes of the mapped UMEM memory area.

Source

pub fn chunk_size(&self) -> usize

Chunk size in bytes.

Source

pub fn free_chunk_count(&self) -> usize

Number of free chunks currently available in the pool.

Source

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

Returns true if addr is an aligned chunk address within this pool’s bounds.

Source

pub fn create_slabs(self: &Arc<Self>, num_slabs: usize) -> Result<Vec<UmemSlab>>

Partitions an Arc<UmemPool> into num_slabs disjoint, per-core chunk slabs.

Each slab receives an equal partition of chunks (total_chunks / num_slabs). Slabs operate completely independently without shared locks or cross-core cache line contention.

Source

pub fn new_slabs( num_chunks: usize, chunk_size: usize, num_slabs: usize, ) -> Result<(Arc<Self>, Vec<UmemSlab>)>

Allocates a new UmemPool with default configuration and partitions it into num_slabs disjoint slabs.

Source

pub fn new_slabs_with_config( config: UmemPoolConfig, num_slabs: usize, ) -> Result<(Arc<Self>, Vec<UmemSlab>)>

Allocates a new UmemPool using the specified UmemPoolConfig and partitions it into num_slabs disjoint slabs.

Trait Implementations§

Source§

impl Drop for UmemPool

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for UmemPool

Source§

impl Sync for UmemPool

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.