Skip to main content

SlabState

Struct SlabState 

Source
struct SlabState {
    partial_pages: [*mut SlabPageHeader; 26],
}
Expand description

Per-size-class partial-page lists.

partial_pages[ci] is the head of a singly-linked list of SlabPageHeader nodes for class ci. A page enters the list on refill and on the first dealloc after going full. It leaves the list when all its blocks are allocated (it silently becomes “full”) or when it becomes completely empty (it is then returned to the buddy allocator).

Fields§

§partial_pages: [*mut SlabPageHeader; 26]

Implementations§

Source§

impl SlabState

Source

const fn new() -> Self

Source

fn class_index_for_layout(layout: Layout) -> usize

Return the slab class index for layout.

The chosen class must be large enough for the payload and guarantee the requested alignment for every block carved from that class.

Source

unsafe fn refill(&mut self, ci: usize, token: &IrqDisabledToken)

Allocate one buddy page, write a SlabPageHeader at its base, carve the remaining space into blocks, and prepend the page to partial_pages[ci].

Source

unsafe fn alloc_block(&mut self, ci: usize, token: &IrqDisabledToken) -> *mut u8

Pop one block from the first partial page for class ci. Calls refill when the partial list is empty. Returns null on OOM.

Source

unsafe fn dealloc_block( &mut self, ptr: *mut u8, ci: usize, token: &IrqDisabledToken, )

Return ptr to its slab page and reclaim the page to the buddy allocator if it becomes fully empty.

Source

unsafe fn remove_from_partial(&mut self, page: *mut SlabPageHeader, ci: usize)

Unlink page from partial_pages[ci]. O(n) in partial-list length.

Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.