mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-23 20:01:23 +01:00
BUG/MINOR: memory: Set objects size for pools in the per-thread cache
When a memory pool is created, it may be allocated from a static array. This happens for "most common" pools, allocated first. Objects of these pools may also be cached in a pool cache. Of course, to not cache too much entries, we track the number of cached objects and the total size of the cache. But the objects size of each pool in the cache (ie, pool_cache[tid][idx].size, where tid is the thread-id and idx is the index of the pool) was never set. So the total size of the cache was never limited. Now when a pool is created, if these objects may be cached, we set the corresponding objects size in the pool cache. This patch must be backported to 2.0 and 1.9.
This commit is contained in:
parent
c2518a53ae
commit
2f6d3c0d65
@ -66,6 +66,7 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
|
|||||||
struct pool_head *entry;
|
struct pool_head *entry;
|
||||||
struct list *start;
|
struct list *start;
|
||||||
unsigned int align;
|
unsigned int align;
|
||||||
|
int thr, idx;
|
||||||
|
|
||||||
/* We need to store a (void *) at the end of the chunks. Since we know
|
/* We need to store a (void *) at the end of the chunks. Since we know
|
||||||
* that the malloc() function will never return such a small size,
|
* that the malloc() function will never return such a small size,
|
||||||
@ -131,6 +132,13 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
|
|||||||
pool->size = size;
|
pool->size = size;
|
||||||
pool->flags = flags;
|
pool->flags = flags;
|
||||||
LIST_ADDQ(start, &pool->list);
|
LIST_ADDQ(start, &pool->list);
|
||||||
|
|
||||||
|
/* update per-thread pool cache if necessary */
|
||||||
|
idx = pool_get_index(pool);
|
||||||
|
if (idx >= 0) {
|
||||||
|
for (thr = 0; thr < MAX_THREADS; thr++)
|
||||||
|
pool_cache[thr][idx].size = size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pool->users++;
|
pool->users++;
|
||||||
#ifndef CONFIG_HAP_LOCKLESS_POOLS
|
#ifndef CONFIG_HAP_LOCKLESS_POOLS
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user