]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: pass the objects count to pool_put_to_shared_cache()
authorWilly Tarreau <w@1wt.eu>
Sun, 2 Jan 2022 14:15:54 +0000 (15:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Jan 2022 18:35:26 +0000 (19:35 +0100)
This is in order to let the caller build the cluster of items to be
released. For now single items are released hence the count is always
1.

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

index 714a843d576e79aa081fc7515eb81a9a6d6060f4..b001f341446576553c3190c1e89c295fd299ca8b 100644 (file)
@@ -129,7 +129,7 @@ static inline void pool_refill_local_from_shared(struct pool_head *pool, struct
        /* ignored without shared pools */
 }
 
-static inline void pool_put_to_shared_cache(struct pool_head *pool, struct pool_item *item)
+static inline void pool_put_to_shared_cache(struct pool_head *pool, struct pool_item *item, uint count)
 {
        /* ignored without shared pools */
 }
@@ -137,7 +137,7 @@ static inline void pool_put_to_shared_cache(struct pool_head *pool, struct pool_
 #else /* CONFIG_HAP_NO_GLOBAL_POOLS */
 
 void pool_refill_local_from_shared(struct pool_head *pool, struct pool_cache_head *pch);
-void pool_put_to_shared_cache(struct pool_head *pool, struct pool_item *item);
+void pool_put_to_shared_cache(struct pool_head *pool, struct pool_item *item, uint count);
 
 /* returns true if the pool is considered to have too many free objects */
 static inline int pool_is_crowded(const struct pool_head *pool)
index 68e83aa674e7f0519639360719764034123c0549..2257dc9f49971f70d5d606513183e92d68b37258 100644 (file)
@@ -338,7 +338,7 @@ void pool_evict_from_local_cache(struct pool_head *pool)
                pi = to_free;
                pi->down = NULL;
                to_free = pi->next;
-               pool_put_to_shared_cache(pool, pi);
+               pool_put_to_shared_cache(pool, pi, 1);
        }
 }
 
@@ -369,7 +369,7 @@ void pool_evict_from_local_caches()
                        struct pool_item *pi = (struct pool_item *)item;
 
                        pi->down = NULL;
-                       pool_put_to_shared_cache(pool, pi);
+                       pool_put_to_shared_cache(pool, pi, 1);
                }
        } while (pool_cache_bytes > CONFIG_HAP_POOL_CACHE_SIZE * 7 / 8);
 }
@@ -465,16 +465,16 @@ void pool_refill_local_from_shared(struct pool_head *pool, struct pool_cache_hea
        pool_cache_bytes += count * pool->size;
 }
 
-/* Adds cache item entry <item> to the shared cache. The caller is advised to
- * first check using pool_is_crowded() if it's wise to add this object there.
- * Both the pool and the item must be valid. Use pool_free() for normal
- * operations.
+/* Adds pool item cluster <item> to the shared cache, which contains <count>
+ * elements. The caller is advised to first check using pool_releasable() if
+ * it's wise to add this series of objects there. Both the pool and the item's
+ * head must be valid.
  */
-void pool_put_to_shared_cache(struct pool_head *pool, struct pool_item *item)
+void pool_put_to_shared_cache(struct pool_head *pool, struct pool_item *item, uint count)
 {
        struct pool_item *free_list;
 
-       _HA_ATOMIC_DEC(&pool->used);
+       _HA_ATOMIC_SUB(&pool->used, count);
        free_list = _HA_ATOMIC_LOAD(&pool->free_list);
        do {
                while (unlikely(free_list == POOL_BUSY)) {