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
impl GlobalNodePool
Sourcepub fn init(&mut self, region_start: usize, region_size: usize)
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.
Sourcepub fn add_region(&mut self, region_start: usize, region_size: usize)
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.
Sourcepub fn alloc_node(&mut self) -> Option<usize>
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
Sourcepub fn dealloc_node(&mut self, node_idx: usize)
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
Sourcepub fn get_node(&self, node_idx: usize) -> Option<&ListNode<BuddyBlock>>
pub fn get_node(&self, node_idx: usize) -> Option<&ListNode<BuddyBlock>>
Get a reference to a node by index
Sourcepub fn get_node_mut(
&mut self,
node_idx: usize,
) -> Option<&mut ListNode<BuddyBlock>>
pub fn get_node_mut( &mut self, node_idx: usize, ) -> Option<&mut ListNode<BuddyBlock>>
Get a mutable reference to a node by index
Sourcepub fn free_node_count(&self) -> usize
pub fn free_node_count(&self) -> usize
Get the number of free nodes in the pool
Sourcepub fn allocated_node_count(&self) -> usize
pub fn allocated_node_count(&self) -> usize
Get the number of allocated nodes
Sourcepub fn get_stats(&self) -> GlobalPoolStats
pub fn get_stats(&self) -> GlobalPoolStats
Get pool statistics