pub struct FrameAllocator { /* private fields */ }Expand description
NUMA-aware hybrid frame allocator
Implementations§
Source§impl FrameAllocator
impl FrameAllocator
Sourcepub fn add_reserved_region(&self, region: ReservedRegion) -> Result<()>
pub fn add_reserved_region(&self, region: ReservedRegion) -> Result<()>
Add a reserved memory region
Sourcepub fn is_reserved(&self, start: FrameNumber, count: usize) -> bool
pub fn is_reserved(&self, start: FrameNumber, count: usize) -> bool
Check if a frame range is reserved
Sourcepub fn mark_standard_reserved_regions(&self)
pub fn mark_standard_reserved_regions(&self)
Mark standard reserved regions (e.g., BIOS, kernel, boot data)
Sourcepub fn init_numa_node(
&mut self,
node: usize,
start_frame: FrameNumber,
frame_count: usize,
) -> Result<()>
pub fn init_numa_node( &mut self, node: usize, start_frame: FrameNumber, frame_count: usize, ) -> Result<()>
Initialize a NUMA node with memory range
Sourcepub fn allocate_frames(
&self,
count: usize,
numa_node: Option<usize>,
) -> Result<FrameNumber>
pub fn allocate_frames( &self, count: usize, numa_node: Option<usize>, ) -> Result<FrameNumber>
Allocate frames from a specific NUMA node
Sourcepub fn allocate_frames_in_zone(
&self,
count: usize,
numa_node: Option<usize>,
zone: Option<MemoryZone>,
) -> Result<FrameNumber>
pub fn allocate_frames_in_zone( &self, count: usize, numa_node: Option<usize>, zone: Option<MemoryZone>, ) -> Result<FrameNumber>
Allocate frames from a specific NUMA node and memory zone
Sourcepub fn mark_frame_used(&self, frame: FrameNumber) -> Result<()>
pub fn mark_frame_used(&self, frame: FrameNumber) -> Result<()>
Mark a specific physical frame as used (reserved) so it won’t be allocated. Used to protect boot page table frames from being overwritten by the frame allocator.
Sourcepub fn free_frames(&self, frame: FrameNumber, count: usize) -> Result<()>
pub fn free_frames(&self, frame: FrameNumber, count: usize) -> Result<()>
Free frames back to the allocator
Sourcepub fn get_stats(&self) -> FrameAllocatorStats
pub fn get_stats(&self) -> FrameAllocatorStats
Get allocator statistics
Sourcepub fn allocate_frame_raii(&'static self) -> Result<FrameGuard>
pub fn allocate_frame_raii(&'static self) -> Result<FrameGuard>
Allocate a single frame with RAII guard
Sourcepub fn allocate_frames_raii(&'static self, count: usize) -> Result<FramesGuard>
pub fn allocate_frames_raii(&'static self, count: usize) -> Result<FramesGuard>
Allocate multiple frames with RAII guard
Sourcepub fn allocate_frame_raii_numa(
&'static self,
numa_node: usize,
) -> Result<FrameGuard>
pub fn allocate_frame_raii_numa( &'static self, numa_node: usize, ) -> Result<FrameGuard>
Allocate frame from specific NUMA node with RAII guard
Sourcepub unsafe fn free_frame(&self, frame: PhysicalFrame)
pub unsafe fn free_frame(&self, frame: PhysicalFrame)
Free a frame (used by RAII guards)
§Safety
The caller must ensure that:
- The frame was previously allocated by this allocator
- The frame is not currently in use
- The frame will not be used after this call
Sourcepub fn deallocate_frame(&self, frame: PhysicalAddress)
pub fn deallocate_frame(&self, frame: PhysicalAddress)
Deallocate a single frame (wrapper for free_frames)