1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-25 11:37:56 +00:00

Change uma_zone_set_max to return the effective value of "nitems" after

rounding. The same value can also be obtained with uma_zone_get_max, but this
change avoids a caller having to make two back-to-back calls.

Sponsored by:	FreeBSD Foundation
Reviewed by:	gnn, jhb
This commit is contained in:
Lawrence Stewart 2010-10-16 04:41:45 +00:00
parent c4ae7908a7
commit 1c6cae9711
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=213911
3 changed files with 11 additions and 8 deletions

View File

@ -59,7 +59,7 @@
.Fn uma_zfree_arg "uma_zone_t zone" "void *item" "void *arg"
.Ft void
.Fn uma_zdestroy "uma_zone_t zone"
.Ft void
.Ft int
.Fn uma_zone_set_max "uma_zone_t zone" "int nitems"
.Ft int
.Fn uma_zone_get_max "uma_zone_t zone"
@ -185,9 +185,9 @@ that can be allocated to
The
.Fa nitems
argument specifies the requested upper limit number of items.
The effective limit may end up being higher than requested, as the
implementation will round up to ensure all memory pages allocated to the zone
are utilised to capacity.
The effective limit is returned to the caller, as it may end up being higher
than requested due to the implementation rounding up to ensure all memory pages
allocated to the zone are utilised to capacity.
The limit applies to 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

View File

@ -452,11 +452,12 @@ int uma_zone_set_obj(uma_zone_t zone, struct vm_object *obj, int size);
*
* Arguments:
* zone The zone to limit
* nitems The requested upper limit on the number of items allowed
*
* Returns:
* Nothing
* int The effective value of nitems after rounding up based on page size
*/
void uma_zone_set_max(uma_zone_t zone, int nitems);
int uma_zone_set_max(uma_zone_t zone, int nitems);
/*
* Obtains the effective limit on the number of items in a zone

View File

@ -2782,7 +2782,7 @@ zone_free_item(uma_zone_t zone, void *item, void *udata,
}
/* See uma.h */
void
int
uma_zone_set_max(uma_zone_t zone, int nitems)
{
uma_keg_t keg;
@ -2792,8 +2792,10 @@ uma_zone_set_max(uma_zone_t zone, int nitems)
keg->uk_maxpages = (nitems / keg->uk_ipers) * keg->uk_ppera;
if (keg->uk_maxpages * keg->uk_ipers < nitems)
keg->uk_maxpages += keg->uk_ppera;
nitems = keg->uk_maxpages * keg->uk_ipers;
ZONE_UNLOCK(zone);
return (nitems);
}
/* See uma.h */