Struct Mm

Source
pub struct Mm { /* private fields */ }
Expand description

A wrapper for the kernel’s struct mm_struct.

This represents the address space of a userspace process, so each process has one Mm instance. It may hold many VMAs internally.

There is a counter called mm_users that counts the users of the address space; this includes the userspace process itself, but can also include kernel threads accessing the address space. Once mm_users reaches zero, this indicates that the address space can be destroyed. To access the address space, you must prevent mm_users from reaching zero while you are accessing it. The MmWithUser type represents an address space where this is guaranteed, and you can create one using mmget_not_zero.

The ARef<Mm> smart pointer holds an mmgrab refcount. Its destructor may sleep.

§Invariants

Values of this type are always refcounted using mmgrab.

Implementations§

Source§

impl Mm

Source

pub fn as_raw(&self) -> *mut mm_struct

Returns a raw pointer to the inner mm_struct.

Source

pub unsafe fn from_raw<'a>(ptr: *const mm_struct) -> &'a Mm

Obtain a reference from a raw pointer.

§Safety

The caller must ensure that ptr points at an mm_struct, and that it is not deallocated during the lifetime ’a.

Source

pub fn mmget_not_zero(&self) -> Option<ARef<MmWithUser>>

Calls mmget_not_zero and returns a handle if it succeeds.

Trait Implementations§

Source§

impl AlwaysRefCounted for Mm

Source§

fn inc_ref(&self)

Increments the reference count on the object.
Source§

unsafe fn dec_ref(obj: NonNull<Self>)

Decrements the reference count on the object. Read more
Source§

impl Send for Mm

Source§

impl Sync for Mm

Auto Trait Implementations§

§

impl !Freeze for Mm

§

impl !RefUnwindSafe for Mm

§

impl !Unpin for Mm

§

impl UnwindSafe for Mm

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, E> Init<T, E> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
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, E> PinInit<T, E> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. 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.