]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: pools: always record the caller for uncached allocs as well
authorWilly Tarreau <w@1wt.eu>
Mon, 11 Sep 2023 13:01:55 +0000 (15:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 Sep 2023 13:19:49 +0000 (15:19 +0200)
When recording the caller of a pool_alloc(), we currently store it only
when the object comes from the cache and never when it comes from the
heap. There's no valid reason for this except that the caller's pointer
was not passed to pool_alloc_nocache(), so it used to set NULL there.
Let's just pass it down the chain.

include/haproxy/pool.h
src/dynbuf.c
src/pool.c

index 8c480d3f63e3076bf64e0512fa188189be202232..6ae5b60ef39bbd5e2706495dbfc4aeab71b7e8ef 100644 (file)
@@ -106,7 +106,7 @@ void trim_all_pools(void);
 
 void *pool_get_from_os_noinc(struct pool_head *pool);
 void pool_put_to_os_nodec(struct pool_head *pool, void *ptr);
-void *pool_alloc_nocache(struct pool_head *pool);
+void *pool_alloc_nocache(struct pool_head *pool, const void *caller);
 void pool_free_nocache(struct pool_head *pool, void *ptr);
 void dump_pools(void);
 int pool_parse_debugging(const char *str, char **err);
index 0b12c7505411176f12bafc3202a16b4ef088cba4..1ae09f481a59a330834f9a9e046ee3ecb7be883b 100644 (file)
@@ -49,7 +49,7 @@ int init_buffer()
                pool_head_buffer->limit = global.tune.buf_limit;
 
        for (done = 0; done < pool_head_buffer->minavail - 1; done++) {
-               buffer = pool_alloc_nocache(pool_head_buffer);
+               buffer = pool_alloc_nocache(pool_head_buffer, init_buffer);
                if (!buffer)
                        return 0;
                pool_free(pool_head_buffer, buffer);
index 83ebe255cfd01fb051b0ec8edc572ae99160bb5b..fc04c40d2e06d39f091755ad81663fb94fa5a6a9 100644 (file)
@@ -420,7 +420,7 @@ void pool_put_to_os_nodec(struct pool_head *pool, void *ptr)
  * and directly returns it. The pool's counters are updated but the object is
  * never cached, so this is usable with and without local or shared caches.
  */
-void *pool_alloc_nocache(struct pool_head *pool)
+void *pool_alloc_nocache(struct pool_head *pool, const void *caller)
 {
        void *ptr = NULL;
        uint bucket;
@@ -436,7 +436,7 @@ void *pool_alloc_nocache(struct pool_head *pool)
 
        /* keep track of where the element was allocated from */
        POOL_DEBUG_SET_MARK(pool, ptr);
-       POOL_DEBUG_TRACE_CALLER(pool, (struct pool_cache_item *)ptr, NULL);
+       POOL_DEBUG_TRACE_CALLER(pool, (struct pool_cache_item *)ptr, caller);
        return ptr;
 }
 
@@ -839,7 +839,7 @@ void *__pool_alloc(struct pool_head *pool, unsigned int flags)
                p = pool_get_from_cache(pool, caller);
 
        if (unlikely(!p))
-               p = pool_alloc_nocache(pool);
+               p = pool_alloc_nocache(pool, caller);
 
        if (likely(p)) {
 #ifdef USE_MEMORY_PROFILING