diff --git a/sys/vm/uma.h b/sys/vm/uma.h index 2076d3bd0b61..f0522b01631d 100644 --- a/sys/vm/uma.h +++ b/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 diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 2dcd14fdd1a3..558b4c727e75 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -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)