mirror of
https://git.FreeBSD.org/src.git
synced 2025-02-03 17:11:32 +00:00
Add uma_zone_get_max() to obtain the effective limit after a call
to uma_zone_set_max(). The UMA zone limit is not exactly set to the value supplied but rounded up to completely fill the backing store increment (a page normally). This can lead to surprising situations where the number of elements allocated from UMA is higher than the supplied limit value. The new get function reads back the effective value so that the supplied limit value can be adjusted to the real limit. Reviewed by: jeffr MFC after: 1 week
This commit is contained in:
parent
13852a6e15
commit
e49471b04b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=211396
12
sys/vm/uma.h
12
sys/vm/uma.h
@ -458,6 +458,18 @@ int uma_zone_set_obj(uma_zone_t zone, struct vm_object *obj, int size);
|
||||
*/
|
||||
void uma_zone_set_max(uma_zone_t zone, int nitems);
|
||||
|
||||
/*
|
||||
* Obtains the effective limit on the number of items in a zone
|
||||
*
|
||||
* Arguments:
|
||||
* zone The zone to obtain the effective limit from
|
||||
*
|
||||
* Return:
|
||||
* 0 No limit
|
||||
* int The effective limit of the zone
|
||||
*/
|
||||
int uma_zone_get_max(uma_zone_t zone);
|
||||
|
||||
/*
|
||||
* The following two routines (uma_zone_set_init/fini)
|
||||
* are used to set the backend init/fini pair which acts on an
|
||||
|
@ -2796,6 +2796,24 @@ uma_zone_set_max(uma_zone_t zone, int nitems)
|
||||
ZONE_UNLOCK(zone);
|
||||
}
|
||||
|
||||
/* See uma.h */
|
||||
int
|
||||
uma_zone_get_max(uma_zone_t zone)
|
||||
{
|
||||
int nitems;
|
||||
uma_keg_t keg;
|
||||
|
||||
ZONE_LOCK(zone);
|
||||
keg = zone_first_keg(zone);
|
||||
if (keg->uk_maxpages)
|
||||
nitems = keg->uk_maxpages * keg->uk_ipers;
|
||||
else
|
||||
nitems = 0;
|
||||
ZONE_UNLOCK(zone);
|
||||
|
||||
return (nitems);
|
||||
}
|
||||
|
||||
/* See uma.h */
|
||||
void
|
||||
uma_zone_set_init(uma_zone_t zone, uma_init uminit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user