pub struct MmWithUser { /* private fields */ }
Expand description
A wrapper for the kernel’s struct mm_struct
.
This type is like Mm
, but with non-zero mm_users
. It can only be used when mm_users
can
be proven to be non-zero at compile-time, usually because the relevant code holds an mmget
refcount. It can be used to access the associated address space.
The ARef<MmWithUser>
smart pointer holds an mmget
refcount. Its destructor may sleep.
§Invariants
Values of this type are always refcounted using mmget
. The value of mm_users
is non-zero.
Implementations§
Source§impl MmWithUser
impl MmWithUser
Sourcepub unsafe fn from_raw<'a>(ptr: *const mm_struct) -> &'a MmWithUser
pub unsafe fn from_raw<'a>(ptr: *const mm_struct) -> &'a MmWithUser
Obtain a reference from a raw pointer.
§Safety
The caller must ensure that ptr
points at an mm_struct
, and that mm_users
remains
non-zero for the duration of the lifetime ’a.
Sourcepub fn into_mmput_async(me: ARef<MmWithUser>) -> ARef<MmWithUserAsync>
pub fn into_mmput_async(me: ARef<MmWithUser>) -> ARef<MmWithUserAsync>
Use mmput_async
when dropping this refcount.
Sourcepub fn lock_vma_under_rcu(&self, vma_addr: usize) -> Option<VmaReadGuard<'_>>
pub fn lock_vma_under_rcu(&self, vma_addr: usize) -> Option<VmaReadGuard<'_>>
Attempt to access a vma using the vma read lock.
This is an optimistic trylock operation, so it may fail if there is contention. In that case, you should fall back to taking the mmap read lock.
When per-vma locks are disabled, this always returns None
.
Sourcepub fn mmap_read_lock(&self) -> MmapReadGuard<'_>
pub fn mmap_read_lock(&self) -> MmapReadGuard<'_>
Lock the mmap read lock.
Sourcepub fn mmap_read_trylock(&self) -> Option<MmapReadGuard<'_>>
pub fn mmap_read_trylock(&self) -> Option<MmapReadGuard<'_>>
Try to lock the mmap read lock.
Methods from Deref<Target = Mm>§
Sourcepub fn mmget_not_zero(&self) -> Option<ARef<MmWithUser>>
pub fn mmget_not_zero(&self) -> Option<ARef<MmWithUser>>
Calls mmget_not_zero
and returns a handle if it succeeds.