]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: rename CONFIG_HAP_LOCAL_POOLS to CONFIG_HAP_POOLS
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Apr 2021 14:24:00 +0000 (16:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 Apr 2021 13:24:33 +0000 (15:24 +0200)
We're going to make the local pool always present unless pools are
completely disabled. This means that pools are always enabled by
default, regardless of the use of threads. Let's drop this notion
of "local" pools and make it just "pool". The equivalent debug
option becomes DEBUG_NO_POOLS instead of DEBUG_NO_LOCAL_POOLS.

For now this changes nothing except the option and dropping the
dependency on USE_THREAD.

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

index f80ba4b0caddcfe9fbd94716a3e837e740cab342..2d9cc0ca53693c9a0a6fdb3c1750fe5409aea325 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -229,7 +229,7 @@ SMALL_OPTS =
 # not use them at all. Some even more obscure ones might also be available
 # without appearing here. Currently defined DEBUG macros include DEBUG_FULL,
 # DEBUG_MEM_STATS, DEBUG_DONT_SHARE_POOLS, DEBUG_NO_LOCKLESS_POOLS, DEBUG_FD,
-# DEBUG_NO_LOCAL_POOLS, DEBUG_FAIL_ALLOC, DEBUG_STRICT_NOCRASH, DEBUG_HPACK,
+# DEBUG_NO_POOLS, DEBUG_FAIL_ALLOC, DEBUG_STRICT_NOCRASH, DEBUG_HPACK,
 # DEBUG_AUTH, DEBUG_SPOE, DEBUG_UAF, DEBUG_THREAD, DEBUG_STRICT, DEBUG_DEV,
 # DEBUG_TASK.
 DEBUG =
index 7dc99c182b7011206e8eb9ae920a03d200f9e1fa..4b185ef9ab724eff035d0a41587f2f57e7d9e86b 100644 (file)
 #include <haproxy/list-t.h>
 #include <haproxy/thread-t.h>
 
+/* Pools are always enabled unless explicitly disabled. When disabled, the
+ * calls are directly passed to the underlying OS functions.
+ */
+#if !defined(DEBUG_NO_POOLS) && !defined(DEBUG_UAF) && !defined(DEBUG_FAIL_ALLOC)
+#define CONFIG_HAP_POOLS
+#endif
+
 /* On architectures supporting threads and double-word CAS, we can implement
  * lock-less memory pools. This isn't supported for debugging modes however.
  */
 #define CONFIG_HAP_LOCKLESS_POOLS
 #endif
 
-/* On architectures supporting threads we can amortize the locking cost using
- * local pools.
- */
-#if defined(USE_THREAD) && !defined(DEBUG_NO_LOCAL_POOLS) && !defined(DEBUG_UAF) && !defined(DEBUG_FAIL_ALLOC)
-#define CONFIG_HAP_LOCAL_POOLS
-#endif
-
 /* On modern architectures with many threads, a fast memory allocator, and
  * local pools, the global pools with their single list can be way slower than
  * the standard allocator which already has its own per-thread arenas. In this
  * case we disable global pools. The global pools may still be enforced
  * using CONFIG_HAP_GLOBAL_POOLS though.
  */
-#if defined(USE_THREAD) && defined(HA_HAVE_FAST_MALLOC) && defined(CONFIG_HAP_LOCAL_POOLS) && !defined(CONFIG_HAP_GLOBAL_POOLS)
+#if defined(USE_THREAD) && defined(HA_HAVE_FAST_MALLOC) && defined(CONFIG_HAP_POOLS) && !defined(CONFIG_HAP_GLOBAL_POOLS)
 #define CONFIG_HAP_NO_GLOBAL_POOLS
 #endif
 
@@ -117,7 +117,7 @@ struct pool_head {
        unsigned int failed;    /* failed allocations */
        struct list list;       /* list of all known pools */
        char name[12];          /* name of the pool */
-#ifdef CONFIG_HAP_LOCAL_POOLS
+#ifdef CONFIG_HAP_POOLS
        struct pool_cache_head cache[MAX_THREADS]; /* pool caches */
 #endif
 } __attribute__((aligned(64)));
index 526c57c2d9f9dc89b8451e608b2538a1ad02fa23..92fb6dfbfb55ff6a52ea7f66f1ff2cd006ab0a5b 100644 (file)
@@ -71,7 +71,7 @@ static inline int pool_is_crowded(const struct pool_head *pool)
 }
 
 
-#ifdef CONFIG_HAP_LOCAL_POOLS
+#ifdef CONFIG_HAP_POOLS
 
 /****************** Thread-local cache management ******************/
 
@@ -123,7 +123,7 @@ static inline void pool_put_to_cache(struct pool_head *pool, void *ptr)
                pool_evict_from_cache();
 }
 
-#endif // CONFIG_HAP_LOCAL_POOLS
+#endif // CONFIG_HAP_POOLS
 
 
 #if defined(CONFIG_HAP_NO_GLOBAL_POOLS)
@@ -269,7 +269,7 @@ static inline void *__pool_alloc(struct pool_head *pool, unsigned int flags)
 {
        void *p;
 
-#ifdef CONFIG_HAP_LOCAL_POOLS
+#ifdef CONFIG_HAP_POOLS
        if (likely(p = __pool_get_from_cache(pool)))
                goto ret;
 #endif
@@ -330,7 +330,7 @@ static inline void pool_free(struct pool_head *pool, void *ptr)
                if (unlikely(mem_poison_byte >= 0))
                        memset(ptr, mem_poison_byte, pool->size);
 
-#ifdef CONFIG_HAP_LOCAL_POOLS
+#ifdef CONFIG_HAP_POOLS
                /* put the object back into the cache only if there are not too
                 * many objects yet in this pool (no more than half of the cached
                 * is used or this pool uses no more than 1/8 of the cache size).
index d1a4fc4e80221b299255c29a77d5ecb5fdf8c175..1285c731a09ca712f0a7450d7671592a3c9f2942 100644 (file)
@@ -42,7 +42,7 @@ struct thread_info {
        unsigned int idle_pct;     /* idle to total ratio over last sample (percent) */
        unsigned int flags;        /* thread info flags, TI_FL_* */
 
-#ifdef CONFIG_HAP_LOCAL_POOLS
+#ifdef CONFIG_HAP_POOLS
        struct list pool_lru_head;                         /* oldest objects   */
 #endif
        struct list buffer_wq;     /* buffer waiters */
index 6f19ec783e3d8f9d1521ae9156d68afcf77439bd..b493a933e6c26cbad4a8d608bd0fc7a2da168fc6 100644 (file)
@@ -27,7 +27,7 @@
 #include <haproxy/tools.h>
 
 
-#ifdef CONFIG_HAP_LOCAL_POOLS
+#ifdef CONFIG_HAP_POOLS
 /* These ones are initialized per-thread on startup by init_pools() */
 THREAD_LOCAL size_t pool_cache_bytes = 0;                /* total cache size */
 THREAD_LOCAL size_t pool_cache_count = 0;                /* #cache objects   */
@@ -107,7 +107,7 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
                pool->flags = flags;
                LIST_ADDQ(start, &pool->list);
 
-#ifdef CONFIG_HAP_LOCAL_POOLS
+#ifdef CONFIG_HAP_POOLS
                /* update per-thread pool cache if necessary */
                for (thr = 0; thr < MAX_THREADS; thr++) {
                        LIST_INIT(&pool->cache[thr].list);
@@ -119,7 +119,7 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
        return pool;
 }
 
-#ifdef CONFIG_HAP_LOCAL_POOLS
+#ifdef CONFIG_HAP_POOLS
 /* Evicts some of the oldest objects from the local cache, pushing them to the
  * global pool.
  */
@@ -602,7 +602,7 @@ void create_pool_callback(struct pool_head **ptr, char *name, unsigned int size)
 /* Initializes all per-thread arrays on startup */
 static void init_pools()
 {
-#ifdef CONFIG_HAP_LOCAL_POOLS
+#ifdef CONFIG_HAP_POOLS
        int thr;
 
        for (thr = 0; thr < MAX_THREADS; thr++) {