Add uma_zone_set_max() to add enforced limits to non vm obj backed zones.
This commit is contained in:
parent
95b805ab3b
commit
aa0e8b9e51
10
sys/vm/uma.h
10
sys/vm/uma.h
@ -359,6 +359,16 @@ void uma_reclaim(void);
|
|||||||
struct vm_object;
|
struct vm_object;
|
||||||
int uma_zone_set_obj(uma_zone_t zone, struct vm_object *obj, int size);
|
int uma_zone_set_obj(uma_zone_t zone, struct vm_object *obj, int size);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets a high limit on the number of items allowed in a zone
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* zone The zone to limit
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* Nothing
|
||||||
|
*/
|
||||||
|
void uma_zone_set_max(uma_zone_t zone, int nitems);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Replaces the standard page_alloc or obj_alloc functions for this zone
|
* Replaces the standard page_alloc or obj_alloc functions for this zone
|
||||||
|
@ -599,6 +599,9 @@ slab_zalloc(uma_zone_t zone, int wait)
|
|||||||
#ifdef UMA_DEBUG
|
#ifdef UMA_DEBUG
|
||||||
printf("slab_zalloc: Allocating a new slab for %s\n", zone->uz_name);
|
printf("slab_zalloc: Allocating a new slab for %s\n", zone->uz_name);
|
||||||
#endif
|
#endif
|
||||||
|
if (zone->uz_maxpages &&
|
||||||
|
zone->uz_pages + zone->uz_ppera > zone->uz_maxpages)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
if (booted || (zone->uz_flags & UMA_ZFLAG_PRIVALLOC)) {
|
if (booted || (zone->uz_flags & UMA_ZFLAG_PRIVALLOC)) {
|
||||||
ZONE_UNLOCK(zone);
|
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;
|
vm_page_t p;
|
||||||
int pages;
|
int pages;
|
||||||
|
|
||||||
|
|
||||||
if (zone->uz_pages + zone->uz_ppera > zone->uz_maxpages)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
retkva = NULL;
|
retkva = NULL;
|
||||||
pages = zone->uz_pages;
|
pages = zone->uz_pages;
|
||||||
|
|
||||||
@ -1242,12 +1241,6 @@ zalloc_start:
|
|||||||
* If isitem is set then we should just return it. The cpu lock
|
* If isitem is set then we should just return it. The cpu lock
|
||||||
* was unlocked when we couldn't get a bucket.
|
* 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;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1676,6 +1669,18 @@ uma_zfree_internal(uma_zone_t zone, void *item, void *udata, int skip)
|
|||||||
zone->uz_dtor(item, zone->uz_size, udata);
|
zone->uz_dtor(item, zone->uz_size, udata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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 */
|
/* See uma.h */
|
||||||
void
|
void
|
||||||
uma_zone_set_freef(uma_zone_t zone, uma_free freef)
|
uma_zone_set_freef(uma_zone_t zone, uma_free freef)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user