Skip to main content

Zone

Struct Zone 

Source
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: ZoneType

Zone type

§base: PhysAddr

Base physical address of this zone

§page_count: usize

Total number of managed pages in this zone.

§present_pages: usize

Pages reported as usable RAM by the boot memory map for this zone.

§span_pages: usize

Total address span covered by this zone metadata, in pages.

Unlike page_count, this includes holes and is kept for diagnostics.

§allocated: usize

Number of allocated pages

§reserved_pages: usize

Pages removed from management during boot reservations.

§lowmem_reserve_pages: usize

Hard reserve kept available for lower zones or emergency paths.

§watermark_min: usize

Watermark below which this zone should be avoided when possible.

§watermark_low: usize

Advisory low watermark for diagnostics and future reclaim hooks.

§watermark_high: usize

Advisory high watermark for diagnostics and future reclaim hooks.

§segment_count: usize

Number of populated contiguous segments in this zone.

§segment_capacity: usize

Total number of segment slots reserved for this zone.

§segments: *mut ZoneSegment

Independently managed contiguous segments inside this zone.

Implementations§

Source§

impl Zone

Source

pub const fn new(zone_type: ZoneType) -> Self

Create a new empty zone

Source

pub fn segments(&self) -> &[ZoneSegment]

Returns the reserved segment storage as a slice.

Source

pub fn segments_mut(&mut self) -> &mut [ZoneSegment]

Returns the reserved segment storage as a mutable slice.

Source

pub fn clear_segments(&mut self)

Reset the zone’s segment storage metadata.

Source

pub fn contains_address(&self, addr: PhysAddr) -> bool

Check if an address is within this zone

Source

pub fn available_pages(&self) -> usize

Get number of available (free) pages

Source

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).

Source

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.

Source

pub fn free_pages_by_migratetype(&self) -> [usize; 2]

Returns the total free pages by migratetype across all orders.

Source

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.

Source

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.

Source

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.