xref: /freebsd/share/man/man9/zone.9 (revision 7851d429a6e8f958a5cd7a3a16a78497e6741346)
10aa028ffSDag-Erling Smørgrav.\"-
26e18fca1SUlrich Spörlein.\" Copyright (c) 2001 Dag-Erling Coïdan Smørgrav
30aa028ffSDag-Erling Smørgrav.\" All rights reserved.
40aa028ffSDag-Erling Smørgrav.\"
50aa028ffSDag-Erling Smørgrav.\" Redistribution and use in source and binary forms, with or without
60aa028ffSDag-Erling Smørgrav.\" modification, are permitted provided that the following conditions
70aa028ffSDag-Erling Smørgrav.\" are met:
80aa028ffSDag-Erling Smørgrav.\" 1. Redistributions of source code must retain the above copyright
90aa028ffSDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer.
100aa028ffSDag-Erling Smørgrav.\" 2. Redistributions in binary form must reproduce the above copyright
110aa028ffSDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer in the
120aa028ffSDag-Erling Smørgrav.\"    documentation and/or other materials provided with the distribution.
130aa028ffSDag-Erling Smørgrav.\"
140aa028ffSDag-Erling Smørgrav.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
150aa028ffSDag-Erling Smørgrav.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
160aa028ffSDag-Erling Smørgrav.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
170aa028ffSDag-Erling Smørgrav.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
180aa028ffSDag-Erling Smørgrav.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
190aa028ffSDag-Erling Smørgrav.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
200aa028ffSDag-Erling Smørgrav.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
210aa028ffSDag-Erling Smørgrav.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
220aa028ffSDag-Erling Smørgrav.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
230aa028ffSDag-Erling Smørgrav.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
240aa028ffSDag-Erling Smørgrav.\" SUCH DAMAGE.
250aa028ffSDag-Erling Smørgrav.\"
260aa028ffSDag-Erling Smørgrav.\" $FreeBSD$
270aa028ffSDag-Erling Smørgrav.\"
2854503a13SJonathan T. Looney.Dd December 20, 2015
290aa028ffSDag-Erling Smørgrav.Dt ZONE 9
300aa028ffSDag-Erling Smørgrav.Os
310aa028ffSDag-Erling Smørgrav.Sh NAME
32382682b2SJeroen Ruigrok van der Werven.Nm uma_zcreate ,
337c32182eSJeroen Ruigrok van der Werven.Nm uma_zalloc ,
346a4c41d1SRemko Lodder.Nm uma_zalloc_arg ,
357c32182eSJeroen Ruigrok van der Werven.Nm uma_zfree ,
366a4c41d1SRemko Lodder.Nm uma_zfree_arg ,
3707f490acSGleb Smirnoff.Nm uma_find_refcnt ,
38d7bbb21aSHartmut Brandt.Nm uma_zdestroy ,
39c4ae7908SLawrence Stewart.Nm uma_zone_set_max,
40c4ae7908SLawrence Stewart.Nm uma_zone_get_max,
412f891cd5SPawel Jakub Dawidek.Nm uma_zone_get_cur,
4254503a13SJonathan T. Looney.Nm uma_zone_set_warning,
4354503a13SJonathan T. Looney.Nm uma_zone_set_maxaction
44f5fccbbcSDag-Erling Smørgrav.Nd zone allocator
450aa028ffSDag-Erling Smørgrav.Sh SYNOPSIS
4632eef9aeSRuslan Ermilov.In sys/param.h
47f16b3c0dSChad David.In sys/queue.h
483a347a6eSJeroen Ruigrok van der Werven.In vm/uma.h
49382682b2SJeroen Ruigrok van der Werven.Ft uma_zone_t
509be1948fSRuslan Ermilov.Fo uma_zcreate
519be1948fSRuslan Ermilov.Fa "char *name" "int size"
529be1948fSRuslan Ermilov.Fa "uma_ctor ctor" "uma_dtor dtor" "uma_init uminit" "uma_fini fini"
536b99842aSEd Schouten.Fa "int align" "uint16_t flags"
549be1948fSRuslan Ermilov.Fc
559be1948fSRuslan Ermilov.Ft "void *"
569be1948fSRuslan Ermilov.Fn uma_zalloc "uma_zone_t zone" "int flags"
576a4c41d1SRemko Lodder.Ft "void *"
586a4c41d1SRemko Lodder.Fn uma_zalloc_arg "uma_zone_t zone" "void *arg" "int flags"
590aa028ffSDag-Erling Smørgrav.Ft void
60f1de92e6SJeroen Ruigrok van der Werven.Fn uma_zfree "uma_zone_t zone" "void *item"
615ca0c84eSThomas Moestl.Ft void
626a4c41d1SRemko Lodder.Fn uma_zfree_arg "uma_zone_t zone" "void *item" "void *arg"
6307f490acSGleb Smirnoff.Ft "uint32_t *"
6407f490acSGleb Smirnoff.Fn uma_find_refcnt "uma_zone_t zone" "void *item"
656a4c41d1SRemko Lodder.Ft void
66f1de92e6SJeroen Ruigrok van der Werven.Fn uma_zdestroy "uma_zone_t zone"
671c6cae97SLawrence Stewart.Ft int
68d7bbb21aSHartmut Brandt.Fn uma_zone_set_max "uma_zone_t zone" "int nitems"
69c4ae7908SLawrence Stewart.Ft int
70c4ae7908SLawrence Stewart.Fn uma_zone_get_max "uma_zone_t zone"
71c4ae7908SLawrence Stewart.Ft int
72c4ae7908SLawrence Stewart.Fn uma_zone_get_cur "uma_zone_t zone"
732f891cd5SPawel Jakub Dawidek.Ft void
742f891cd5SPawel Jakub Dawidek.Fn uma_zone_set_warning "uma_zone_t zone" "const char *warning"
7554503a13SJonathan T. Looney.Ft void
7654503a13SJonathan T. Looney.Fn uma_zone_set_maxaction "uma_zone_t zone" "void (*maxaction)(uma_zone_t)"
770a5a3ccbSGleb Smirnoff.In sys/sysctl.h
780a5a3ccbSGleb Smirnoff.Fn SYSCTL_UMA_MAX parent nbr name access zone descr
790a5a3ccbSGleb Smirnoff.Fn SYSCTL_ADD_UMA_MAX ctx parent nbr name access zone descr
800a5a3ccbSGleb Smirnoff.Fn SYSCTL_UMA_CUR parent nbr name access zone descr
810a5a3ccbSGleb Smirnoff.Fn SYSCTL_ADD_UMA_CUR ctx parent nbr name access zone descr
820aa028ffSDag-Erling Smørgrav.Sh DESCRIPTION
830aa028ffSDag-Erling SmørgravThe zone allocator provides an efficient interface for managing
840aa028ffSDag-Erling Smørgravdynamically-sized collections of items of similar size.
850aa028ffSDag-Erling SmørgravThe zone allocator can work with preallocated zones as well as with
860aa028ffSDag-Erling Smørgravruntime-allocated ones, and is therefore available much earlier in the
870aa028ffSDag-Erling Smørgravboot process than other memory management routines.
880aa028ffSDag-Erling Smørgrav.Pp
890aa028ffSDag-Erling SmørgravA zone is an extensible collection of items of identical size.
900aa028ffSDag-Erling SmørgravThe zone allocator keeps track of which items are in use and which
91008080bdSJeroen Ruigrok van der Wervenare not, and provides functions for allocating items from the zone and
920aa028ffSDag-Erling Smørgravfor releasing them back (which makes them available for later use).
930aa028ffSDag-Erling Smørgrav.Pp
94ced699e3SRuslan ErmilovAfter the first allocation of an item,
9590d83886SJulian Elischerit will have been cleared to zeroes, however subsequent allocations
967251f557SKonstantin Belousovwill retain the contents as of the last free.
9790d83886SJulian Elischer.Pp
98382682b2SJeroen Ruigrok van der WervenThe
99382682b2SJeroen Ruigrok van der Werven.Fn uma_zcreate
100382682b2SJeroen Ruigrok van der Wervenfunction creates a new zone from which items may then be allocated from.
101382682b2SJeroen Ruigrok van der WervenThe
102382682b2SJeroen Ruigrok van der Werven.Fa name
103382682b2SJeroen Ruigrok van der Wervenargument is a text name of the zone for debugging and stats; this memory
104382682b2SJeroen Ruigrok van der Wervenshould not be freed until the zone has been deallocated.
105382682b2SJeroen Ruigrok van der Werven.Pp
1064919e8cbSAlfred PerlsteinThe
1074919e8cbSAlfred Perlstein.Fa ctor
1084919e8cbSAlfred Perlsteinand
1094919e8cbSAlfred Perlstein.Fa dtor
1104919e8cbSAlfred Perlsteinarguments are callback functions that are called by
1114919e8cbSAlfred Perlsteinthe uma subsystem at the time of the call to
1124919e8cbSAlfred Perlstein.Fn uma_zalloc
1134919e8cbSAlfred Perlsteinand
1144919e8cbSAlfred Perlstein.Fn uma_zfree
115d962d52aSRuslan Ermilovrespectively.
116d962d52aSRuslan ErmilovTheir purpose is to provide hooks for initializing or
1174919e8cbSAlfred Perlsteindestroying things that need to be done at the time of the allocation
118d962d52aSRuslan Ermilovor release of a resource.
119e07f1d5fSHiten PandyaA good usage for the
1204919e8cbSAlfred Perlstein.Fa ctor
1214919e8cbSAlfred Perlsteinand
1224919e8cbSAlfred Perlstein.Fa dtor
1234919e8cbSAlfred Perlsteincallbacks
1244919e8cbSAlfred Perlsteinmight be to adjust a global count of the number of objects allocated.
1254919e8cbSAlfred Perlstein.Pp
1264919e8cbSAlfred PerlsteinThe
1274919e8cbSAlfred Perlstein.Fa uminit
1284919e8cbSAlfred Perlsteinand
1294919e8cbSAlfred Perlstein.Fa fini
1304919e8cbSAlfred Perlsteinarguments are used to optimize the allocation of
131d962d52aSRuslan Ermilovobjects from the zone.
132d962d52aSRuslan ErmilovThey are called by the uma subsystem whenever
1334919e8cbSAlfred Perlsteinit needs to allocate or free several items to satisfy requests or memory
134d962d52aSRuslan Ermilovpressure.
135d962d52aSRuslan ErmilovA good use for the
136d962d52aSRuslan Ermilov.Fa uminit
137d962d52aSRuslan Ermilovand
138d962d52aSRuslan Ermilov.Fa fini
139d962d52aSRuslan Ermilovcallbacks might be to
140d962d52aSRuslan Ermilovinitialize and destroy mutexes contained within the object.
141d962d52aSRuslan ErmilovThis would
1424919e8cbSAlfred Perlsteinallow one to re-use already initialized mutexes when an object is returned
143d962d52aSRuslan Ermilovfrom the uma subsystem's object cache.
144d962d52aSRuslan ErmilovThey are not called on each call to
1454919e8cbSAlfred Perlstein.Fn uma_zalloc
1464919e8cbSAlfred Perlsteinand
1474919e8cbSAlfred Perlstein.Fn uma_zfree
1484919e8cbSAlfred Perlsteinbut rather in a batch mode on several objects.
1494919e8cbSAlfred Perlstein.Pp
150b7e2b86cSGleb SmirnoffThe
151b7e2b86cSGleb Smirnoff.Fa flags
152b7e2b86cSGleb Smirnoffargument of the
153b7e2b86cSGleb Smirnoff.Fn uma_zcreate
154b7e2b86cSGleb Smirnoffis a subset of the following flags:
155b7e2b86cSGleb Smirnoff.Bl -tag -width "foo"
156b7e2b86cSGleb Smirnoff.It Dv UMA_ZONE_NOFREE
157b7e2b86cSGleb SmirnoffSlabs of the zone are never returned back to VM.
158b7e2b86cSGleb Smirnoff.It Dv UMA_ZONE_REFCNT
159b7e2b86cSGleb SmirnoffEach item in the zone would have internal reference counter associated with it.
160b7e2b86cSGleb SmirnoffSee
161b7e2b86cSGleb Smirnoff.Fn uma_find_refcnt .
162b7e2b86cSGleb Smirnoff.It Dv UMA_ZONE_NODUMP
163b7e2b86cSGleb SmirnoffPages belonging to the zone will not be included into mini-dumps.
164ad97af7eSGleb Smirnoff.It Dv UMA_ZONE_PCPU
165ad97af7eSGleb SmirnoffAn allocation from zone would have
166ad97af7eSGleb Smirnoff.Va mp_ncpu
167ad97af7eSGleb Smirnoffshadow copies, that are privately assigned to CPUs.
168ad97af7eSGleb SmirnoffA CPU can address its private copy using base allocation address plus
169ad97af7eSGleb Smirnoffmultiple of current CPU id and
170ad97af7eSGleb Smirnoff.Fn sizeof "struct pcpu" :
171ad97af7eSGleb Smirnoff.Bd -literal -offset indent
172ad97af7eSGleb Smirnofffoo_zone = uma_zcreate(..., UMA_ZONE_PCPU);
173ad97af7eSGleb Smirnoff ...
174ad97af7eSGleb Smirnofffoo_base = uma_zalloc(foo_zone, ...);
175ad97af7eSGleb Smirnoff ...
176ad97af7eSGleb Smirnoffcritical_enter();
177ad97af7eSGleb Smirnofffoo_pcpu = (foo_t *)zpcpu_get(foo_base);
178ad97af7eSGleb Smirnoff/* do something with foo_pcpu */
179ad97af7eSGleb Smirnoffcritical_exit();
180ad97af7eSGleb Smirnoff.Ed
181b7e2b86cSGleb Smirnoff.It Dv UMA_ZONE_OFFPAGE
182b7e2b86cSGleb SmirnoffBy default book-keeping of items within a slab is done in the slab page itself.
183b7e2b86cSGleb SmirnoffThis flag explicitly tells subsystem that book-keeping structure should be
184b7e2b86cSGleb Smirnoffallocated separately from special internal zone.
185b7e2b86cSGleb SmirnoffThis flag requires either
186b7e2b86cSGleb Smirnoff.Dv UMA_ZONE_VTOSLAB
187b7e2b86cSGleb Smirnoffor
188b7e2b86cSGleb Smirnoff.Dv UMA_ZONE_HASH ,
189b7e2b86cSGleb Smirnoffsince subsystem requires a mechanism to find a book-keeping structure
1907c64ddd5SWarren Blockto an item being freed.
191b7e2b86cSGleb SmirnoffThe subsystem may choose to prefer offpage book-keeping for certain zones
192b7e2b86cSGleb Smirnoffimplicitly.
193b7e2b86cSGleb Smirnoff.It Dv UMA_ZONE_ZINIT
194b7e2b86cSGleb SmirnoffThe zone will have its
195b7e2b86cSGleb Smirnoff.Ft uma_init
196b7e2b86cSGleb Smirnoffmethod set to internal method that initializes a new allocated slab
197b7e2b86cSGleb Smirnoffto all zeros.
198b1edef17SJoel DahlDo not mistake
199b7e2b86cSGleb Smirnoff.Ft uma_init
200b7e2b86cSGleb Smirnoffmethod with
201b7e2b86cSGleb Smirnoff.Ft uma_ctor .
202b7e2b86cSGleb SmirnoffA zone with
203b7e2b86cSGleb Smirnoff.Dv UMA_ZONE_ZINIT
204b7e2b86cSGleb Smirnoffflag would not return zeroed memory on every
205b7e2b86cSGleb Smirnoff.Fn uma_zalloc .
206b7e2b86cSGleb Smirnoff.It Dv UMA_ZONE_HASH
207b7e2b86cSGleb SmirnoffThe zone should use an internal hash table to find slab book-keeping
208b7e2b86cSGleb Smirnoffstructure where an allocation being freed belongs to.
209b7e2b86cSGleb Smirnoff.It Dv UMA_ZONE_VTOSLAB
210b7e2b86cSGleb SmirnoffThe zone should use special field of
211b7e2b86cSGleb Smirnoff.Vt vm_page_t
212b7e2b86cSGleb Smirnoffto find slab book-keeping structure where an allocation being freed belongs to.
213b7e2b86cSGleb Smirnoff.It Dv UMA_ZONE_MALLOC
214b7e2b86cSGleb SmirnoffThe zone is for the
215b7e2b86cSGleb Smirnoff.Xr malloc 9
216b7e2b86cSGleb Smirnoffsubsystem.
217b7e2b86cSGleb Smirnoff.It Dv UMA_ZONE_VM
218b7e2b86cSGleb SmirnoffThe zone is for the VM subsystem.
219b7e2b86cSGleb Smirnoff.El
220b7e2b86cSGleb Smirnoff.Pp
2210aa028ffSDag-Erling SmørgravTo allocate an item from a zone, simply call
2227c32182eSJeroen Ruigrok van der Werven.Fn uma_zalloc
2231437c79aSJeroen Ruigrok van der Wervenwith a pointer to that zone
2241437c79aSJeroen Ruigrok van der Wervenand set the
225acff84fbSJeroen Ruigrok van der Werven.Fa flags
226acff84fbSJeroen Ruigrok van der Wervenargument to selected flags as documented in
227acff84fbSJeroen Ruigrok van der Werven.Xr malloc 9 .
2281437c79aSJeroen Ruigrok van der WervenIt will return a pointer to an item if successful,
2291437c79aSJeroen Ruigrok van der Wervenor
2300aa028ffSDag-Erling Smørgrav.Dv NULL
2310aa028ffSDag-Erling Smørgravin the rare case where all items in the zone are in use and the
2321437c79aSJeroen Ruigrok van der Wervenallocator is unable to grow the zone
2332864c799SEdward Tomasz Napieralaand
2341437c79aSJeroen Ruigrok van der Werven.Dv M_NOWAIT
2351437c79aSJeroen Ruigrok van der Wervenis specified.
2360aa028ffSDag-Erling Smørgrav.Pp
2370aa028ffSDag-Erling SmørgravItems are released back to the zone from which they were allocated by
2380aa028ffSDag-Erling Smørgravcalling
2397c32182eSJeroen Ruigrok van der Werven.Fn uma_zfree
2400aa028ffSDag-Erling Smørgravwith a pointer to the zone and a pointer to the item.
24120ed0cb0SMatthew D FlemingIf
24220ed0cb0SMatthew D Fleming.Fa item
24320ed0cb0SMatthew D Flemingis
24420ed0cb0SMatthew D Fleming.Dv NULL ,
24520ed0cb0SMatthew D Flemingthen
24620ed0cb0SMatthew D Fleming.Fn uma_zfree
24720ed0cb0SMatthew D Flemingdoes nothing.
2485ca0c84eSThomas Moestl.Pp
2496a4c41d1SRemko LodderThe variations
2506a4c41d1SRemko Lodder.Fn uma_zalloc_arg
2516a4c41d1SRemko Lodderand
2526a4c41d1SRemko Lodder.Fn uma_zfree_arg
2536a4c41d1SRemko Lodderallow to
2546a4c41d1SRemko Lodderspecify an argument for the
2556a4c41d1SRemko Lodder.Dv ctor
2566a4c41d1SRemko Lodderand
2576a4c41d1SRemko Lodder.Dv dtor
2586a4c41d1SRemko Lodderfunctions, respectively.
2596a4c41d1SRemko Lodder.Pp
26007f490acSGleb SmirnoffIf zone was created with
26107f490acSGleb Smirnoff.Dv UMA_ZONE_REFCNT
26207f490acSGleb Smirnoffflag, then pointer to reference counter for an item can be retrieved with
26307f490acSGleb Smirnoffhelp of the
26407f490acSGleb Smirnoff.Fn uma_find_refcnt
26507f490acSGleb Smirnofffunction.
26607f490acSGleb Smirnoff.Pp
26755407559SJeroen Ruigrok van der WervenCreated zones,
26855407559SJeroen Ruigrok van der Wervenwhich are empty,
2695ca0c84eSThomas Moestlcan be destroyed using
2707c32182eSJeroen Ruigrok van der Werven.Fn uma_zdestroy ,
2715ca0c84eSThomas Moestlfreeing all memory that was allocated for the zone.
2725ca0c84eSThomas MoestlAll items allocated from the zone with
2737c32182eSJeroen Ruigrok van der Werven.Fn uma_zalloc
2745ca0c84eSThomas Moestlmust have been freed with
2757c32182eSJeroen Ruigrok van der Werven.Fn uma_zfree
2765ca0c84eSThomas Moestlbefore.
277d7bbb21aSHartmut Brandt.Pp
278c4ae7908SLawrence StewartThe
279d7bbb21aSHartmut Brandt.Fn uma_zone_set_max
280c4ae7908SLawrence Stewartfunction limits the number of items
281c4ae7908SLawrence Stewart.Pq and therefore memory
282c4ae7908SLawrence Stewartthat can be allocated to
283c4ae7908SLawrence Stewart.Fa zone .
284d7bbb21aSHartmut BrandtThe
285d7bbb21aSHartmut Brandt.Fa nitems
286c4ae7908SLawrence Stewartargument specifies the requested upper limit number of items.
2871c6cae97SLawrence StewartThe effective limit is returned to the caller, as it may end up being higher
2881c6cae97SLawrence Stewartthan requested due to the implementation rounding up to ensure all memory pages
2891c6cae97SLawrence Stewartallocated to the zone are utilised to capacity.
290c4ae7908SLawrence StewartThe limit applies to the total number of items in the zone, which includes
291d7bbb21aSHartmut Brandtallocated items, free items and free items in the per-cpu caches.
292d7bbb21aSHartmut BrandtOn systems with more than one CPU it may not be possible to allocate
293d7bbb21aSHartmut Brandtthe specified number of items even when there is no shortage of memory,
294d7bbb21aSHartmut Brandtbecause all of the remaining free items may be in the caches of the
295d7bbb21aSHartmut Brandtother CPUs when the limit is hit.
296c4ae7908SLawrence Stewart.Pp
297c4ae7908SLawrence StewartThe
298c4ae7908SLawrence Stewart.Fn uma_zone_get_max
299c4ae7908SLawrence Stewartfunction returns the effective upper limit number of items for a zone.
300c4ae7908SLawrence Stewart.Pp
301c4ae7908SLawrence StewartThe
302c4ae7908SLawrence Stewart.Fn uma_zone_get_cur
303c4ae7908SLawrence Stewartfunction returns the approximate current occupancy of the zone.
304c4ae7908SLawrence StewartThe returned value is approximate because appropriate synchronisation to
3053102cfe2SGlen Barberdetermine an exact value is not performed by the implementation.
306c4ae7908SLawrence StewartThis ensures low overhead at the expense of potentially stale data being used
307c4ae7908SLawrence Stewartin the calculation.
3082f891cd5SPawel Jakub Dawidek.Pp
3092f891cd5SPawel Jakub DawidekThe
3102f891cd5SPawel Jakub Dawidek.Fn uma_zone_set_warning
3112f891cd5SPawel Jakub Dawidekfunction sets a warning that will be printed on the system console when the
3122f891cd5SPawel Jakub Dawidekgiven zone becomes full and fails to allocate an item.
31354503a13SJonathan T. LooneyThe warning will be printed no more often than every five minutes.
3142f891cd5SPawel Jakub DawidekWarnings can be turned off globally by setting the
3152f891cd5SPawel Jakub Dawidek.Va vm.zone_warnings
3162f891cd5SPawel Jakub Dawideksysctl tunable to
3172f891cd5SPawel Jakub Dawidek.Va 0 .
3180a5a3ccbSGleb Smirnoff.Pp
3190a5a3ccbSGleb SmirnoffThe
32054503a13SJonathan T. Looney.Fn uma_zone_set_maxaction
32154503a13SJonathan T. Looneyfunction sets a function that will be called when the given zone becomes full
32254503a13SJonathan T. Looneyand fails to allocate an item.
323*7851d429SEdward Tomasz NapieralaThe function will be called with the zone locked.
324*7851d429SEdward Tomasz NapieralaAlso, the function
325*7851d429SEdward Tomasz Napieralathat called the allocation function may have held additional locks.
326*7851d429SEdward Tomasz NapieralaTherefore,
32754503a13SJonathan T. Looneythis function should do very little work (similar to a signal handler).
32854503a13SJonathan T. Looney.Pp
32954503a13SJonathan T. LooneyThe
3300a5a3ccbSGleb Smirnoff.Fn SYSCTL_UMA_MAX parent nbr name access zone descr
3310a5a3ccbSGleb Smirnoffmacro declares a static
3320a5a3ccbSGleb Smirnoff.Xr sysctl
3330a5a3ccbSGleb Smirnoffoid that exports the effective upper limit number of items for a zone.
3340a5a3ccbSGleb SmirnoffThe
3350a5a3ccbSGleb Smirnoff.Fa zone
3360a5a3ccbSGleb Smirnoffargument should be a pointer to
3370a5a3ccbSGleb Smirnoff.Vt uma_zone_t .
3380a5a3ccbSGleb SmirnoffA read of the oid returns value obtained through
3390a5a3ccbSGleb Smirnoff.Fn uma_zone_get_max .
3400a5a3ccbSGleb SmirnoffA write to the oid sets new value via
3410a5a3ccbSGleb Smirnoff.Fn uma_zone_set_max .
3420a5a3ccbSGleb SmirnoffThe
3430a5a3ccbSGleb Smirnoff.Fn SYSCTL_ADD_UMA_MAX ctx parent nbr name access zone descr
3440a5a3ccbSGleb Smirnoffmacro is provided to create this type of oid dynamically.
3450a5a3ccbSGleb Smirnoff.Pp
3460a5a3ccbSGleb SmirnoffThe
3470a5a3ccbSGleb Smirnoff.Fn SYSCTL_UMA_CUR parent nbr name access zone descr
34862cb31dcSWarner Loshmacro declares a static read-only
3490a5a3ccbSGleb Smirnoff.Xr sysctl
3500a5a3ccbSGleb Smirnoffoid that exports the approximate current occupancy of the zone.
3510a5a3ccbSGleb SmirnoffThe
3520a5a3ccbSGleb Smirnoff.Fa zone
3530a5a3ccbSGleb Smirnoffargument should be a pointer to
3540a5a3ccbSGleb Smirnoff.Vt uma_zone_t .
3550a5a3ccbSGleb SmirnoffA read of the oid returns value obtained through
3560a5a3ccbSGleb Smirnoff.Fn uma_zone_get_cur .
3570a5a3ccbSGleb SmirnoffThe
3580a5a3ccbSGleb Smirnoff.Fn SYSCTL_ADD_UMA_CUR ctx parent nbr name zone descr
3590a5a3ccbSGleb Smirnoffmacro is provided to create this type of oid dynamically.
3600aa028ffSDag-Erling Smørgrav.Sh RETURN VALUES
3610aa028ffSDag-Erling SmørgravThe
3627c32182eSJeroen Ruigrok van der Werven.Fn uma_zalloc
3630aa028ffSDag-Erling Smørgravfunction returns a pointer to an item, or
3640aa028ffSDag-Erling Smørgrav.Dv NULL
3652864c799SEdward Tomasz Napieralaif the zone ran out of unused items
3662864c799SEdward Tomasz Napieralaand
3672864c799SEdward Tomasz Napierala.Dv M_NOWAIT
3682864c799SEdward Tomasz Napieralawas specified.
3690aa028ffSDag-Erling Smørgrav.Sh SEE ALSO
3700aa028ffSDag-Erling Smørgrav.Xr malloc 9
3710aa028ffSDag-Erling Smørgrav.Sh HISTORY
3720aa028ffSDag-Erling SmørgravThe zone allocator first appeared in
3730aa028ffSDag-Erling Smørgrav.Fx 3.0 .
3749a795583SJeroen Ruigrok van der WervenIt was radically changed in
3759a795583SJeroen Ruigrok van der Werven.Fx 5.0
3769a795583SJeroen Ruigrok van der Wervento function as a slab allocator.
3770aa028ffSDag-Erling Smørgrav.Sh AUTHORS
3780aa028ffSDag-Erling Smørgrav.An -nosplit
3790aa028ffSDag-Erling SmørgravThe zone allocator was written by
3800aa028ffSDag-Erling Smørgrav.An John S. Dyson .
3819a795583SJeroen Ruigrok van der WervenThe zone allocator was rewritten in large parts by
3828a7314fcSBaptiste Daroussin.An Jeff Roberson Aq Mt jeff@FreeBSD.org
3839a795583SJeroen Ruigrok van der Wervento function as a slab allocator.
3840aa028ffSDag-Erling Smørgrav.Pp
3850aa028ffSDag-Erling SmørgravThis manual page was written by
3868a7314fcSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
3879a795583SJeroen Ruigrok van der WervenChanges for UMA by
3888a7314fcSBaptiste Daroussin.An Jeroen Ruigrok van der Werven Aq Mt asmodai@FreeBSD.org .
389