From: Willy Tarreau Date: Thu, 15 Apr 2021 15:23:15 +0000 (+0200) Subject: MINOR: pools: make the basic pool_refill_alloc()/pool_free() update needed_avg X-Git-Tag: v2.4-dev17~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=64383b81818c7f6228c45b80f126abeb90ba5712;p=thirdparty%2Fhaproxy.git MINOR: pools: make the basic pool_refill_alloc()/pool_free() update needed_avg This is a first step towards unifying all the fallback code. Right now these two functions are the only ones which do not update the needed_avg rate counter since there's currently no shared pool kept when using them. But their code is similar to what could be used everywhere except for this one, so let's make them capable of maintaining usage statistics. As a side effect the needed field in "show pools" will now be populated. --- diff --git a/include/haproxy/pool.h b/include/haproxy/pool.h index 92fb6dfbfb..d01c6d7c80 100644 --- a/include/haproxy/pool.h +++ b/include/haproxy/pool.h @@ -141,6 +141,7 @@ static inline void __pool_free(struct pool_head *pool, void *ptr) { _HA_ATOMIC_DEC(&pool->used); _HA_ATOMIC_DEC(&pool->allocated); + swrate_add(&pool->needed_avg, POOL_AVG_SAMPLES, pool->used); pool_free_area(ptr, pool->size + POOL_EXTRA); } diff --git a/src/pool.c b/src/pool.c index 59cc5083e9..685d6b3002 100644 --- a/src/pool.c +++ b/src/pool.c @@ -165,6 +165,8 @@ void *__pool_refill_alloc(struct pool_head *pool, unsigned int avail) return NULL; } + swrate_add_scaled(&pool->needed_avg, POOL_AVG_SAMPLES, pool->allocated, POOL_AVG_SAMPLES/4); + ptr = pool_alloc_area(pool->size + POOL_EXTRA); if (!ptr) { _HA_ATOMIC_INC(&pool->failed);