pub struct Zone {Show 14 fields
pub zone_type: ZoneType,
pub base: PhysAddr,
pub page_count: usize,
pub present_pages: usize,
pub span_pages: usize,
pub allocated: usize,
pub reserved_pages: usize,
pub lowmem_reserve_pages: usize,
pub watermark_min: usize,
pub watermark_low: usize,
pub watermark_high: usize,
pub segment_count: usize,
pub segment_capacity: usize,
pub segments: *mut ZoneSegment,
}Expand description
Memory zone with buddy allocator free lists
Fields§
§zone_type: ZoneTypeZone type
base: PhysAddrBase physical address of this zone
page_count: usizeTotal number of managed pages in this zone.
present_pages: usizePages reported as usable RAM by the boot memory map for this zone.
span_pages: usizeTotal address span covered by this zone metadata, in pages.
Unlike page_count, this includes holes and is kept for diagnostics.
allocated: usizeNumber of allocated pages
reserved_pages: usizePages removed from management during boot reservations.
lowmem_reserve_pages: usizeHard reserve kept available for lower zones or emergency paths.
watermark_min: usizeWatermark below which this zone should be avoided when possible.
watermark_low: usizeAdvisory low watermark for diagnostics and future reclaim hooks.
watermark_high: usizeAdvisory high watermark for diagnostics and future reclaim hooks.
segment_count: usizeNumber of populated contiguous segments in this zone.
segment_capacity: usizeTotal number of segment slots reserved for this zone.
segments: *mut ZoneSegmentIndependently managed contiguous segments inside this zone.
Implementations§
Source§impl Zone
impl Zone
Sourcepub fn segments(&self) -> &[ZoneSegment]
pub fn segments(&self) -> &[ZoneSegment]
Returns the reserved segment storage as a slice.
Sourcepub fn segments_mut(&mut self) -> &mut [ZoneSegment]
pub fn segments_mut(&mut self) -> &mut [ZoneSegment]
Returns the reserved segment storage as a mutable slice.
Sourcepub fn clear_segments(&mut self)
pub fn clear_segments(&mut self)
Reset the zone’s segment storage metadata.
Sourcepub fn contains_address(&self, addr: PhysAddr) -> bool
pub fn contains_address(&self, addr: PhysAddr) -> bool
Check if an address is within this zone
Sourcepub fn available_pages(&self) -> usize
pub fn available_pages(&self) -> usize
Get number of available (free) pages
Sourcepub fn free_list_count(&self, order: u8) -> usize
pub fn free_list_count(&self, order: u8) -> usize
Count the number of free blocks at a given order.
Walks the buddy free list. Safe because we only read the next link from
the per-frame crate::memory::frame::MetaSlot (not from mapped page bytes).
Sourcepub fn free_list_count_for(&self, order: u8, migratetype: Migratetype) -> usize
pub fn free_list_count_for(&self, order: u8, migratetype: Migratetype) -> usize
Count the number of free blocks at a given order for one migratetype.
Sourcepub fn free_pages_by_migratetype(&self) -> [usize; 2]
pub fn free_pages_by_migratetype(&self) -> [usize; 2]
Returns the total free pages by migratetype across all orders.
Sourcepub fn free_pages_at_or_above_order(&self, order: u8) -> usize
pub fn free_pages_at_or_above_order(&self, order: u8) -> usize
Returns the number of free pages currently available in blocks of at least order.
This is the relevant numerator for fragmentation analysis of an
allocation request at order: pages on smaller free lists exist, but
cannot satisfy that request without prior coalescing.
Sourcepub fn fragmentation_score(
&self,
order: u8,
cached_order0_pages: usize,
) -> usize
pub fn fragmentation_score( &self, order: u8, cached_order0_pages: usize, ) -> usize
Returns a simple fragmentation score for order, expressed as a percentage.
0 means all currently free pages are still usable for an allocation of
that order. 100 means all free pages are trapped in blocks smaller than
the requested order. cached_order0_pages accounts for pages parked in
per-CPU caches, which behave like order-0 fragments until drained.
Sourcepub fn largest_free_order(&self) -> Option<u8>
pub fn largest_free_order(&self) -> Option<u8>
Returns the largest order that currently has at least one free block.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Zone
impl RefUnwindSafe for Zone
impl !Sync for Zone
impl Unpin for Zone
impl UnsafeUnpin for Zone
impl UnwindSafe for Zone
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more