pub struct MemoryAvailability { /* private fields */ }Expand description
Provenance-preserving memory availability for the current process.
Two quantities live here and they answer different questions.
- Available (
available_bytes) is free space right now: a finite cgroup-v1 or cgroup-v2 ceiling admits exactlymin(host available, reclaim-aware cgroup available). A v2 literalmemory.max = maxremains typed as unbounded and therefore defers to the host; v1’s numeric unlimited sentinel participates exactly and likewise loses to a tighter host value. This quantity moves, and under pressure it goes to zero. - Capacity (
capacity_bytes) is how much memory this process could ever address:min(host total, the binding cgroup's hard limit). It is a property of the box and the cgroup configuration, not of the schedule, so it does not move when a sibling allocates.
The distinction is load-bearing (#2684). “Does this dense footprint fit
here at all?” is a capacity question and its answer must be stationary —
see process_memory_availability on why a route derived from a moving
quantity is a defect. “Does this allocation fit right now?” is an
availability question, and the joint ledger
(MemoryGovernor::try_reserve) is the instrument for it. Reading the
second where the first was meant is what let a cgroup a few pages from its
limit refuse a 28,800-byte design on a host with 448 GB free.
If an active controller cannot be parsed exactly, admission fails closed with zero bytes — both available and capacity — while retaining the typed probe failure; it never silently inherits host capacity.
Implementations§
Source§impl MemoryAvailability
impl MemoryAvailability
Sourcepub const fn capacity_bytes(&self) -> u64
pub const fn capacity_bytes(&self) -> u64
The stationary ceiling on memory this process could ever address:
min(host total, binding cgroup hard limit), or zero when the cgroup
probe failed closed. Unlike Self::available_bytes this does not move
when other work allocates, which is what makes it usable as a routing
threshold (#2684).
pub const fn available_bytes(&self) -> u64
pub fn available_bytes_usize(&self) -> usize
Trait Implementations§
Source§impl Clone for MemoryAvailability
impl Clone for MemoryAvailability
Source§fn clone(&self) -> MemoryAvailability
fn clone(&self) -> MemoryAvailability
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MemoryAvailability
impl Debug for MemoryAvailability
Source§impl Display for MemoryAvailability
impl Display for MemoryAvailability
impl Eq for MemoryAvailability
Source§impl PartialEq for MemoryAvailability
impl PartialEq for MemoryAvailability
impl StructuralPartialEq for MemoryAvailability
Auto Trait Implementations§
impl Freeze for MemoryAvailability
impl RefUnwindSafe for MemoryAvailability
impl Send for MemoryAvailability
impl Sync for MemoryAvailability
impl Unpin for MemoryAvailability
impl UnsafeUnpin for MemoryAvailability
impl UnwindSafe for MemoryAvailability
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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