Struct mmtk::util::heap::accounting::PageAccounting
source · pub struct PageAccounting {
reserved: AtomicUsize,
committed: AtomicUsize,
}
Expand description
The struct is used for page usage. Both page resource and side metadata uses this struct to do page accounting.
Fields§
§reserved: AtomicUsize
The reserved pages. This should be incremented when we are about to allocate pages. Note this is different than quarantining address range. We do not count for quarantined memory.
committed: AtomicUsize
The committed pages. This should be incremented when we successfully allocate pages from the OS.
Implementations§
source§impl PageAccounting
impl PageAccounting
pub fn new() -> Self
sourcepub fn reserve_and_commit(&self, pages: usize)
pub fn reserve_and_commit(&self, pages: usize)
Inform of both reserving and committing a certain number of pages.
sourcepub fn reserve(&self, pages: usize)
pub fn reserve(&self, pages: usize)
Inform of reserving a certain number of pages. Usually this is called before attempting to allocate memory.
sourcepub fn clear_reserved(&self, pages: usize)
pub fn clear_reserved(&self, pages: usize)
Inform of clearing some reserved pages. This is used when we have reserved some pages but the allocation cannot be satisfied. We can call this to clear the number of reserved pages, so later we can reserve and attempt again.
sourcepub fn commit(&self, pages: usize)
pub fn commit(&self, pages: usize)
Inform of successfully committing a certain number of pages. This is used after we have reserved pages and successfully allocated those memory.
sourcepub fn release(&self, pages: usize)
pub fn release(&self, pages: usize)
Inform of releasing a certain number of pages. The number of pages will be deducted from both reserved and committed pages.
sourcepub fn reset(&self)
pub fn reset(&self)
Set both reserved and committed pages to zero. This is only used when we completely clear a space.
pub fn get_reserved_pages(&self) -> usize
pub fn get_committed_pages(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for PageAccounting
impl Send for PageAccounting
impl Sync for PageAccounting
impl Unpin for PageAccounting
impl UnwindSafe for PageAccounting
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for 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