Enum HugePage

Source
pub enum HugePage {
    Static(MapHugeFlag),
    Dynamic {
        kilobytes: usize,
    },
    Smallest,
    Largest,
    Selected(for<'r> fn(&'r [usize]) -> Option<&'r usize>),
}
Expand description

Provides an arbitrary huge-page size and mapping flag for that size.

Can store or create a MAP_HUGE_* flag for use with mmap(), (MappedFile) or memfd_create() (file::MemoryFile::with_hugetlb())

§Usage

Main usage is for generating a MapHugeFlag via compute_huge(). This function may fail (rarely), so a TryInto impl exists for MapHugeFlag as well.

Variants§

§

Static(MapHugeFlag)

A staticly presented MAP_HUGE_* flag. See MapHugeFlag for details.

§

Dynamic

A dynamically calculated MAP_HUGE_* flag from an arbitrary size in kB.

§Safety

The kernel must actually support huge-pages of this size.

If kilobytes is 0, or an overflow in calculation happens, then this is identical to Smallest.

Fields

§kilobytes: usize
§

Smallest

The smallest huge-page size on the system

§

Largest

The largest huge-page size on the system

§

Selected(for<'r> fn(&'r [usize]) -> Option<&'r usize>)

Use a callback function to select the huge-page size (in kB) from an ordered (lowest to highest) enumeration of all available on the system.

Implementations§

Source§

impl HugePage

Source

pub fn compute_huge(self) -> Option<MapHugeFlag>

Compute the MapHugeFlag from this huge-page specification.

§Returns
  • None - If there was an error in computing the correct flag.
  • Some - If the computation was successful.
§Panics

In debug builds, if scanning the system for huge-pages fails after SYSTEM_HUGEPAGES has already failed.

Trait Implementations§

Source§

impl Clone for HugePage

Source§

fn clone(&self) -> HugePage

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HugePage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HugePage

Source§

fn default() -> HugePage

Returns the “default value” for a type. Read more
Source§

impl Hash for HugePage

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for HugePage

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<HugePage> for MapHugeFlag

Source§

type Error = HugePageCalcErr

The type returned in the event of a conversion error.
Source§

fn try_from(from: HugePage) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for HugePage

Source§

impl Eq for HugePage

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.