xref: /freebsd/sys/vm/uma.h (revision 736ee5907f3de3559a85fbb0c12b75d10d4f4c90)
18355f576SJeff Roberson /*
28355f576SJeff Roberson  * Copyright (c) 2002, Jeffrey Roberson <jroberson@chesapeake.net>
38355f576SJeff Roberson  * All rights reserved.
48355f576SJeff Roberson  *
58355f576SJeff Roberson  * Redistribution and use in source and binary forms, with or without
68355f576SJeff Roberson  * modification, are permitted provided that the following conditions
78355f576SJeff Roberson  * are met:
88355f576SJeff Roberson  * 1. Redistributions of source code must retain the above copyright
98355f576SJeff Roberson  *    notice unmodified, this list of conditions, and the following
108355f576SJeff Roberson  *    disclaimer.
118355f576SJeff Roberson  * 2. Redistributions in binary form must reproduce the above copyright
128355f576SJeff Roberson  *    notice, this list of conditions and the following disclaimer in the
138355f576SJeff Roberson  *    documentation and/or other materials provided with the distribution.
148355f576SJeff Roberson  *
158355f576SJeff Roberson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
168355f576SJeff Roberson  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
178355f576SJeff Roberson  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
188355f576SJeff Roberson  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
198355f576SJeff Roberson  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
208355f576SJeff Roberson  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
218355f576SJeff Roberson  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
228355f576SJeff Roberson  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
238355f576SJeff Roberson  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
248355f576SJeff Roberson  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258355f576SJeff Roberson  *
268355f576SJeff Roberson  * $FreeBSD$
278355f576SJeff Roberson  *
288355f576SJeff Roberson  */
298355f576SJeff Roberson 
308355f576SJeff Roberson /*
318355f576SJeff Roberson  * uma.h - External definitions for the Universal Memory Allocator
328355f576SJeff Roberson  *
338355f576SJeff Roberson  * Jeff Roberson <jroberson@chesapeake.net>
348355f576SJeff Roberson */
358355f576SJeff Roberson 
368355f576SJeff Roberson #ifndef VM_UMA_H
378355f576SJeff Roberson #define VM_UMA_H
388355f576SJeff Roberson 
398355f576SJeff Roberson #include <sys/param.h>		/* For NULL */
408355f576SJeff Roberson #include <sys/malloc.h>		/* For M_* */
418355f576SJeff Roberson 
428355f576SJeff Roberson /* User visable parameters */
438355f576SJeff Roberson #define UMA_SMALLEST_UNIT       (PAGE_SIZE / 256) /* Smallest item allocated */
448355f576SJeff Roberson 
458355f576SJeff Roberson /* Types and type defs */
468355f576SJeff Roberson 
478355f576SJeff Roberson struct uma_zone;
488355f576SJeff Roberson /* Opaque type used as a handle to the zone */
498355f576SJeff Roberson typedef struct uma_zone * uma_zone_t;
508355f576SJeff Roberson 
518355f576SJeff Roberson /*
528355f576SJeff Roberson  * Item constructor
538355f576SJeff Roberson  *
548355f576SJeff Roberson  * Arguments:
558355f576SJeff Roberson  *	item  A pointer to the memory which has been allocated.
568355f576SJeff Roberson  *	arg   The arg field passed to uma_zalloc_arg
578355f576SJeff Roberson  *	size  The size of the allocated item
588355f576SJeff Roberson  *
598355f576SJeff Roberson  * Returns:
608355f576SJeff Roberson  *	Nothing
618355f576SJeff Roberson  *
628355f576SJeff Roberson  * Discussion:
638355f576SJeff Roberson  *	The constructor is called just before the memory is returned
648355f576SJeff Roberson  *	to the user. It may block if neccisary.
658355f576SJeff Roberson  */
668355f576SJeff Roberson typedef void (*uma_ctor)(void *mem, int size, void *arg);
678355f576SJeff Roberson 
688355f576SJeff Roberson /*
698355f576SJeff Roberson  * Item destructor
708355f576SJeff Roberson  *
718355f576SJeff Roberson  * Arguments:
728355f576SJeff Roberson  *	item  A pointer to the memory which has been allocated.
738355f576SJeff Roberson  *	size  The size of the item being destructed.
748355f576SJeff Roberson  *	arg   Argument passed through uma_zfree_arg
758355f576SJeff Roberson  *
768355f576SJeff Roberson  * Returns:
778355f576SJeff Roberson  *	Nothing
788355f576SJeff Roberson  *
798355f576SJeff Roberson  * Discussion:
808355f576SJeff Roberson  *	The destructor may perform operations that differ from those performed
818355f576SJeff Roberson  *	by the initializer, but it must leave the object in the same state.
828355f576SJeff Roberson  *	This IS type stable storage.  This is called after EVERY zfree call.
838355f576SJeff Roberson  */
848355f576SJeff Roberson typedef void (*uma_dtor)(void *mem, int size, void *arg);
858355f576SJeff Roberson 
868355f576SJeff Roberson /*
878355f576SJeff Roberson  * Item initializer
888355f576SJeff Roberson  *
898355f576SJeff Roberson  * Arguments:
908355f576SJeff Roberson  *	item  A pointer to the memory which has been allocated.
918355f576SJeff Roberson  *	size  The size of the item being initialized.
928355f576SJeff Roberson  *
938355f576SJeff Roberson  * Returns:
948355f576SJeff Roberson  *	Nothing
958355f576SJeff Roberson  *
968355f576SJeff Roberson  * Discussion:
978355f576SJeff Roberson  *	The initializer is called when the memory is cached in the uma zone.
988355f576SJeff Roberson  *	this should be the same state that the destructor leaves the object in.
998355f576SJeff Roberson  */
1008355f576SJeff Roberson typedef void (*uma_init)(void *mem, int size);
1018355f576SJeff Roberson 
1028355f576SJeff Roberson /*
1038355f576SJeff Roberson  * Item discard function
1048355f576SJeff Roberson  *
1058355f576SJeff Roberson  * Arguments:
1068355f576SJeff Roberson  * 	item  A pointer to memory which has been 'freed' but has not left the
1078355f576SJeff Roberson  *	      zone's cache.
1088355f576SJeff Roberson  *	size  The size of the item being discarded.
1098355f576SJeff Roberson  *
1108355f576SJeff Roberson  * Returns:
1118355f576SJeff Roberson  *	Nothing
1128355f576SJeff Roberson  *
1138355f576SJeff Roberson  * Discussion:
1148355f576SJeff Roberson  *	This routine is called when memory leaves a zone and is returned to the
1158355f576SJeff Roberson  *	system for other uses.  It is the counter part to the init function.
1168355f576SJeff Roberson  */
1178355f576SJeff Roberson typedef void (*uma_fini)(void *mem, int size);
1188355f576SJeff Roberson 
1198355f576SJeff Roberson /*
1208355f576SJeff Roberson  * What's the difference between initializing and constructing?
1218355f576SJeff Roberson  *
1228355f576SJeff Roberson  * The item is initialized when it is cached, and this is the state that the
1238355f576SJeff Roberson  * object should be in when returned to the allocator. The purpose of this is
1248355f576SJeff Roberson  * to remove some code which would otherwise be called on each allocation by
1258355f576SJeff Roberson  * utilizing a known, stable state.  This differs from the constructor which
1268355f576SJeff Roberson  * will be called on EVERY allocation.
1278355f576SJeff Roberson  *
1288355f576SJeff Roberson  * For example, in the initializer you may want to initialize embeded locks,
1298355f576SJeff Roberson  * NULL list pointers, set up initial states, magic numbers, etc.  This way if
1308355f576SJeff Roberson  * the object is held in the allocator and re-used it won't be neccisary to
1318355f576SJeff Roberson  * re-initialize it.
1328355f576SJeff Roberson  *
1338355f576SJeff Roberson  * The constructor may be used to lock a data structure, link it on to lists,
1348355f576SJeff Roberson  * bump reference counts or total counts of outstanding structures, etc.
1358355f576SJeff Roberson  *
1368355f576SJeff Roberson  */
1378355f576SJeff Roberson 
1388355f576SJeff Roberson 
1398355f576SJeff Roberson /* Function proto types */
1408355f576SJeff Roberson 
1418355f576SJeff Roberson /*
1428355f576SJeff Roberson  * Create a new uma zone
1438355f576SJeff Roberson  *
1448355f576SJeff Roberson  * Arguments:
1458355f576SJeff Roberson  *	name  The text name of the zone for debugging and stats, this memory
1468355f576SJeff Roberson  *		should not be freed until the zone has been deallocated.
1478355f576SJeff Roberson  *	size  The size of the object that is being created.
1488355f576SJeff Roberson  *	ctor  The constructor that is called when the object is allocated
1498355f576SJeff Roberson  *	dtor  The destructor that is called when the object is freed.
1508355f576SJeff Roberson  *	init  An initializer that sets up the initial state of the memory.
1518355f576SJeff Roberson  *	fini  A discard function that undoes initialization done by init.
1528355f576SJeff Roberson  *		ctor/dtor/init/fini may all be null, see notes above.
1538355f576SJeff Roberson  *	align A bitmask that corisponds to the requested alignment
1548355f576SJeff Roberson  *		eg 4 would be 0x3
1558355f576SJeff Roberson  *	flags A set of parameters that control the behavior of the zone
1568355f576SJeff Roberson  *
1578355f576SJeff Roberson  * Returns:
1588355f576SJeff Roberson  *	A pointer to a structure which is intended to be opaque to users of
1598355f576SJeff Roberson  *	the interface.  The value may be null if the wait flag is not set.
1608355f576SJeff Roberson  */
1618355f576SJeff Roberson 
1628355f576SJeff Roberson uma_zone_t uma_zcreate(char *name, int size, uma_ctor ctor, uma_dtor dtor,
1638355f576SJeff Roberson 			uma_init uminit, uma_fini fini, int align,
1648355f576SJeff Roberson 			u_int16_t flags);
1658355f576SJeff Roberson 
1668355f576SJeff Roberson /* Definitions for uma_zcreate flags */
1678355f576SJeff Roberson #define UMA_ZONE_PAGEABLE	0x0001	/* Return items not fully backed by
1688355f576SJeff Roberson 					   physical memory XXX Not yet */
1698355f576SJeff Roberson #define UMA_ZONE_ZINIT		0x0002	/* Initialize with zeros */
1708355f576SJeff Roberson #define UMA_ZONE_STATIC		0x0004	/* Staticly sized zone */
1718355f576SJeff Roberson #define UMA_ZONE_OFFPAGE	0x0008	/* Force the slab structure allocation
1728355f576SJeff Roberson 					   off of the real memory */
1738355f576SJeff Roberson #define UMA_ZONE_MALLOC		0x0010	/* For use by malloc(9) only! */
1748355f576SJeff Roberson #define UMA_ZONE_NOFREE		0x0020	/* Do not free slabs of this type! */
1758355f576SJeff Roberson 
1768355f576SJeff Roberson /* Definitions for align */
1778355f576SJeff Roberson #define UMA_ALIGN_PTR	(sizeof(void *) - 1)	/* Alignment fit for ptr */
1788355f576SJeff Roberson #define UMA_ALIGN_LONG	(sizeof(long) - 1)	/* "" long */
1798355f576SJeff Roberson #define UMA_ALIGN_INT	(sizeof(int) - 1)	/* "" int */
1808355f576SJeff Roberson #define UMA_ALIGN_SHORT	(sizeof(short) - 1)	/* "" short */
1818355f576SJeff Roberson #define UMA_ALIGN_CHAR	(sizeof(char) - 1)	/* "" char */
1828355f576SJeff Roberson #define UMA_ALIGN_CACHE	(16 - 1)		/* Cache line size align */
1838355f576SJeff Roberson 
1848355f576SJeff Roberson /*
1858355f576SJeff Roberson  * Destroys a uma zone
1868355f576SJeff Roberson  *
1878355f576SJeff Roberson  * Arguments:
1888355f576SJeff Roberson  *	zone  The zone we want to destroy.
1898355f576SJeff Roberson  *	wait  This flag indicates whether or not we should wait for all
1908355f576SJeff Roberson  *		allocations to free, or return an errno on outstanding memory.
1918355f576SJeff Roberson  *
1928355f576SJeff Roberson  * Returns:
1938355f576SJeff Roberson  *	0 on successful completion, or EWOULDBLOCK if there are outstanding
1948355f576SJeff Roberson  *	allocations and the wait flag is M_NOWAIT
1958355f576SJeff Roberson  */
1968355f576SJeff Roberson 
1978355f576SJeff Roberson int uma_zdestroy(uma_zone_t zone, int wait);
1988355f576SJeff Roberson 
1998355f576SJeff Roberson /*
2008355f576SJeff Roberson  * Allocates an item out of a zone
2018355f576SJeff Roberson  *
2028355f576SJeff Roberson  * Arguments:
2038355f576SJeff Roberson  *	zone  The zone we are allocating from
2048355f576SJeff Roberson  *	arg   This data is passed to the ctor function
2058355f576SJeff Roberson  *	wait  This flag indicates whether or not we are allowed to block while
2068355f576SJeff Roberson  *		allocating memory for this zone should we run out.
2078355f576SJeff Roberson  *
2088355f576SJeff Roberson  * Returns:
2098355f576SJeff Roberson  *	A non null pointer to an initialized element from the zone is
2108355f576SJeff Roberson  *	garanteed if the wait flag is M_WAITOK, otherwise a null pointer may be
2118355f576SJeff Roberson  *	returned if the zone is empty or the ctor failed.
2128355f576SJeff Roberson  */
2138355f576SJeff Roberson 
2148355f576SJeff Roberson void *uma_zalloc_arg(uma_zone_t zone, void *arg, int wait);
2158355f576SJeff Roberson 
2168355f576SJeff Roberson /*
2178355f576SJeff Roberson  * Allocates an item out of a zone without supplying an argument
2188355f576SJeff Roberson  *
2198355f576SJeff Roberson  * This is just a wrapper for uma_zalloc_arg for convenience.
2208355f576SJeff Roberson  *
2218355f576SJeff Roberson  */
2228355f576SJeff Roberson static __inline void *uma_zalloc(uma_zone_t zone, int wait);
2238355f576SJeff Roberson 
2248355f576SJeff Roberson static __inline void *
2258355f576SJeff Roberson uma_zalloc(uma_zone_t zone, int wait)
2268355f576SJeff Roberson {
2278355f576SJeff Roberson 	return uma_zalloc_arg(zone, NULL, wait);
2288355f576SJeff Roberson }
2298355f576SJeff Roberson 
2308355f576SJeff Roberson /*
2318355f576SJeff Roberson  * Frees an item back into the specified zone.
2328355f576SJeff Roberson  *
2338355f576SJeff Roberson  * Arguments:
2348355f576SJeff Roberson  *	zone  The zone the item was originally allocated out of.
2358355f576SJeff Roberson  *	item  The memory to be freed.
2368355f576SJeff Roberson  *	arg   Argument passed to the destructor
2378355f576SJeff Roberson  *
2388355f576SJeff Roberson  * Returns:
2398355f576SJeff Roberson  *	Nothing.
2408355f576SJeff Roberson  */
2418355f576SJeff Roberson 
2428355f576SJeff Roberson void uma_zfree_arg(uma_zone_t zone, void *item, void *arg);
2438355f576SJeff Roberson 
2448355f576SJeff Roberson /*
2458355f576SJeff Roberson  * Frees an item back to a zone without supplying an argument
2468355f576SJeff Roberson  *
2478355f576SJeff Roberson  * This is just a wrapper for uma_zfree_arg for convenience.
2488355f576SJeff Roberson  *
2498355f576SJeff Roberson  */
2508355f576SJeff Roberson static __inline void uma_zfree(uma_zone_t zone, void *item);
2518355f576SJeff Roberson 
2528355f576SJeff Roberson static __inline void
2538355f576SJeff Roberson uma_zfree(uma_zone_t zone, void *item)
2548355f576SJeff Roberson {
2558355f576SJeff Roberson 	return uma_zfree_arg(zone, item, NULL);
2568355f576SJeff Roberson }
2578355f576SJeff Roberson 
2588355f576SJeff Roberson /*
2598355f576SJeff Roberson  * XXX The rest of the prototypes in this header are h0h0 magic for the VM.
2608355f576SJeff Roberson  * If you think you need to use it for a normal zone you're probably incorrect.
2618355f576SJeff Roberson  */
2628355f576SJeff Roberson 
2638355f576SJeff Roberson /*
2648355f576SJeff Roberson  * Backend page supplier routines
2658355f576SJeff Roberson  *
2668355f576SJeff Roberson  * Arguments:
2678355f576SJeff Roberson  *	zone  The zone that is requesting pages
2688355f576SJeff Roberson  *	size  The number of bytes being requested
2698355f576SJeff Roberson  *	pflag Flags for these memory pages, see below.
2708355f576SJeff Roberson  *	wait  Indicates our willingness to block.
2718355f576SJeff Roberson  *
2728355f576SJeff Roberson  * Returns:
2738355f576SJeff Roberson  *	A pointer to the alloced memory or NULL on failure.
2748355f576SJeff Roberson  */
2758355f576SJeff Roberson 
2768355f576SJeff Roberson typedef void *(*uma_alloc)(uma_zone_t zone, int size, u_int8_t *pflag, int wait);
2778355f576SJeff Roberson 
2788355f576SJeff Roberson /*
2798355f576SJeff Roberson  * Backend page free routines
2808355f576SJeff Roberson  *
2818355f576SJeff Roberson  * Arguments:
2828355f576SJeff Roberson  *	item  A pointer to the previously allocated pages
2838355f576SJeff Roberson  *	size  The original size of the allocation
2848355f576SJeff Roberson  *	pflag The flags for the slab.  See UMA_SLAB_* below
2858355f576SJeff Roberson  *
2868355f576SJeff Roberson  * Returns:
2878355f576SJeff Roberson  *	None
2888355f576SJeff Roberson  */
2898355f576SJeff Roberson typedef void (*uma_free)(void *item, int size, u_int8_t pflag);
2908355f576SJeff Roberson 
2918355f576SJeff Roberson 
2928355f576SJeff Roberson 
2938355f576SJeff Roberson /*
2948355f576SJeff Roberson  * Sets up the uma allocator. (Called by vm_mem_init)
2958355f576SJeff Roberson  *
2968355f576SJeff Roberson  * Arguments:
2978355f576SJeff Roberson  *	bootmem  A pointer to memory used to bootstrap the system.
2988355f576SJeff Roberson  *
2998355f576SJeff Roberson  * Returns:
3008355f576SJeff Roberson  *	Nothing
3018355f576SJeff Roberson  *
3028355f576SJeff Roberson  * Discussion:
3038355f576SJeff Roberson  *	This memory is used for zones which allocate things before the
3048355f576SJeff Roberson  *	backend page supplier can give us pages.  It should be
3058355f576SJeff Roberson  *	UMA_SLAB_SIZE * UMA_BOOT_PAGES bytes. (see uma_int.h)
3068355f576SJeff Roberson  *
3078355f576SJeff Roberson  */
3088355f576SJeff Roberson 
3098355f576SJeff Roberson void uma_startup(void *bootmem);
3108355f576SJeff Roberson 
3118355f576SJeff Roberson /*
3128355f576SJeff Roberson  * Finishes starting up the allocator.  This should
3138355f576SJeff Roberson  * be called when kva is ready for normal allocs.
3148355f576SJeff Roberson  *
3158355f576SJeff Roberson  * Arguments:
3168355f576SJeff Roberson  *	hash   An area of memory that will become the malloc hash
3178355f576SJeff Roberson  *	elems  The number of elements in this array
3188355f576SJeff Roberson  *
3198355f576SJeff Roberson  * Returns:
3208355f576SJeff Roberson  *	Nothing
3218355f576SJeff Roberson  *
3228355f576SJeff Roberson  * Discussion:
3238355f576SJeff Roberson  *	uma_startup2 is called by kmeminit() to prepare the malloc
3248355f576SJeff Roberson  *	hash bucket, and enable use of uma for malloc ops.
3258355f576SJeff Roberson  */
3268355f576SJeff Roberson 
3278355f576SJeff Roberson void uma_startup2(void *hash, u_long elems);
3288355f576SJeff Roberson 
3298355f576SJeff Roberson /*
3308355f576SJeff Roberson  * Reclaims unused memory for all zones
3318355f576SJeff Roberson  *
3328355f576SJeff Roberson  * Arguments:
3338355f576SJeff Roberson  *	None
3348355f576SJeff Roberson  * Returns:
3358355f576SJeff Roberson  *	None
3368355f576SJeff Roberson  *
3378355f576SJeff Roberson  * This should only be called by the page out daemon.
3388355f576SJeff Roberson  */
3398355f576SJeff Roberson 
3408355f576SJeff Roberson void uma_reclaim(void);
3418355f576SJeff Roberson 
3428355f576SJeff Roberson /*
3438355f576SJeff Roberson  * Switches the backing object of a zone
3448355f576SJeff Roberson  *
3458355f576SJeff Roberson  * Arguments:
3468355f576SJeff Roberson  *	zone  The zone to update
3478355f576SJeff Roberson  *	obj   The obj to use for future allocations
3488355f576SJeff Roberson  *	size  The size of the object to allocate
3498355f576SJeff Roberson  *
3508355f576SJeff Roberson  * Returns:
3518355f576SJeff Roberson  *	0  if kva space can not be allocated
3528355f576SJeff Roberson  *	1  if successful
3538355f576SJeff Roberson  *
3548355f576SJeff Roberson  * Discussion:
3558355f576SJeff Roberson  *	A NULL object can be used and uma will allocate one for you.  Setting
3568355f576SJeff Roberson  *	the size will limit the amount of memory allocated to this zone.
3578355f576SJeff Roberson  *
3588355f576SJeff Roberson  */
3598355f576SJeff Roberson struct vm_object;
3608355f576SJeff Roberson int uma_zone_set_obj(uma_zone_t zone, struct vm_object *obj, int size);
3618355f576SJeff Roberson 
362736ee590SJeff Roberson /*
363736ee590SJeff Roberson  * Sets a high limit on the number of items allowed in a zone
364736ee590SJeff Roberson  *
365736ee590SJeff Roberson  * Arguments:
366736ee590SJeff Roberson  *	zone  The zone to limit
367736ee590SJeff Roberson  *
368736ee590SJeff Roberson  * Returns:
369736ee590SJeff Roberson  *	Nothing
370736ee590SJeff Roberson  */
371736ee590SJeff Roberson void uma_zone_set_max(uma_zone_t zone, int nitems);
3728355f576SJeff Roberson 
3738355f576SJeff Roberson /*
3748355f576SJeff Roberson  * Replaces the standard page_alloc or obj_alloc functions for this zone
3758355f576SJeff Roberson  *
3768355f576SJeff Roberson  * Arguments:
3778355f576SJeff Roberson  *	zone   The zone whos back end allocator is being changed.
3788355f576SJeff Roberson  *	allocf A pointer to the allocation function
3798355f576SJeff Roberson  *
3808355f576SJeff Roberson  * Returns:
3818355f576SJeff Roberson  *	Nothing
3828355f576SJeff Roberson  *
3838355f576SJeff Roberson  * Discussion:
3848355f576SJeff Roberson  *	This could be used to implement pageable allocation, or perhaps
3858355f576SJeff Roberson  *	even DMA allocators if used in conjunction with the OFFPAGE
3868355f576SJeff Roberson  *	zone flag.
3878355f576SJeff Roberson  */
3888355f576SJeff Roberson 
3898355f576SJeff Roberson void uma_zone_set_allocf(uma_zone_t zone, uma_alloc allocf);
3908355f576SJeff Roberson 
3918355f576SJeff Roberson /*
3928355f576SJeff Roberson  * Used for freeing memory provided by the allocf above
3938355f576SJeff Roberson  *
3948355f576SJeff Roberson  * Arguments:
3958355f576SJeff Roberson  *	zone  The zone that intends to use this free routine.
3968355f576SJeff Roberson  *	freef The page freeing routine.
3978355f576SJeff Roberson  *
3988355f576SJeff Roberson  * Returns:
3998355f576SJeff Roberson  *	Nothing
4008355f576SJeff Roberson  */
4018355f576SJeff Roberson 
4028355f576SJeff Roberson void uma_zone_set_freef(uma_zone_t zone, uma_free freef);
4038355f576SJeff Roberson 
4048355f576SJeff Roberson /*
4058355f576SJeff Roberson  * These flags are setable in the allocf and visable in the freef.
4068355f576SJeff Roberson  */
4078355f576SJeff Roberson #define UMA_SLAB_BOOT	0x01		/* Slab alloced from boot pages */
4088355f576SJeff Roberson #define UMA_SLAB_KMEM	0x02		/* Slab alloced from kmem_map */
4098355f576SJeff Roberson #define UMA_SLAB_KMAP	0x04		/* Slab alloced from kernel_map */
4108355f576SJeff Roberson #define UMA_SLAB_PRIV	0x08		/* Slab alloced from priv allocator */
4118355f576SJeff Roberson #define UMA_SLAB_OFFP	0x10		/* Slab is managed seperately  */
4128355f576SJeff Roberson #define UMA_SLAB_MALLOC	0x20		/* Slab is a large malloc slab */
4138355f576SJeff Roberson /* 0x40 and 0x80 are available */
4148355f576SJeff Roberson 
4158355f576SJeff Roberson /*
4168355f576SJeff Roberson  * Used to pre-fill a zone with some number of items
4178355f576SJeff Roberson  *
4188355f576SJeff Roberson  * Arguments:
4198355f576SJeff Roberson  *	zone    The zone to fill
4208355f576SJeff Roberson  *	itemcnt The number of items to reserve
4218355f576SJeff Roberson  *
4228355f576SJeff Roberson  * Returns:
4238355f576SJeff Roberson  *	Nothing
4248355f576SJeff Roberson  *
4258355f576SJeff Roberson  * NOTE: This is blocking and should only be done at startup
4268355f576SJeff Roberson  */
4278355f576SJeff Roberson void uma_prealloc(uma_zone_t zone, int itemcnt);
4288355f576SJeff Roberson 
4298355f576SJeff Roberson 
4308355f576SJeff Roberson #endif
431