isc_mempool_create(mgr->mctx, sizeof(dns_dispatch_t), &mgr->dpool);
isc_mempool_setname(mgr->depool, "dispmgr_depool");
- isc_mempool_setmaxalloc(mgr->depool, 32768);
isc_mempool_setfreemax(mgr->depool, 32768);
isc_mempool_associatelock(mgr->depool, &mgr->depool_lock);
isc_mempool_setfillcount(mgr->depool, 32);
isc_mempool_setname(mgr->rpool, "dispmgr_rpool");
- isc_mempool_setmaxalloc(mgr->rpool, 32768);
isc_mempool_setfreemax(mgr->rpool, 32768);
isc_mempool_associatelock(mgr->rpool, &mgr->rpool_lock);
isc_mempool_setfillcount(mgr->rpool, 32);
isc_mempool_setname(mgr->dpool, "dispmgr_dpool");
- isc_mempool_setmaxalloc(mgr->dpool, 32768);
isc_mempool_setfreemax(mgr->dpool, 32768);
isc_mempool_associatelock(mgr->dpool, &mgr->dpool_lock);
isc_mempool_setfillcount(mgr->dpool, 32);
* complexity.
*/
if (maxbuffers > mgr->maxbuffers) {
- isc_mempool_setmaxalloc(mgr->bpool, maxbuffers);
isc_mempool_setfreemax(mgr->bpool, maxbuffers);
mgr->maxbuffers = maxbuffers;
}
} else {
isc_mempool_create(mgr->mctx, buffersize, &mgr->bpool);
isc_mempool_setname(mgr->bpool, "dispmgr_bpool");
- isc_mempool_setmaxalloc(mgr->bpool, maxbuffers);
isc_mempool_setfreemax(mgr->bpool, maxbuffers);
isc_mempool_associatelock(mgr->bpool, &mgr->bpool_lock);
isc_mempool_setfillcount(mgr->bpool, 32);
/* Create or adjust socket pool */
if (mgr->spool != NULL) {
if (maxrequests < DNS_DISPATCH_POOLSOCKS * 2) {
- isc_mempool_setmaxalloc(mgr->spool,
- DNS_DISPATCH_POOLSOCKS * 2);
isc_mempool_setfreemax(mgr->spool,
DNS_DISPATCH_POOLSOCKS * 2);
}
isc_mempool_create(mgr->mctx, sizeof(dispsocket_t), &mgr->spool);
isc_mempool_setname(mgr->spool, "dispmgr_spool");
- isc_mempool_setmaxalloc(mgr->spool, maxrequests);
isc_mempool_setfreemax(mgr->spool, maxrequests);
isc_mempool_associatelock(mgr->spool, &mgr->spool_lock);
isc_mempool_setfillcount(mgr->spool, 32);
isc_mutex_init(&disp->sepool_lock);
isc_mempool_setname(disp->sepool, "disp_sepool");
- isc_mempool_setmaxalloc(disp->sepool, 32768);
isc_mempool_setfreemax(disp->sepool, 32768);
isc_mempool_associatelock(disp->sepool, &disp->sepool_lock);
isc_mempool_setfillcount(disp->sepool, 16);
*\li mpctxp != NULL and *mpctxp == NULL
*
* Defaults:
- *\li maxalloc = UINT_MAX
*\li freemax = 1
*\li fillcount = 1
*
/*
* The following functions get/set various parameters. Note that due to
* the unlocked nature of pools these are potentially random values
- *unless the imposed externally provided locking protocols are followed.
+ * unless the imposed externally provided locking protocols are followed.
*
* Also note that the quota limits will not always take immediate
- *effect. For instance, setting "maxalloc" to a number smaller than the
- *currently allocated count is permitted. New allocations will be
- *refused until the count drops below this threshold.
+ * effect.
*
* All functions require (in addition to other requirements):
* mpctx is a valid memory pool
* Returns current size of the free list.
*/
-unsigned int
-isc_mempool_getmaxalloc(isc_mempool_t *mpctx);
-/*!<
- * Returns the maximum allowed number of allocations.
- */
-
-void
-isc_mempool_setmaxalloc(isc_mempool_t *mpctx, unsigned int limit);
-/*%<
- * Sets the maximum allowed number of allocations.
- *
- * Additional requirements:
- *\li limit > 0
- */
-
unsigned int
isc_mempool_getallocated(isc_mempool_t *mpctx);
/*%<
/*%< optionally locked from here down */
element *items; /*%< low water item list */
size_t size; /*%< size of each item on this pool */
- atomic_size_t maxalloc; /*%< max number of items allowed */
atomic_size_t allocated; /*%< # of items currently given out */
atomic_size_t freecount; /*%< # of items on reserved list */
atomic_size_t freemax; /*%< # of items allowed on free list */
pool = ISC_LIST_HEAD(ctx->pools);
if (pool != NULL) {
fprintf(out, "[Pool statistics]\n");
- fprintf(out, "%15s %10s %10s %10s %10s %10s %10s %10s %1s\n",
- "name", "size", "maxalloc", "allocated", "freecount",
- "freemax", "fillcount", "gets", "L");
+ fprintf(out, "%15s %10s %10s %10s %10s %10s %10s %1s\n", "name",
+ "size", "allocated", "freecount", "freemax",
+ "fillcount", "gets", "L");
}
while (pool != NULL) {
- fprintf(out,
- "%15s %10zu %10zu %10zu %10zu %10zu %10zu %10zu %s\n",
+ fprintf(out, "%15s %10zu %10zu %10zu %10zu %10zu %10zu %s\n",
pool->name, pool->size,
- atomic_load_relaxed(&pool->maxalloc),
atomic_load_relaxed(&pool->allocated),
atomic_load_relaxed(&pool->freecount),
atomic_load_relaxed(&pool->freemax),
.size = size,
};
- atomic_init(&mpctx->maxalloc, SIZE_MAX);
atomic_init(&mpctx->allocated, 0);
atomic_init(&mpctx->freecount, 0);
atomic_init(&mpctx->freemax, 1);
isc__mempool_get(isc_mempool_t *mpctx FLARG) {
REQUIRE(VALID_MEMPOOL(mpctx));
- size_t allocated = atomic_fetch_add_release(&mpctx->allocated, 1);
- size_t maxalloc = atomic_load_acquire(&mpctx->maxalloc);
-
- /*
- * Don't let the caller go over quota.
- */
- if (ISC_UNLIKELY(allocated >= maxalloc)) {
- atomic_fetch_sub_release(&mpctx->allocated, 1);
- return (NULL);
- }
-
- atomic_fetch_add_relaxed(&mpctx->gets, 1);
+ (void)atomic_fetch_add_release(&mpctx->allocated, 1);
+ (void)atomic_fetch_add_relaxed(&mpctx->gets, 1);
return (isc__mem_get(mpctx->mctx, mpctx->size FLARG_PASS));
}
REQUIRE(VALID_MEMPOOL(mpctx));
- size_t allocated = atomic_fetch_add_release(&mpctx->allocated, 1);
- size_t maxalloc = atomic_load_acquire(&mpctx->maxalloc);
-
- /*
- * Don't let the caller go over quota
- */
- if (ISC_UNLIKELY(allocated >= maxalloc)) {
- atomic_fetch_sub_release(&mpctx->allocated, 1);
- return (NULL);
- }
+ element *item;
+ unsigned int i;
MPCTXLOCK(mpctx);
if (ISC_UNLIKELY(mpctx->items == NULL)) {
*/
item = mpctx->items;
if (ISC_UNLIKELY(item == NULL)) {
- atomic_fetch_sub_release(&mpctx->allocated, 1);
goto out;
}
INSIST(atomic_fetch_sub_release(&mpctx->freecount, 1) > 0);
atomic_fetch_add_relaxed(&mpctx->gets, 1);
+ atomic_fetch_add_release(&mpctx->allocated, 1);
ADD_TRACE(mpctx->mctx, item, mpctx->size, file, line);
return (atomic_load_relaxed(&mpctx->freecount));
}
-void
-isc_mempool_setmaxalloc(isc_mempool_t *mpctx, unsigned int limit) {
- REQUIRE(VALID_MEMPOOL(mpctx));
- REQUIRE(limit > 0);
-
- atomic_store_release(&mpctx->maxalloc, limit);
-}
-
-unsigned int
-isc_mempool_getmaxalloc(isc_mempool_t *mpctx) {
- REQUIRE(VALID_MEMPOOL(mpctx));
-
- return (atomic_load_relaxed(&mpctx->maxalloc));
-}
-
unsigned int
isc_mempool_getallocated(isc_mempool_t *mpctx) {
REQUIRE(VALID_MEMPOOL(mpctx));
isc_mempool_setfreemax(mp1, MP1_FREEMAX);
isc_mempool_setfillcount(mp1, MP1_FILLCNT);
- isc_mempool_setmaxalloc(mp1, MP1_MAXALLOC);
/*
* Allocate MP1_MAXALLOC items from the pool. This is our max.
assert_non_null(items1[i]);
}
- /*
- * Try to allocate one more. This should fail.
- */
- tmp = isc_mempool_get(mp1);
- assert_null(tmp);
-
/*
* Free the first 11 items. Verify that there are 10 free items on
* the free list (which is our max).
isc_mempool_getfillcount
isc_mempool_getfreecount
isc_mempool_getfreemax
-isc_mempool_getmaxalloc
isc_mempool_setfillcount
isc_mempool_setfreemax
-isc_mempool_setmaxalloc
isc_mempool_setname
isc_mutexblock_destroy
isc_mutexblock_init