The Slab Allocator: An Object-Caching Kernel Memory Allocator
📜 Abstract
This paper presents a comprehensive design overview of the SunOS 5.4 kernel memory allocator. This allocator is based on a set of object-caching primitives that reduce the cost of allocating complex objects by retaining their state between uses. These same primitives prove equally effective for managing stateless memory (e.g. data pages and temporary buffers) because they are space-efficient and fast. The allocator’s object caches respond dynamically to global memory pressure, and employ an object-coloring scheme that improves the system’s overall cache utilization and bus balance. The allocator also has several statistical and debugging features that can detect a wide range of problems throughout the system.
✨ Summary
The paper introduced the slab allocator, an object-caching kernel memory allocation design implemented for SunOS 5.4. Its principal mechanisms—typed object caches, reusable constructed objects, slab-based reclamation, memory-pressure feedback, cache coloring, and allocator instrumentation—were intended to improve allocation speed, space efficiency, cache utilization, and debugging.
The design had substantial subsequent influence. A later USENIX paper by Bonwick and Adams states that slab allocation was initially deployed in Solaris 2.4 and was subsequently adopted in whole or in part by Linux, FreeBSD, NetBSD, OpenBSD, EROS, and Nemesis; it was also adapted for applications including BIRD and Perl. (usenix.org) Linux kernel research documentation describes Linux’s slab implementation as heavily based on Bonwick’s original paper, with later improvements. (kernel.org) The later Solaris work extended the design with per-CPU caching, generalized resource allocation through vmem, and the user-level libumem allocator. (usenix.org)