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
impl SlabState
const fn new() -> Self
Sourcefn class_index_for_layout(layout: Layout) -> usize
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.
Sourceunsafe fn refill(&mut self, ci: usize, token: &IrqDisabledToken)
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].
Sourceunsafe fn alloc_block(&mut self, ci: usize, token: &IrqDisabledToken) -> *mut u8
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.
Sourceunsafe fn dealloc_block(
&mut self,
ptr: *mut u8,
ci: usize,
token: &IrqDisabledToken,
)
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.
Sourceunsafe fn remove_from_partial(&mut self, page: *mut SlabPageHeader, ci: usize)
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§
impl Freeze for SlabState
impl RefUnwindSafe for SlabState
impl Unpin for SlabState
impl UnsafeUnpin for SlabState
impl UnwindSafe for SlabState
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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