template <size_t AllocSize>
class PageSlabAllocator
Defined at line 39 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
Simple slab allocator that uses a vm_page_t as its slab to perform allocations out of. This makes
the allocator only suitable for small allocations, preferably ones that divide evenly into a
page.
All per-slab metadata is stored in the vm_page_t itself and, by default, the only dependency of
the allocator is the PMM to allocate and free pages from. The heap is not needed for any other
metadata allocations.
Free regions are tracked in a two level list with each slab having an internal list of free
regions, and the allocator itself having a list of slabs that have at least one free region.
Slabs that become fully empty are able to be returned to the PMM, although allocations cannot be
moved between slabs, so fragmentation can still occur.
The allocator can be specialized to control the actual allocation and freeing of the slabs
themselves.
This class it not thread safe.
Protected Members
static const uint32_t kEntryAlign
static const uint32_t kAllocsPerSlab
static const uint32_t kEndOfList
Public Methods
void PageSlabAllocator<AllocSize> ()
Defined at line 41 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
void ~PageSlabAllocator<AllocSize> ()
Defined at line 42 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
void * allocate_bytes ()
Allocates an area of uninitialized memory of AllocSize and returns a pointer to it, or nullptr
on error.
Defined at line 49 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
template <typename T>
T * allocate_object ()
Allocates an area of uninitialized memory capable of holding a single object of type |T|. This
is largely a convenience wrapper around |allocate_bytes| that validates T is compatible with
the size and alignment of the allocations.
Returns a nullptr on error.
Defined at line 56 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
void deallocate_bytes (void * ptr)
Deallocates the storage referenced by |ptr|, which must be a pointer obtained by an earlier
call to |allocate_object| or |allocate_bytes|.
Defined at line 66 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
template <typename T>
void deallocate_object (T * ptr)
Typed convenience wrapper around |deallocate_bytes|. Assumes the object at |ptr| has already
been destructed.
Defined at line 71 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
size_t AllocatedSlabs ()
Defined at line 75 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
uint32_t SlabsRequired (uint32_t num_allocs)
Helper to return the number of slabs this allocator would allocate to store the specified
number of allocations.
Defined at line 79 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
Protected Methods
ktl::pair<vm_page_t *, uint32_t> AllocToSlab (const void * ptr)
Defined at line 96 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
Entry * GetEntry (vm_page_t * slab, uint32_t index)
Defined at line 104 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
void DebugFreeAllSlabs ()
Defined at line 109 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
vm_page_t * AllocSlab ()
Defined at line 120 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
void FreeSlab (vm_page_t * slab)
Defined at line 131 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h
vm_page_t * PaddrToPage (paddr_t paddr)
Defined at line 136 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h