Skip to main content

GlobalNodePool

Struct GlobalNodePool 

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

Global node pool - all zones and orders share nodes from this pool

Nodes are carved from one or more contiguous memory regions provided by the page allocator. The pool manages a single free list of nodes using raw pointers (stored as usize indices).

Implementations§

Source§

impl GlobalNodePool

Source

pub const fn new() -> Self

Create a new global node pool (uninitialized, must call init())

Source

pub fn init(&mut self, region_start: usize, region_size: usize)

Initialize the global node pool with a backing memory region

The region is treated as raw memory and partitioned into ListNode<BuddyBlock> objects, which are all added to the pool’s free list.

Source

pub fn add_region(&mut self, region_start: usize, region_size: usize)

Add an additional memory region to the node pool

This can be used to grow the pool at runtime by carving more memory from the page allocator.

Source

pub fn alloc_node(&mut self) -> Option<usize>

Allocate a node from the pool

Returns the index of the allocated node, or None if pool is exhausted

Source

pub fn dealloc_node(&mut self, node_idx: usize)

Deallocate a node back to the pool

The node should not be part of any active list when freed

Source

pub fn get_node(&self, node_idx: usize) -> Option<&ListNode<BuddyBlock>>

Get a reference to a node by index

Source

pub fn get_node_mut( &mut self, node_idx: usize, ) -> Option<&mut ListNode<BuddyBlock>>

Get a mutable reference to a node by index

Source

pub fn free_node_count(&self) -> usize

Get the number of free nodes in the pool

Source

pub fn allocated_node_count(&self) -> usize

Get the number of allocated nodes

Source

pub fn get_stats(&self) -> GlobalPoolStats

Get pool statistics

Trait Implementations§

Source§

impl Default for GlobalNodePool

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.