VMEM(9) | Kernel Concepts | VMEM(9) |
vmem
—
kmem_alloc
() space), but also for
DVMA, bp_mapin
(), /dev/kmem,
and even some device mappings.
The kernel address space, therefore, is most accurately described as a tree of arenas in which each node of the tree imports some subset of its parent. The virtual memory allocator manages these arenas and supports their natural hierarchical structure.
vmem_create
() and
vmem_destroy
() create and destroy vmem arenas. In
order to differentiate between arenas used for addresses and arenas used for
identifiers, the VMC_IDENTIFIER
flag is passed to
vmem_create
(). This prevents identifier exhaustion
from being diagnosed as general memory failure.
[kernelheap,
ekernelheap)
. Spans can be added to an arena in two ways: explicitly,
by vmem_add
(); or implicitly, by importing, as
described in Imported Memory below.
[addr, addr + size)
represents
exactly one vmem_alloc(size)
that returned
addr. Free segments represent the space between allocated
segments. If two free segments are adjacent, we coalesce them into one larger
segment; that is, if segments [a, b)
and
[b, c)
are both free, we merge them into a single
segment [a, c)
. The segments within a span are linked
together in increasing-address order so we can easily determine whether
coalescing is possible.
Segments never cross span boundaries. When all segments within an imported span become free, we return the span to its source.
kmem_slab_create
() requests) is just a
subset of heap_arena (the kernel heap) that provides caching
for the most common slab sizes. When kmem_va_arena runs out
of virtual memory, it imports more from the heap; we say
that heap_arena is the vmem source for
kmem_va_arena. vmem_create
() allows
you to specify any existing vmem arena as the source for your new arena.
Topologically, since every arena is a child of at most one source, the set of
all arenas forms a collection of trees.
vmem_xalloc
() allows the client to specify any or all
of these constraints.
vmem_create
() time, that defines the arena's minimum
unit of currency. Most commonly the quantum is either 1 or
PAGESIZE
, but any power of 2 is legal. All vmem
allocations are guaranteed to be quantum-aligned.
vmem_alloc
() and
vmem_free
() to create and destroy slabs.
Jeff Bonwick and Jonathan Adams, Magazines and vmem: Extending the Slab Allocator to Many CPUs and Arbitrary Resources., Proceedings of the 2001 Usenix Conference, http://www.usenix.org/event/usenix01/bonwick.html.
January 18, 2017 | OmniOS |