isc_mempool_create(mctx, COMMSIZE, &commctx);
isc_mempool_setname(commctx, "COMMPOOL");
- /*
- * 6 and 2 set as reasonable parameters for 3 or 4 nameserver
- * systems.
- */
- isc_mempool_setfreemax(commctx, 6);
isc_mutex_init(&lookup_lock);
}
CHECK(isc_ht_init(&inst->ht, mctx, 16));
isc_mutex_init(&inst->hlock);
- /*
- * We don't set any limit on the number of free state objects
- * so that they'll always be returned to the pool and not
- * freed until the pool is destroyed on shutdown.
- */
- isc_mempool_setfreemax(inst->datapool, UINT_MAX);
isc_mutex_init(&inst->plock);
isc_mempool_associatelock(inst->datapool, &inst->plock);
#define ADB_STALE_MARGIN 1800
#endif /* ifndef ADB_STALE_MARGIN */
-#define FREE_ITEMS 64 /*%< free count for memory pools */
-#define FILL_COUNT 16 /*%< fill count for memory pools */
-
#define DNS_ADB_INVALIDBUCKET (-1) /*%< invalid bucket address */
#define DNS_ADB_MINADBSIZE (1024U * 1024U) /*%< 1 Megabyte */
#define MPINIT(t, p, n) \
do { \
isc_mempool_create(mem, sizeof(t), &(p)); \
- isc_mempool_setfreemax((p), FREE_ITEMS); \
isc_mempool_setname((p), n); \
isc_mempool_associatelock((p), &adb->mplock); \
} while (0)
isc_mempool_create(mgr->mctx, sizeof(dns_dispatch_t), &mgr->dpool);
isc_mempool_setname(mgr->depool, "dispmgr_depool");
- isc_mempool_setfreemax(mgr->depool, 32768);
isc_mempool_associatelock(mgr->depool, &mgr->depool_lock);
isc_mempool_setname(mgr->rpool, "dispmgr_rpool");
- isc_mempool_setfreemax(mgr->rpool, 32768);
isc_mempool_associatelock(mgr->rpool, &mgr->rpool_lock);
isc_mempool_setname(mgr->dpool, "dispmgr_dpool");
- isc_mempool_setfreemax(mgr->dpool, 32768);
isc_mempool_associatelock(mgr->dpool, &mgr->dpool_lock);
mgr->buffers = 0;
REQUIRE(buckets < 2097169); /* next prime > 65536 * 32 */
REQUIRE(increment > buckets);
+ UNUSED(maxrequests);
+
/*
* Keep some number of items around. This should be a config
* option. For now, keep 8, but later keep at least two even
* complexity.
*/
if (maxbuffers > mgr->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_setfreemax(mgr->bpool, maxbuffers);
isc_mempool_associatelock(mgr->bpool, &mgr->bpool_lock);
}
/* Create or adjust socket pool */
if (mgr->spool != NULL) {
- if (maxrequests < DNS_DISPATCH_POOLSOCKS * 2) {
- isc_mempool_setfreemax(mgr->spool,
- DNS_DISPATCH_POOLSOCKS * 2);
- }
UNLOCK(&mgr->buffer_lock);
return (ISC_R_SUCCESS);
}
isc_mempool_create(mgr->mctx, sizeof(dispsocket_t), &mgr->spool);
isc_mempool_setname(mgr->spool, "dispmgr_spool");
- isc_mempool_setfreemax(mgr->spool, maxrequests);
isc_mempool_associatelock(mgr->spool, &mgr->spool_lock);
result = qid_allocate(mgr, buckets, increment, &mgr->qid, true);
isc_mempool_create(mgr->mctx, sizeof(dispportentry_t),
&disp->portpool);
isc_mempool_setname(disp->portpool, "disp_portpool");
- isc_mempool_setfreemax(disp->portpool, 128);
}
disp->socket = sock;
disp->local = *localaddr;
isc_mutex_init(&disp->sepool_lock);
isc_mempool_setname(disp->sepool, "disp_sepool");
- isc_mempool_setfreemax(disp->sepool, 32768);
isc_mempool_associatelock(disp->sepool, &disp->sepool_lock);
attributes &= ~DNS_DISPATCHATTR_TCP;
ISC_LIST_INIT(m->freerdatalist);
isc_mempool_create(m->mctx, sizeof(dns_name_t), &m->namepool);
- isc_mempool_setfreemax(m->namepool, NAME_COUNT);
isc_mempool_setname(m->namepool, "msg:names");
isc_mempool_create(m->mctx, sizeof(dns_rdataset_t), &m->rdspool);
- isc_mempool_setfreemax(m->rdspool, RDATASET_COUNT);
isc_mempool_setname(m->rdspool, "msg:rdataset");
dynbuf = NULL;
*\li mpctxp != NULL and *mpctxp == NULL
*
* Defaults:
- *\li freemax = 1
*
* Returns:
*\li #ISC_R_NOMEMORY -- not enough memory to create pool
* the unlocked nature of pools these are potentially random values
* unless the imposed externally provided locking protocols are followed.
*
- * Also note that the quota limits will not always take immediate
- * effect.
- *
* All functions require (in addition to other requirements):
* mpctx is a valid memory pool
*/
-unsigned int
-isc_mempool_getfreemax(isc_mempool_t *mpctx);
-/*%<
- * Returns the maximum allowed size of the free list.
- */
-
-void
-isc_mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit);
-/*%<
- * Sets the maximum allowed size of the free list.
- */
-
unsigned int
isc_mempool_getfreecount(isc_mempool_t *mpctx);
/*%<
size_t size; /*%< size of each item on this pool */
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 */
/*%< Stats only. */
atomic_size_t gets; /*%< # of requests to this pool */
/*%< Debugging only. */
pool = ISC_LIST_HEAD(ctx->pools);
if (pool != NULL) {
fprintf(out, "[Pool statistics]\n");
- fprintf(out, "%15s %10s %10s %10s %10s %10s %1s\n", "name",
- "size", "allocated", "freecount", "freemax",
+ fprintf(out, "%15s %10s %10s %10s %10s %1s\n", "name",
+ "size", "allocated", "freecount",
"gets", "L");
}
while (pool != NULL) {
- fprintf(out, "%15s %10zu %10zu %10zu %10zu %10zu %s\n",
+ fprintf(out, "%15s %10zu %10zu %10zu %10zu %s\n",
pool->name, pool->size,
atomic_load_relaxed(&pool->allocated),
atomic_load_relaxed(&pool->freecount),
- atomic_load_relaxed(&pool->freemax),
atomic_load_relaxed(&pool->gets),
(pool->lock == NULL ? "N" : "Y"));
pool = ISC_LIST_NEXT(pool, link);
atomic_init(&mpctx->allocated, 0);
atomic_init(&mpctx->freecount, 0);
- atomic_init(&mpctx->freemax, 1);
*mpctxp = (isc_mempool_t *)mpctx;
REQUIRE(VALID_MEMPOOL(mpctx));
element *item;
- unsigned int i;
MPCTXLOCK(mpctx);
if (ISC_UNLIKELY(mpctx->items == NULL)) {
isc_mem_t *mctx = mpctx->mctx;
item = mem_get(mctx, mpctx->size);
mem_getstats(mctx, mpctx->size);
- item->next = NULL;
} else {
item = mpctx->items;
+ mpctx->items = item->next;
}
+ MPCTXUNLOCK(mpctx);
+
REQUIRE(item != NULL);
- mpctx->items = item->next;
+ item->next = NULL;
INSIST(atomic_fetch_sub_release(&mpctx->freecount, 1) > 0);
atomic_fetch_add_relaxed(&mpctx->gets, 1);
ADD_TRACE(mpctx->mctx, item, mpctx->size, file, line);
-out:
- MPCTXUNLOCK(mpctx);
-
return (item);
}
isc_mem_t *mctx = mpctx->mctx;
size_t freecount = atomic_load_acquire(&mpctx->freecount);
- size_t freemax = atomic_load_acquire(&mpctx->freemax);
+ size_t allocated = atomic_fetch_sub_release(&mpctx->allocated, 1);
- INSIST(atomic_fetch_sub_release(&mpctx->allocated, 1) > 0);
+ INSIST(allocated > 0);
DELETE_TRACE(mctx, mem, mpctx->size, file, line);
/*
- * If our free list is full, return this to the mctx directly.
+ * If the number of freeitems is more than number of allocated items,
+ * return the item to the allocator.
*/
- if (freecount >= freemax) {
+ if (freecount >= allocated) {
mem_putstats(mctx, mem, mpctx->size);
mem_put(mctx, mem, mpctx->size);
return;
* Quotas
*/
-void
-isc_mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit) {
- REQUIRE(VALID_MEMPOOL(mpctx));
-
- atomic_store_release(&mpctx->freemax, limit);
-}
-
-unsigned int
-isc_mempool_getfreemax(isc_mempool_t *mpctx) {
- REQUIRE(VALID_MEMPOOL(mpctx));
-
- return (atomic_load_acquire(&mpctx->freemax));
-}
-
unsigned int
isc_mempool_getfreecount(isc_mempool_t *mpctx) {
REQUIRE(VALID_MEMPOOL(mpctx));
isc_mutex_init(&mgr->reqlock);
isc_mempool_create(mgr->mctx, sizeof(isc__nm_uvreq_t), &mgr->reqpool);
isc_mempool_setname(mgr->reqpool, "nm_reqpool");
- isc_mempool_setfreemax(mgr->reqpool, 4096);
isc_mempool_associatelock(mgr->reqpool, &mgr->reqlock);
isc_mutex_init(&mgr->evlock);
isc_mempool_create(mgr->mctx, sizeof(isc__netievent_storage_t),
&mgr->evpool);
isc_mempool_setname(mgr->evpool, "nm_evpool");
- isc_mempool_setfreemax(mgr->evpool, 4096);
isc_mempool_associatelock(mgr->evpool, &mgr->evlock);
mgr->workers = isc_mem_get(mctx, workers * sizeof(isc__networker_t));
return (0);
}
-#define MP1_FREEMAX 10
#define MP1_MAXALLOC 30
-#define MP2_FREEMAX 25
-
/* general memory system tests */
static void
isc_mem_test(void **state) {
isc_mempool_create(test_mctx, 24, &mp1);
isc_mempool_create(test_mctx, 31, &mp2);
- isc_mempool_setfreemax(mp1, MP1_FREEMAX);
-
/*
* Allocate MP1_MAXALLOC items from the pool. This is our max.
*/
* them, then allocate 50 more, etc.
*/
- isc_mempool_setfreemax(mp2, 25);
-
for (j = 0; j < 500000; j++) {
for (i = 0; i < 50; i++) {
items2[i] = isc_mempool_get(mp2);
isc_mempool_associatelock(mp, &mplock);
- isc_mempool_setfreemax(mp, 32768);
-
UNUSED(state);
result = isc_time_now(&ts1);
isc_mempool_destroy
isc_mempool_getallocated
isc_mempool_getfreecount
-isc_mempool_getfreemax
-isc_mempool_setfreemax
isc_mempool_setname
isc_mutexblock_destroy
isc_mutexblock_init