Make our replacement INT32_MAX always signed
[tor/rransom.git] / src / common / mempool.c
blob9538a05489892a02e5452c9fc3bd740101a0ed3b
1 /* Copyright (c) 2007-2011, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 #if 1
4 /* Tor dependencies */
5 #include "orconfig.h"
6 #endif
8 #include <stdlib.h>
9 #include <string.h>
10 #include "torint.h"
11 #define MEMPOOL_PRIVATE
12 #include "mempool.h"
14 /* OVERVIEW:
16 * This is an implementation of memory pools for Tor cells. It may be
17 * useful for you too.
19 * Generally, a memory pool is an allocation strategy optimized for large
20 * numbers of identically-sized objects. Rather than the elaborate arena
21 * and coalescing strategies you need to get good performance for a
22 * general-purpose malloc(), pools use a series of large memory "chunks",
23 * each of which is carved into a bunch of smaller "items" or
24 * "allocations".
26 * To get decent performance, you need to:
27 * - Minimize the number of times you hit the underlying allocator.
28 * - Try to keep accesses as local in memory as possible.
29 * - Try to keep the common case fast.
31 * Our implementation uses three lists of chunks per pool. Each chunk can
32 * be either "full" (no more room for items); "empty" (no items); or
33 * "used" (not full, not empty). There are independent doubly-linked
34 * lists for each state.
36 * CREDIT:
38 * I wrote this after looking at 3 or 4 other pooling allocators, but
39 * without copying. The strategy this most resembles (which is funny,
40 * since that's the one I looked at longest ago) is the pool allocator
41 * underlying Python's obmalloc code. Major differences from obmalloc's
42 * pools are:
43 * - We don't even try to be threadsafe.
44 * - We only handle objects of one size.
45 * - Our list of empty chunks is doubly-linked, not singly-linked.
46 * (This could change pretty easily; it's only doubly-linked for
47 * consistency.)
48 * - We keep a list of full chunks (so we can have a "nuke everything"
49 * function). Obmalloc's pools leave full chunks to float unanchored.
51 * LIMITATIONS:
52 * - Not even slightly threadsafe.
53 * - Likes to have lots of items per chunks.
54 * - One pointer overhead per allocated thing. (The alternative is
55 * something like glib's use of an RB-tree to keep track of what
56 * chunk any given piece of memory is in.)
57 * - Only aligns allocated things to void* level: redefine ALIGNMENT_TYPE
58 * if you need doubles.
59 * - Could probably be optimized a bit; the representation contains
60 * a bit more info than it really needs to have.
63 #if 1
64 /* Tor dependencies */
65 #include "orconfig.h"
66 #include "util.h"
67 #include "compat.h"
68 #include "log.h"
69 #define ALLOC(x) tor_malloc(x)
70 #define FREE(x) tor_free(x)
71 #define ASSERT(x) tor_assert(x)
72 #undef ALLOC_CAN_RETURN_NULL
73 #define TOR
74 //#define ALLOC_ROUNDUP(p) tor_malloc_roundup(p)
75 /* End Tor dependencies */
76 #else
77 /* If you're not building this as part of Tor, you'll want to define the
78 * following macros. For now, these should do as defaults.
80 #include <assert.h>
81 #define PREDICT_UNLIKELY(x) (x)
82 #define PREDICT_LIKELY(x) (x)
83 #define ALLOC(x) malloc(x)
84 #define FREE(x) free(x)
85 #define STRUCT_OFFSET(tp, member) \
86 ((off_t) (((char*)&((tp*)0)->member)-(char*)0))
87 #define ASSERT(x) assert(x)
88 #define ALLOC_CAN_RETURN_NULL
89 #endif
91 /* Tuning parameters */
92 /** Largest type that we need to ensure returned memory items are aligned to.
93 * Change this to "double" if we need to be safe for structs with doubles. */
94 #define ALIGNMENT_TYPE void *
95 /** Increment that we need to align allocated. */
96 #define ALIGNMENT sizeof(ALIGNMENT_TYPE)
97 /** Largest memory chunk that we should allocate. */
98 #define MAX_CHUNK (8*(1L<<20))
99 /** Smallest memory chunk size that we should allocate. */
100 #define MIN_CHUNK 4096
102 typedef struct mp_allocated_t mp_allocated_t;
103 typedef struct mp_chunk_t mp_chunk_t;
105 /** Holds a single allocated item, allocated as part of a chunk. */
106 struct mp_allocated_t {
107 /** The chunk that this item is allocated in. This adds overhead to each
108 * allocated item, thus making this implementation inappropriate for
109 * very small items. */
110 mp_chunk_t *in_chunk;
111 union {
112 /** If this item is free, the next item on the free list. */
113 mp_allocated_t *next_free;
114 /** If this item is not free, the actual memory contents of this item.
115 * (Not actual size.) */
116 char mem[1];
117 /** An extra element to the union to insure correct alignment. */
118 ALIGNMENT_TYPE _dummy;
119 } u;
122 /** 'Magic' value used to detect memory corruption. */
123 #define MP_CHUNK_MAGIC 0x09870123
125 /** A chunk of memory. Chunks come from malloc; we use them */
126 struct mp_chunk_t {
127 unsigned long magic; /**< Must be MP_CHUNK_MAGIC if this chunk is valid. */
128 mp_chunk_t *next; /**< The next free, used, or full chunk in sequence. */
129 mp_chunk_t *prev; /**< The previous free, used, or full chunk in sequence. */
130 mp_pool_t *pool; /**< The pool that this chunk is part of. */
131 /** First free item in the freelist for this chunk. Note that this may be
132 * NULL even if this chunk is not at capacity: if so, the free memory at
133 * next_mem has not yet been carved into items.
135 mp_allocated_t *first_free;
136 int n_allocated; /**< Number of currently allocated items in this chunk. */
137 int capacity; /**< Number of items that can be fit into this chunk. */
138 size_t mem_size; /**< Number of usable bytes in mem. */
139 char *next_mem; /**< Pointer into part of <b>mem</b> not yet carved up. */
140 char mem[1]; /**< Storage for this chunk. (Not actual size.) */
143 /** Number of extra bytes needed beyond mem_size to allocate a chunk. */
144 #define CHUNK_OVERHEAD STRUCT_OFFSET(mp_chunk_t, mem[0])
146 /** Given a pointer to a mp_allocated_t, return a pointer to the memory
147 * item it holds. */
148 #define A2M(a) (&(a)->u.mem)
149 /** Given a pointer to a memory_item_t, return a pointer to its enclosing
150 * mp_allocated_t. */
151 #define M2A(p) ( ((char*)p) - STRUCT_OFFSET(mp_allocated_t, u.mem) )
153 #ifdef ALLOC_CAN_RETURN_NULL
154 /** If our ALLOC() macro can return NULL, check whether <b>x</b> is NULL,
155 * and if so, return NULL. */
156 #define CHECK_ALLOC(x) \
157 if (PREDICT_UNLIKELY(!x)) { return NULL; }
158 #else
159 /** If our ALLOC() macro can't return NULL, do nothing. */
160 #define CHECK_ALLOC(x)
161 #endif
163 /** Helper: Allocate and return a new memory chunk for <b>pool</b>. Does not
164 * link the chunk into any list. */
165 static mp_chunk_t *
166 mp_chunk_new(mp_pool_t *pool)
168 size_t sz = pool->new_chunk_capacity * pool->item_alloc_size;
169 #ifdef ALLOC_ROUNDUP
170 size_t alloc_size = CHUNK_OVERHEAD + sz;
171 mp_chunk_t *chunk = ALLOC_ROUNDUP(&alloc_size);
172 #else
173 mp_chunk_t *chunk = ALLOC(CHUNK_OVERHEAD + sz);
174 #endif
175 #ifdef MEMPOOL_STATS
176 ++pool->total_chunks_allocated;
177 #endif
178 CHECK_ALLOC(chunk);
179 memset(chunk, 0, sizeof(mp_chunk_t)); /* Doesn't clear the whole thing. */
180 chunk->magic = MP_CHUNK_MAGIC;
181 #ifdef ALLOC_ROUNDUP
182 chunk->mem_size = alloc_size - CHUNK_OVERHEAD;
183 chunk->capacity = chunk->mem_size / pool->item_alloc_size;
184 #else
185 chunk->capacity = pool->new_chunk_capacity;
186 chunk->mem_size = sz;
187 #endif
188 chunk->next_mem = chunk->mem;
189 chunk->pool = pool;
190 return chunk;
193 /** Take a <b>chunk</b> that has just been allocated or removed from
194 * <b>pool</b>'s empty chunk list, and add it to the head of the used chunk
195 * list. */
196 static INLINE void
197 add_newly_used_chunk_to_used_list(mp_pool_t *pool, mp_chunk_t *chunk)
199 chunk->next = pool->used_chunks;
200 if (chunk->next)
201 chunk->next->prev = chunk;
202 pool->used_chunks = chunk;
203 ASSERT(!chunk->prev);
206 /** Return a newly allocated item from <b>pool</b>. */
207 void *
208 mp_pool_get(mp_pool_t *pool)
210 mp_chunk_t *chunk;
211 mp_allocated_t *allocated;
213 if (PREDICT_LIKELY(pool->used_chunks != NULL)) {
214 /* Common case: there is some chunk that is neither full nor empty. Use
215 * that one. (We can't use the full ones, obviously, and we should fill
216 * up the used ones before we start on any empty ones. */
217 chunk = pool->used_chunks;
219 } else if (pool->empty_chunks) {
220 /* We have no used chunks, but we have an empty chunk that we haven't
221 * freed yet: use that. (We pull from the front of the list, which should
222 * get us the most recently emptied chunk.) */
223 chunk = pool->empty_chunks;
225 /* Remove the chunk from the empty list. */
226 pool->empty_chunks = chunk->next;
227 if (chunk->next)
228 chunk->next->prev = NULL;
230 /* Put the chunk on the 'used' list*/
231 add_newly_used_chunk_to_used_list(pool, chunk);
233 ASSERT(!chunk->prev);
234 --pool->n_empty_chunks;
235 if (pool->n_empty_chunks < pool->min_empty_chunks)
236 pool->min_empty_chunks = pool->n_empty_chunks;
237 } else {
238 /* We have no used or empty chunks: allocate a new chunk. */
239 chunk = mp_chunk_new(pool);
240 CHECK_ALLOC(chunk);
242 /* Add the new chunk to the used list. */
243 add_newly_used_chunk_to_used_list(pool, chunk);
246 ASSERT(chunk->n_allocated < chunk->capacity);
248 if (chunk->first_free) {
249 /* If there's anything on the chunk's freelist, unlink it and use it. */
250 allocated = chunk->first_free;
251 chunk->first_free = allocated->u.next_free;
252 allocated->u.next_free = NULL; /* For debugging; not really needed. */
253 ASSERT(allocated->in_chunk == chunk);
254 } else {
255 /* Otherwise, the chunk had better have some free space left on it. */
256 ASSERT(chunk->next_mem + pool->item_alloc_size <=
257 chunk->mem + chunk->mem_size);
259 /* Good, it did. Let's carve off a bit of that free space, and use
260 * that. */
261 allocated = (void*)chunk->next_mem;
262 chunk->next_mem += pool->item_alloc_size;
263 allocated->in_chunk = chunk;
264 allocated->u.next_free = NULL; /* For debugging; not really needed. */
267 ++chunk->n_allocated;
268 #ifdef MEMPOOL_STATS
269 ++pool->total_items_allocated;
270 #endif
272 if (PREDICT_UNLIKELY(chunk->n_allocated == chunk->capacity)) {
273 /* This chunk just became full. */
274 ASSERT(chunk == pool->used_chunks);
275 ASSERT(chunk->prev == NULL);
277 /* Take it off the used list. */
278 pool->used_chunks = chunk->next;
279 if (chunk->next)
280 chunk->next->prev = NULL;
282 /* Put it on the full list. */
283 chunk->next = pool->full_chunks;
284 if (chunk->next)
285 chunk->next->prev = chunk;
286 pool->full_chunks = chunk;
288 /* And return the memory portion of the mp_allocated_t. */
289 return A2M(allocated);
292 /** Return an allocated memory item to its memory pool. */
293 void
294 mp_pool_release(void *item)
296 mp_allocated_t *allocated = (void*) M2A(item);
297 mp_chunk_t *chunk = allocated->in_chunk;
299 ASSERT(chunk);
300 ASSERT(chunk->magic == MP_CHUNK_MAGIC);
301 ASSERT(chunk->n_allocated > 0);
303 allocated->u.next_free = chunk->first_free;
304 chunk->first_free = allocated;
306 if (PREDICT_UNLIKELY(chunk->n_allocated == chunk->capacity)) {
307 /* This chunk was full and is about to be used. */
308 mp_pool_t *pool = chunk->pool;
309 /* unlink from the full list */
310 if (chunk->prev)
311 chunk->prev->next = chunk->next;
312 if (chunk->next)
313 chunk->next->prev = chunk->prev;
314 if (chunk == pool->full_chunks)
315 pool->full_chunks = chunk->next;
317 /* link to the used list. */
318 chunk->next = pool->used_chunks;
319 chunk->prev = NULL;
320 if (chunk->next)
321 chunk->next->prev = chunk;
322 pool->used_chunks = chunk;
323 } else if (PREDICT_UNLIKELY(chunk->n_allocated == 1)) {
324 /* This was used and is about to be empty. */
325 mp_pool_t *pool = chunk->pool;
327 /* Unlink from the used list */
328 if (chunk->prev)
329 chunk->prev->next = chunk->next;
330 if (chunk->next)
331 chunk->next->prev = chunk->prev;
332 if (chunk == pool->used_chunks)
333 pool->used_chunks = chunk->next;
335 /* Link to the empty list */
336 chunk->next = pool->empty_chunks;
337 chunk->prev = NULL;
338 if (chunk->next)
339 chunk->next->prev = chunk;
340 pool->empty_chunks = chunk;
342 /* Reset the guts of this chunk to defragment it, in case it gets
343 * used again. */
344 chunk->first_free = NULL;
345 chunk->next_mem = chunk->mem;
347 ++pool->n_empty_chunks;
349 --chunk->n_allocated;
352 /** Allocate a new memory pool to hold items of size <b>item_size</b>. We'll
353 * try to fit about <b>chunk_capacity</b> bytes in each chunk. */
354 mp_pool_t *
355 mp_pool_new(size_t item_size, size_t chunk_capacity)
357 mp_pool_t *pool;
358 size_t alloc_size, new_chunk_cap;
360 tor_assert(item_size < SIZE_T_CEILING);
361 tor_assert(chunk_capacity < SIZE_T_CEILING);
362 tor_assert(SIZE_T_CEILING / item_size > chunk_capacity);
364 pool = ALLOC(sizeof(mp_pool_t));
365 CHECK_ALLOC(pool);
366 memset(pool, 0, sizeof(mp_pool_t));
368 /* First, we figure out how much space to allow per item. We'll want to
369 * use make sure we have enough for the overhead plus the item size. */
370 alloc_size = (size_t)(STRUCT_OFFSET(mp_allocated_t, u.mem) + item_size);
371 /* If the item_size is less than sizeof(next_free), we need to make
372 * the allocation bigger. */
373 if (alloc_size < sizeof(mp_allocated_t))
374 alloc_size = sizeof(mp_allocated_t);
376 /* If we're not an even multiple of ALIGNMENT, round up. */
377 if (alloc_size % ALIGNMENT) {
378 alloc_size = alloc_size + ALIGNMENT - (alloc_size % ALIGNMENT);
380 if (alloc_size < ALIGNMENT)
381 alloc_size = ALIGNMENT;
382 ASSERT((alloc_size % ALIGNMENT) == 0);
384 /* Now we figure out how many items fit in each chunk. We need to fit at
385 * least 2 items per chunk. No chunk can be more than MAX_CHUNK bytes long,
386 * or less than MIN_CHUNK. */
387 if (chunk_capacity > MAX_CHUNK)
388 chunk_capacity = MAX_CHUNK;
389 /* Try to be around a power of 2 in size, since that's what allocators like
390 * handing out. 512K-1 byte is a lot better than 512K+1 byte. */
391 chunk_capacity = (size_t) round_to_power_of_2(chunk_capacity);
392 while (chunk_capacity < alloc_size * 2 + CHUNK_OVERHEAD)
393 chunk_capacity *= 2;
394 if (chunk_capacity < MIN_CHUNK)
395 chunk_capacity = MIN_CHUNK;
397 new_chunk_cap = (chunk_capacity-CHUNK_OVERHEAD) / alloc_size;
398 tor_assert(new_chunk_cap < INT_MAX);
399 pool->new_chunk_capacity = (int)new_chunk_cap;
401 pool->item_alloc_size = alloc_size;
403 log_debug(LD_MM, "Capacity is %lu, item size is %lu, alloc size is %lu",
404 (unsigned long)pool->new_chunk_capacity,
405 (unsigned long)pool->item_alloc_size,
406 (unsigned long)(pool->new_chunk_capacity*pool->item_alloc_size));
408 return pool;
411 /** Helper function for qsort: used to sort pointers to mp_chunk_t into
412 * descending order of fullness. */
413 static int
414 mp_pool_sort_used_chunks_helper(const void *_a, const void *_b)
416 mp_chunk_t *a = *(mp_chunk_t**)_a;
417 mp_chunk_t *b = *(mp_chunk_t**)_b;
418 return b->n_allocated - a->n_allocated;
421 /** Sort the used chunks in <b>pool</b> into descending order of fullness,
422 * so that we preferentially fill up mostly full chunks before we make
423 * nearly empty chunks less nearly empty. */
424 static void
425 mp_pool_sort_used_chunks(mp_pool_t *pool)
427 int i, n=0, inverted=0;
428 mp_chunk_t **chunks, *chunk;
429 for (chunk = pool->used_chunks; chunk; chunk = chunk->next) {
430 ++n;
431 if (chunk->next && chunk->next->n_allocated > chunk->n_allocated)
432 ++inverted;
434 if (!inverted)
435 return;
436 //printf("Sort %d/%d\n",inverted,n);
437 chunks = ALLOC(sizeof(mp_chunk_t *)*n);
438 #ifdef ALLOC_CAN_RETURN_NULL
439 if (PREDICT_UNLIKELY(!chunks)) return;
440 #endif
441 for (i=0,chunk = pool->used_chunks; chunk; chunk = chunk->next)
442 chunks[i++] = chunk;
443 qsort(chunks, n, sizeof(mp_chunk_t *), mp_pool_sort_used_chunks_helper);
444 pool->used_chunks = chunks[0];
445 chunks[0]->prev = NULL;
446 for (i=1;i<n;++i) {
447 chunks[i-1]->next = chunks[i];
448 chunks[i]->prev = chunks[i-1];
450 chunks[n-1]->next = NULL;
451 FREE(chunks);
452 mp_pool_assert_ok(pool);
455 /** If there are more than <b>n</b> empty chunks in <b>pool</b>, free the
456 * excess ones that have been empty for the longest. If
457 * <b>keep_recently_used</b> is true, do not free chunks unless they have been
458 * empty since the last call to this function.
460 void
461 mp_pool_clean(mp_pool_t *pool, int n_to_keep, int keep_recently_used)
463 mp_chunk_t *chunk, **first_to_free;
465 mp_pool_sort_used_chunks(pool);
466 ASSERT(n_to_keep >= 0);
468 if (keep_recently_used) {
469 int n_recently_used = pool->n_empty_chunks - pool->min_empty_chunks;
470 if (n_to_keep < n_recently_used)
471 n_to_keep = n_recently_used;
474 ASSERT(n_to_keep >= 0);
476 first_to_free = &pool->empty_chunks;
477 while (*first_to_free && n_to_keep > 0) {
478 first_to_free = &(*first_to_free)->next;
479 --n_to_keep;
481 if (!*first_to_free) {
482 pool->min_empty_chunks = pool->n_empty_chunks;
483 return;
486 chunk = *first_to_free;
487 while (chunk) {
488 mp_chunk_t *next = chunk->next;
489 chunk->magic = 0xdeadbeef;
490 FREE(chunk);
491 #ifdef MEMPOOL_STATS
492 ++pool->total_chunks_freed;
493 #endif
494 --pool->n_empty_chunks;
495 chunk = next;
498 pool->min_empty_chunks = pool->n_empty_chunks;
499 *first_to_free = NULL;
502 /** Helper: Given a list of chunks, free all the chunks in the list. */
503 static void
504 destroy_chunks(mp_chunk_t *chunk)
506 mp_chunk_t *next;
507 while (chunk) {
508 chunk->magic = 0xd3adb33f;
509 next = chunk->next;
510 FREE(chunk);
511 chunk = next;
515 /** Free all space held in <b>pool</b> This makes all pointers returned from
516 * mp_pool_get(<b>pool</b>) invalid. */
517 void
518 mp_pool_destroy(mp_pool_t *pool)
520 destroy_chunks(pool->empty_chunks);
521 destroy_chunks(pool->used_chunks);
522 destroy_chunks(pool->full_chunks);
523 memset(pool, 0xe0, sizeof(mp_pool_t));
524 FREE(pool);
527 /** Helper: make sure that a given chunk list is not corrupt. */
528 static int
529 assert_chunks_ok(mp_pool_t *pool, mp_chunk_t *chunk, int empty, int full)
531 mp_allocated_t *allocated;
532 int n = 0;
533 if (chunk)
534 ASSERT(chunk->prev == NULL);
536 while (chunk) {
537 n++;
538 ASSERT(chunk->magic == MP_CHUNK_MAGIC);
539 ASSERT(chunk->pool == pool);
540 for (allocated = chunk->first_free; allocated;
541 allocated = allocated->u.next_free) {
542 ASSERT(allocated->in_chunk == chunk);
544 if (empty)
545 ASSERT(chunk->n_allocated == 0);
546 else if (full)
547 ASSERT(chunk->n_allocated == chunk->capacity);
548 else
549 ASSERT(chunk->n_allocated > 0 && chunk->n_allocated < chunk->capacity);
551 ASSERT(chunk->capacity == pool->new_chunk_capacity);
553 ASSERT(chunk->mem_size ==
554 pool->new_chunk_capacity * pool->item_alloc_size);
556 ASSERT(chunk->next_mem >= chunk->mem &&
557 chunk->next_mem <= chunk->mem + chunk->mem_size);
559 if (chunk->next)
560 ASSERT(chunk->next->prev == chunk);
562 chunk = chunk->next;
564 return n;
567 /** Fail with an assertion if <b>pool</b> is not internally consistent. */
568 void
569 mp_pool_assert_ok(mp_pool_t *pool)
571 int n_empty;
573 n_empty = assert_chunks_ok(pool, pool->empty_chunks, 1, 0);
574 assert_chunks_ok(pool, pool->full_chunks, 0, 1);
575 assert_chunks_ok(pool, pool->used_chunks, 0, 0);
577 ASSERT(pool->n_empty_chunks == n_empty);
580 #ifdef TOR
581 /** Dump information about <b>pool</b>'s memory usage to the Tor log at level
582 * <b>severity</b>. */
583 /*FFFF uses Tor logging functions. */
584 void
585 mp_pool_log_status(mp_pool_t *pool, int severity)
587 uint64_t bytes_used = 0;
588 uint64_t bytes_allocated = 0;
589 uint64_t bu = 0, ba = 0;
590 mp_chunk_t *chunk;
591 int n_full = 0, n_used = 0;
593 ASSERT(pool);
595 for (chunk = pool->empty_chunks; chunk; chunk = chunk->next) {
596 bytes_allocated += chunk->mem_size;
598 log_fn(severity, LD_MM, U64_FORMAT" bytes in %d empty chunks",
599 U64_PRINTF_ARG(bytes_allocated), pool->n_empty_chunks);
600 for (chunk = pool->used_chunks; chunk; chunk = chunk->next) {
601 ++n_used;
602 bu += chunk->n_allocated * pool->item_alloc_size;
603 ba += chunk->mem_size;
604 log_fn(severity, LD_MM, " used chunk: %d items allocated",
605 chunk->n_allocated);
607 log_fn(severity, LD_MM, U64_FORMAT"/"U64_FORMAT
608 " bytes in %d partially full chunks",
609 U64_PRINTF_ARG(bu), U64_PRINTF_ARG(ba), n_used);
610 bytes_used += bu;
611 bytes_allocated += ba;
612 bu = ba = 0;
613 for (chunk = pool->full_chunks; chunk; chunk = chunk->next) {
614 ++n_full;
615 bu += chunk->n_allocated * pool->item_alloc_size;
616 ba += chunk->mem_size;
618 log_fn(severity, LD_MM, U64_FORMAT"/"U64_FORMAT
619 " bytes in %d full chunks",
620 U64_PRINTF_ARG(bu), U64_PRINTF_ARG(ba), n_full);
621 bytes_used += bu;
622 bytes_allocated += ba;
624 log_fn(severity, LD_MM, "Total: "U64_FORMAT"/"U64_FORMAT" bytes allocated "
625 "for cell pools are full.",
626 U64_PRINTF_ARG(bytes_used), U64_PRINTF_ARG(bytes_allocated));
628 #ifdef MEMPOOL_STATS
629 log_fn(severity, LD_MM, U64_FORMAT" cell allocations ever; "
630 U64_FORMAT" chunk allocations ever; "
631 U64_FORMAT" chunk frees ever.",
632 U64_PRINTF_ARG(pool->total_items_allocated),
633 U64_PRINTF_ARG(pool->total_chunks_allocated),
634 U64_PRINTF_ARG(pool->total_chunks_freed));
635 #endif
637 #endif