]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: make pool_evict_last_items() use pool_put_to_os_no_dec()
authorWilly Tarreau <w@1wt.eu>
Sat, 12 Aug 2023 10:34:09 +0000 (12:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 12 Aug 2023 17:04:34 +0000 (19:04 +0200)
The bucket is already known, no need to calculate it again. Let's just
include the lower level functions.

src/pool.c

index 7239b2bae3bb0e5b94b39c2739bea4c2f512293f..7cb71d00fc248f49b146d339fbe7ff9b0e928272 100644 (file)
@@ -512,6 +512,7 @@ static void pool_evict_last_items(struct pool_head *pool, struct pool_cache_head
        uint released = 0;
        uint cluster = 0;
        uint to_free_max;
+       uint bucket;
 
        BUG_ON(pool_debugging & POOL_DBG_NO_CACHE);
 
@@ -526,12 +527,12 @@ static void pool_evict_last_items(struct pool_head *pool, struct pool_cache_head
                LIST_DELETE(&item->by_pool);
                LIST_DELETE(&item->by_lru);
 
+               bucket = pool_pbucket(item);
+               _HA_ATOMIC_DEC(&pool->buckets[bucket].used);
+               swrate_add_opportunistic(&pool->buckets[bucket].needed_avg, POOL_AVG_SAMPLES, pool->buckets[bucket].used);
+
                if (to_free_max > released || cluster) {
                        /* will never match when global pools are disabled */
-                       uint bucket = pool_pbucket(item);
-                       _HA_ATOMIC_DEC(&pool->buckets[bucket].used);
-                       swrate_add_opportunistic(&pool->buckets[bucket].needed_avg, POOL_AVG_SAMPLES, pool->buckets[bucket].used);
-
                        pi = (struct pool_item *)item;
                        pi->next = NULL;
                        pi->down = head;
@@ -543,8 +544,11 @@ static void pool_evict_last_items(struct pool_head *pool, struct pool_cache_head
                                cluster = 0;
                                head = NULL;
                        }
-               } else
-                       pool_free_nocache(pool, item);
+               } else {
+                       /* does pool_free_nocache() with a known bucket */
+                       _HA_ATOMIC_DEC(&pool->buckets[bucket].allocated);
+                       pool_put_to_os_nodec(pool, item);
+               }
 
                released++;
        }