template <size_t AllocSize, size_t MaxAllocs, typename SLAB = FixedIdSlabAllocator<
              sizeof(vm_page_t*), BaseIdSlabAllocator<AllocSize>::SlabsRequired(MaxAllocs)>>

class IdSlabAllocator

Defined at line 333 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h

Slab allocator that can convert each allocation to/from a numerical ID, with the added guarantee

that all IDs fall within [0, MaxAllocs). This implies that only up to MaxAllocs can be

allocated at one time. To achieve this it is a restriction that the maximum number of requested

allocations be a common multiple of the number of allocations per slab and per ID slab.

The properties of this allocator are otherwise the same as the PageSlabAllocator, with the only

dependency being direct PMM allocations, and slabs able to be cleaned up if they become fully

free.

This slab allocator uses the FixedIdSlabAllocator internally to allocate slab IDs. This works as

follows:

1. Whenever this slab allocator allocates a slab, the `vm_page_t*` pointing to that slab is

stored in the FixedIdSlabAllocator.

2. By construction, each slab in the FixedIdSlabAllocator has an ID that we can convert into a

slab. Thus, using the AllocToId function allows us to convert the `vm_page_t**` into a stable

ID that we can assign as the slab's ID in this allocator.

We do this to minimize the amount of metadata needed to store the IDs. Notice that using a

FixedIdSlabAllocator directly would increase the allocation size by 8 bytes for every slab we

allocate. By introducing this level of indirection, we are able to add a slab to the

FixedIdSlabAllocator only when we have (8 / kPageSize) slabs allocated in this allocator. We can

fit (sizeof(T) / kPageSize) allocations in each slab in this allocator, so this means that the

size of the underlying FixedIdSlabAllocator will grow at a rate of

(8 * sizeof(T)) / (kPageSize * kPageSize) bytes per allocation added.

The rate of growth of the static metadata can be further reduced by adding additional levels of

indirection for the slab id allocation by overriding the SLAB template argument.

Public Methods

void IdSlabAllocator<AllocSize, MaxAllocs, SLAB> ()

Defined at line 336 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h

void ~IdSlabAllocator<AllocSize, MaxAllocs, SLAB> ()

Defined at line 337 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h

size_t MemoryUsage ()

Total memory usage, in bytes, including any unused portions of slabs, not including the size of

|this|.

Defined at line 341 of file ../../zircon/kernel/vm/include/vm/page_slab_allocator.h