introduction to kernel memory allocators
kernel provides several memory allocators,
each with different characteristics and purpose. This document summarizes the
main differences between them.
You should use the
allocator for all allocations unless you have special needs that it does not
provide, such as:
- use from interrupt handlers
- a minimum reserved number of allocations
- a maximum usable number of allocations
- costly object initialization that can be reused
- allocating resources other than pageable RAM-backed kernel virtual address
allocator is main general purpose allocator in the kernel. It was modelled
after an interface of the same name implemented in Solaris.
and requires no setup. It cannot be used from interrupt context.
implemented using a collection of pool caches for common small allocation
sizes, so there is no performance benefit to using a pool cache if you have no
allocator is a fixed-size memory allocator which requires setup to initialize
a shared pool.
A pool can be configured with a low-water mark to reserve a minimum number of
objects available, a high-water mark to bound the maximum number of objects in
reserve, and a hard limit to bound on the maximum number of objects in use.
can be used to allocate memory in interrupt context for objects that have been
reserved in advance, with the possibility of failure if there are none.
allocates pageable RAM-backed kernel virtual address space from the same
backing store as
, but it
can be configured to allocate any kind of resource with a custom allocator.
The pool cache allocator is a per-CPU cache on top of
fixed-size memory allocations that may occur in interrupt context requiring
The per-CPU cache makes allocation much cheaper — no interprocessor
synchronization in the fast case — at the cost of potentially caching
some extra resources on one CPU that cannot be used by another.
In addition to all the features of a pool like a custom backing allocator, a
pool cache also supports a constructor and destructor routine for when objects
are drawn from the shared pool in case the per-CPU cache is empty, or returned
to it when the cache is full. This can reduce the cost of reusable
initialization and finalization, or associate objects with CPU-local
API is a low-level memory allocator for page-aligned kernel virtual address
space in multiples of
, with wired
RAM backing, pageable RAM backing, or backing to be supplied by the caller
is a general address space allocator. It is used internally by
other kernel subsystems and device drivers to allocate regions of various
kinds of address spaces. Internally, it allocates large chunks of the address
space and uses a
to draw small allocations out of them.
API manages and allocates constrained regions of an address space. The extent
manager is optimized for simplicity, not speed, and is available early at
reserve regions of I/O port and memory spaces to prevent drivers from using
the same device registers or bus memory.
Taylor R Campbell