xref: /netbsd-src/share/man/man9/memoryallocators.9 (revision aad9773e38ed2370a628a6416e098f9008fc10a7)
1.\" $NetBSD: memoryallocators.9,v 1.6 2014/03/18 18:20:40 riastradh Exp $
2.\"
3.\" Copyright (c) 2006 Elad Efrat <elad@NetBSD.org>
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. The name of the author may not be used to endorse or promote products
15.\"    derived from this software without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.Dd August 3, 2009
29.Dt MEMORYALLOCATORS 9
30.Os
31.Sh NAME
32.Nm memoryallocators
33.Nd introduction to kernel memory allocators
34.Sh DESCRIPTION
35The
36.Nx
37kernel provides several memory allocators, each with different characteristics
38and purpose.
39This document summarizes the main differences between them.
40.Ss The Kmem Allocator
41The kmem allocator is modelled after an interface of similar name implemented in
42Solaris.
43This is main general purpose allocator in the kernel.
44.Pp
45It is implemented on-top of the
46.Xr vmem 9
47resource allocator (beyond the scope of this document), meaning it will be using
48.Xr pool_cache 9
49internally to speed-up common (small) sized allocations.
50.Pp
51It requires no setup, but cannot be used from interrupt context.
52.Pp
53See
54.Xr kmem 9
55for more details.
56.Ss The Pool Allocator
57The
58.Xr pool 9
59allocator is a fixed-size memory allocator.
60It requires setup (to initialize a memory pool) and is interrupt-safe.
61.Pp
62.\" On some architectures (foo, bar) the
63.\" .Xr pool 9
64.\" allocator will use direct-mapped segments rather than normal page
65.\" mappings, which can reduce TLB contentions.
66.\".Pp
67See
68.Xr pool 9
69for more details.
70.Ss The Pool Cache Allocator
71The pool cache allocator works on-top of the
72.Xr pool 9
73allocator, also allowing fixed-size allocation only, requires setup,
74and is interrupt-safe.
75.Pp
76The pool cache allocator is expected to be faster than other allocators,
77including the
78.Dq normal
79pool allocator.
80.Pp
81In the future this allocator is expected to have a per-CPU cache.
82.Pp
83See
84.Xr pool_cache 9
85for more details.
86.Ss The UVM Kernel Memory Allocator
87This is a low-level memory allocator interface.
88It allows variable-sized allocations in multiples of
89.Dv PAGE_SIZE ,
90and can be used to allocate both wired and pageable kernel memory.
91.Pp
92See
93.Xr uvm 9
94for more details.
95.Sh SEE ALSO
96.Xr intro 9 ,
97.Xr kmem 9 ,
98.Xr pool 9 ,
99.Xr pool_cache 9 ,
100.Xr uvm 9 ,
101.Xr vmem 9
102.Sh AUTHORS
103.An Elad Efrat Aq Mt elad@NetBSD.org
104.An YAMAMOTO Takashi Aq Mt yamt@NetBSD.org
105