pub struct TwoLevelMmapper {
transition_lock: Mutex<()>,
slabs: Vec<OnceOptionBox<[Atomic<MapState>; 8192]>>,
}
Expand description
A two-level implementation of Mmapper
.
It is essentially a lazily initialized array of [Atomic<MapState>
]. Because it is designed to
govern a large address range, and the array is sparse, we use a two-level design. The higher
level holds a vector of slabs, and each slab holds an array of [Atomic<MapState>
]. Each slab
governs an aligned region of MMAP_CHUNKS_PER_SLAB
chunks. Slabs are lazily created when the
user intends to write into one of its MapState
.
Fields§
§transition_lock: Mutex<()>
Lock for transitioning map states.
FIXME: We only need this lock when transitioning map states.
The TwoLevelMmapper
itself is completely lock-free even when allocating new slabs.
We should move the lock one leve above, to MapState
.
slabs: Vec<OnceOptionBox<[Atomic<MapState>; 8192]>>
Slabs
Implementations§
source§impl TwoLevelMmapper
impl TwoLevelMmapper
pub fn new() -> Self
fn new_slab() -> [Atomic<MapState>; 8192]
fn slab_table(&self, addr: Address) -> Option<&[Atomic<MapState>; 8192]>
fn get_or_allocate_slab_table(&self, addr: Address) -> &[Atomic<MapState>; 8192]
fn chunk_index_to_address(base: Address, chunk: usize) -> Address
sourcefn slab_align_down(addr: Address) -> Address
fn slab_align_down(addr: Address) -> Address
Align addr
down to slab size.
sourcefn slab_limit(addr: Address) -> Address
fn slab_limit(addr: Address) -> Address
Get the base address of the next slab after the slab that contains addr
.
sourcefn chunk_index(slab: Address, addr: Address) -> usize
fn chunk_index(slab: Address, addr: Address) -> usize
Return the index of the chunk that contains addr
within the slab starting at slab
.
If addr
is beyond the end of the slab, the result could be beyond the end of the slab.
Trait Implementations§
source§impl Debug for TwoLevelMmapper
impl Debug for TwoLevelMmapper
source§impl Default for TwoLevelMmapper
impl Default for TwoLevelMmapper
source§impl Mmapper for TwoLevelMmapper
impl Mmapper for TwoLevelMmapper
source§fn is_mapped_address(&self, addr: Address) -> bool
fn is_mapped_address(&self, addr: Address) -> bool
Return {@code true} if the given address has been mmapped
@param addr The address in question. @return {@code true} if the given address has been mmapped
source§fn eagerly_mmap_all_spaces(&self, _space_map: &[Address])
fn eagerly_mmap_all_spaces(&self, _space_map: &[Address])
source§fn mark_as_mapped(&self, start: Address, bytes: usize)
fn mark_as_mapped(&self, start: Address, bytes: usize)
source§fn quarantine_address_range(
&self,
start: Address,
pages: usize,
strategy: MmapStrategy,
anno: &MmapAnnotation<'_>,
) -> Result<()>
fn quarantine_address_range( &self, start: Address, pages: usize, strategy: MmapStrategy, anno: &MmapAnnotation<'_>, ) -> Result<()>
source§fn ensure_mapped(
&self,
start: Address,
pages: usize,
strategy: MmapStrategy,
anno: &MmapAnnotation<'_>,
) -> Result<()>
fn ensure_mapped( &self, start: Address, pages: usize, strategy: MmapStrategy, anno: &MmapAnnotation<'_>, ) -> Result<()>
impl Send for TwoLevelMmapper
impl Sync for TwoLevelMmapper
Auto Trait Implementations§
impl !Freeze for TwoLevelMmapper
impl RefUnwindSafe for TwoLevelMmapper
impl Unpin for TwoLevelMmapper
impl !UnwindSafe for TwoLevelMmapper
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>
, which can then be
downcast
into Box<dyn 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>
, which 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> DowncastSend for T
impl<T> DowncastSend for T
§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