uma_zcreate uma_zalloc uma_zalloc_arg uma_zfree uma_zfree_arg uma_zdestroy uma_zone_set_max - zone allocator
A zone is an extensible collection of items of identical size. The zone allocator keeps track of which items are in use and which are not, and provides functions for allocating items from the zone and for releasing them back (which makes them available for later use).
After the first allocation of an item, it will have been cleared to zeroes, however subsequent allocations will retain the contents as of the last free.
function creates a new zone from which items may then be allocated from. The Fa name argument is a text name of the zone for debugging and stats; this memory should not be freed until the zone has been deallocated.
arguments are callback functions that are called by
the uma subsystem at the time of the call to
and uma_zfree ();
respectively. Their purpose is to provide hooks for initializing or destroying things that need to be done at the time of the allocation or release of a resource. A good usage for the Fa ctor and Fa dtor callbacks might be to adjust a global count of the number of objects allocated.
arguments are used to optimize the allocation of
objects from the zone.
They are called by the uma subsystem whenever
it needs to allocate or free several items to satisfy requests or memory
A good use for the
callbacks might be to
initialize and destroy mutexes contained within the object.
allow one to re-use already initialized mutexes when an object is returned
from the uma subsystem's object cache.
They are not called on each call to
and uma_zfree ();
but rather in a batch mode on several objects.
To allocate an item from a zone, simply call
with a pointer to that zone and set the Fa flags argument to selected flags as documented in malloc(9). It will return a pointer to an item if successful, or NULL in the rare case where all items in the zone are in use and the allocator is unable to grow the zone or when M_NOWAIT is specified.
Items are released back to the zone from which they were allocated by
with a pointer to the zone and a pointer to the item.
and uma_zfree_arg ();
allow to specify an argument for the ctor and dtor functions, respectively.
which are empty,
can be destroyed using
freeing all memory that was allocated for the zone. All items allocated from the zone with uma_zalloc ();
must have been freed with uma_zfree ();
The purpose of
is to limit the maximum amount of memory that the system can dedicated toward the zone specified by the Fa zone argument. The Fa nitems argument gives the upper limit of items in the zone. This limits the total number of items in the zone which includes: allocated items, free items and free items in the per-cpu caches. On systems with more than one CPU it may not be possible to allocate the specified number of items even when there is no shortage of memory, because all of the remaining free items may be in the caches of the other CPUs when the limit is hit.
This manual page was written by An Dag-Erling Sm/orgrav Aq des@FreeBSD.org . Changes for UMA by An Jeroen Ruigrok van der Werven Aq asmodai@FreeBSD.org .
Закладки на сайте
Проследить за страницей
Created 1996-2023 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру