]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pool: remove the size field from pool_cache_head
authorWilly Tarreau <w@1wt.eu>
Sat, 17 Apr 2021 12:05:10 +0000 (14:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 Apr 2021 13:24:33 +0000 (15:24 +0200)
Everywhere we have access to the pool so we don't need to cache a copy
of the pool's size into the pool_cache_head. Let's remove it.

include/haproxy/pool-t.h
include/haproxy/pool.h
src/pool.c

index b6d4d3101561d9832513c1b51418c1015ee39169..7dc99c182b7011206e8eb9ae920a03d200f9e1fa 100644 (file)
@@ -84,7 +84,6 @@
 
 struct pool_cache_head {
        struct list list;    /* head of objects in this pool */
-       size_t size;         /* size of an object */
        unsigned int count;  /* number of objects in this pool */
 } THREAD_ALIGNED(64);
 
index ee97135fdb7a32332748a6165a89ad03978e3735..526c57c2d9f9dc89b8451e608b2538a1ad02fa23 100644 (file)
@@ -94,7 +94,7 @@ static inline void *__pool_get_from_cache(struct pool_head *pool)
 
        item = LIST_NEXT(&ph->list, typeof(item), by_pool);
        ph->count--;
-       pool_cache_bytes -= ph->size;
+       pool_cache_bytes -= pool->size;
        pool_cache_count--;
        LIST_DEL(&item->by_pool);
        LIST_DEL(&item->by_lru);
@@ -117,7 +117,7 @@ static inline void pool_put_to_cache(struct pool_head *pool, void *ptr)
        LIST_ADD(&ti->pool_lru_head, &item->by_lru);
        ph->count++;
        pool_cache_count++;
-       pool_cache_bytes += ph->size;
+       pool_cache_bytes += pool->size;
 
        if (unlikely(pool_cache_bytes > CONFIG_HAP_POOL_CACHE_SIZE))
                pool_evict_from_cache();
index 4f367d0b3454cef60a5da9dadd773f84947a2823..6f19ec783e3d8f9d1521ae9156d68afcf77439bd 100644 (file)
@@ -111,7 +111,6 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
                /* update per-thread pool cache if necessary */
                for (thr = 0; thr < MAX_THREADS; thr++) {
                        LIST_INIT(&pool->cache[thr].list);
-                       pool->cache[thr].size = size;
                }
 #endif
                HA_SPIN_INIT(&pool->lock);
@@ -141,7 +140,7 @@ void pool_evict_from_cache()
                LIST_DEL(&item->by_lru);
                ph->count--;
                pool_cache_count--;
-               pool_cache_bytes -= ph->size;
+               pool_cache_bytes -= pool->size;
                __pool_free(pool, item);
        } while (pool_cache_bytes > CONFIG_HAP_POOL_CACHE_SIZE * 7 / 8);
 }