]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: use EBO to wait for unlock during pool_flush()
authorWilly Tarreau <w@1wt.eu>
Thu, 17 Aug 2023 07:04:35 +0000 (09:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Aug 2023 07:09:20 +0000 (09:09 +0200)
pool_flush() could become a source of contention on the pool's free list
if there are many competing thread using that pool. Let's make sure we
use EBO and not just a simple CPU relaxation there, to avoid disturbing
them.

src/pool.c

index 341c3b4d86bf5782903e0c8b3d29fd2ca8aff644..59b0944bba0061e832c2d375c0fdbeb2cf2624b9 100644 (file)
@@ -749,10 +749,9 @@ void pool_flush(struct pool_head *pool)
        for (bucket = 0; bucket < CONFIG_HAP_POOL_BUCKETS; bucket++) {
                next = pool->buckets[bucket].free_list;
                do {
-                       while (unlikely(next == POOL_BUSY)) {
-                               __ha_cpu_relax();
-                               next = _HA_ATOMIC_LOAD(&pool->buckets[bucket].free_list);
-                       }
+                       while (unlikely(next == POOL_BUSY))
+                               next = (void*)pl_wait_new_long((ulong*)&pool->buckets[bucket].free_list, (ulong)next);
+
                        if (next == NULL)
                                break;
                } while (unlikely((next = _HA_ATOMIC_XCHG(&pool->buckets[bucket].free_list, POOL_BUSY)) == POOL_BUSY));