summaryrefslogtreecommitdiffstats
path: root/sys/vm/uma_core.c
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2002-03-20 05:28:34 +0000
committerjeff <jeff@FreeBSD.org>2002-03-20 05:28:34 +0000
commitaa0e8b9e515b3df6d81ffe9b1e252449fe6efb7b (patch)
tree2bde23573b4710d2ce6cbe8b09b39802f83ecc04 /sys/vm/uma_core.c
parent95b805ab3ba49af1a775609fd71d8bd8617ca30c (diff)
downloadFreeBSD-src-aa0e8b9e515b3df6d81ffe9b1e252449fe6efb7b.zip
FreeBSD-src-aa0e8b9e515b3df6d81ffe9b1e252449fe6efb7b.tar.gz
Add uma_zone_set_max() to add enforced limits to non vm obj backed zones.
Diffstat (limited to 'sys/vm/uma_core.c')
-rw-r--r--sys/vm/uma_core.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 5b4be4b..2f1b765 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -599,6 +599,9 @@ slab_zalloc(uma_zone_t zone, int wait)
#ifdef UMA_DEBUG
printf("slab_zalloc: Allocating a new slab for %s\n", zone->uz_name);
#endif
+ if (zone->uz_maxpages &&
+ zone->uz_pages + zone->uz_ppera > zone->uz_maxpages)
+ return (NULL);
if (booted || (zone->uz_flags & UMA_ZFLAG_PRIVALLOC)) {
ZONE_UNLOCK(zone);
@@ -734,10 +737,6 @@ obj_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
vm_page_t p;
int pages;
-
- if (zone->uz_pages + zone->uz_ppera > zone->uz_maxpages)
- return (NULL);
-
retkva = NULL;
pages = zone->uz_pages;
@@ -1242,12 +1241,6 @@ zalloc_start:
* If isitem is set then we should just return it. The cpu lock
* was unlocked when we couldn't get a bucket.
*/
-
-#ifdef INVARIANTS
- if (wait == M_WAITOK)
- KASSERT(item != NULL,
- ("uma_zalloc: WAITOK set but we're returning NULL"));
-#endif
return item;
}
@@ -1678,6 +1671,18 @@ uma_zfree_internal(uma_zone_t zone, void *item, void *udata, int skip)
/* See uma.h */
void
+uma_zone_set_max(uma_zone_t zone, int nitems)
+{
+ ZONE_LOCK(zone);
+ if (zone->uz_ppera > 1)
+ zone->uz_maxpages = nitems / zone->uz_ppera;
+ else
+ zone->uz_maxpages = nitems / zone->uz_ipers;
+ ZONE_UNLOCK(zone);
+}
+
+/* See uma.h */
+void
uma_zone_set_freef(uma_zone_t zone, uma_free freef)
{
ZONE_LOCK(zone);
OpenPOWER on IntegriCloud