]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pool: move pool declarations to read_mostly
authorWilly Tarreau <w@1wt.eu>
Sat, 10 Apr 2021 15:23:00 +0000 (17:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 10 Apr 2021 17:27:41 +0000 (19:27 +0200)
All pool heads are accessed via a pointer and should not be shared with
highly written variables. Move them to the read_mostly section.

addons/ot/src/opentracing.c
addons/ot/src/scope.c
include/haproxy/pool.h
src/chunk.c
src/compression.c
src/dynbuf.c
src/extcheck.c
src/hpack-tbl.c
src/http_ana.c
src/ssl_sock.c

index b79b90a51376dc10658d862b90d42bbcc84deec9..58936d1224aaeb21a75667866a1dddf38eed72a2 100644 (file)
@@ -20,7 +20,7 @@
 #include "include.h"
 
 
-static struct pool_head *pool_head_ot_span_context = NULL;
+static struct pool_head *pool_head_ot_span_context __read_mostly = NULL;
 
 #ifdef USE_POOL_OT_SPAN_CONTEXT
 REGISTER_POOL(&pool_head_ot_span_context, "ot_span_context", MAX(sizeof(struct otc_span), sizeof(struct otc_span_context)));
index 462c86577d41437ec164b3b824c4454e3ff72a44..ace8a229e0f02507c364b093bbbb25ee181d76f5 100644 (file)
@@ -20,9 +20,9 @@
 #include "include.h"
 
 
-static struct pool_head *pool_head_ot_scope_span = NULL;
-static struct pool_head *pool_head_ot_scope_context = NULL;
-static struct pool_head *pool_head_ot_runtime_context = NULL;
+static struct pool_head *pool_head_ot_scope_span __read_mostly = NULL;
+static struct pool_head *pool_head_ot_scope_context __read_mostly = NULL;
+static struct pool_head *pool_head_ot_runtime_context __read_mostly = NULL;
 
 #ifdef USE_POOL_OT_SCOPE_SPAN
 REGISTER_POOL(&pool_head_ot_scope_span, "ot_scope_span", sizeof(struct flt_ot_scope_span));
index c94860e4412406577375dec8e272c8a80a476819..e0e03fc328cca087b69ba5bb4dffb56eb011109b 100644 (file)
 
 /* This macro declares a pool head <ptr> and registers its creation */
 #define DECLARE_POOL(ptr, name, size)   \
-       struct pool_head *(ptr) = NULL; \
+       struct pool_head *(ptr) __read_mostly = NULL; \
        REGISTER_POOL(&ptr, name, size)
 
 /* This macro declares a static pool head <ptr> and registers its creation */
 #define DECLARE_STATIC_POOL(ptr, name, size) \
-       static struct pool_head *(ptr);      \
+       static struct pool_head *(ptr) __read_mostly; \
        REGISTER_POOL(&ptr, name, size)
 
 /* poison each newly allocated area with this byte if >= 0 */
index ade0323a8420360813376e2eb4d5768a27eec1a8..5c720c1bcdef493d5bf718f70799515f2915667b 100644 (file)
@@ -26,12 +26,12 @@ static THREAD_LOCAL struct buffer trash_chunk1;
 static THREAD_LOCAL struct buffer trash_chunk2;
 
 /* trash buffers used for various conversions */
-static int trash_size;
+static int trash_size __read_mostly;
 static THREAD_LOCAL char *trash_buf1;
 static THREAD_LOCAL char *trash_buf2;
 
 /* the trash pool for reentrant allocations */
-struct pool_head *pool_head_trash = NULL;
+struct pool_head *pool_head_trash __read_mostly = NULL;
 
 /* this is used to drain data, and as a temporary buffer for sprintf()... */
 THREAD_LOCAL struct buffer trash = { };
index da6213ed30dada2e238d64fd50d2981cb73f216a..1d275edac7b8f42f9d3c979f084c9e4460a0ef30 100644 (file)
@@ -48,11 +48,11 @@ static void *alloc_zlib(void *opaque, unsigned int items, unsigned int size);
 static void free_zlib(void *opaque, void *ptr);
 
 /* zlib allocation  */
-static struct pool_head *zlib_pool_deflate_state = NULL;
-static struct pool_head *zlib_pool_window = NULL;
-static struct pool_head *zlib_pool_prev = NULL;
-static struct pool_head *zlib_pool_head = NULL;
-static struct pool_head *zlib_pool_pending_buf = NULL;
+static struct pool_head *zlib_pool_deflate_state __read_mostly = NULL;
+static struct pool_head *zlib_pool_window __read_mostly = NULL;
+static struct pool_head *zlib_pool_prev __read_mostly = NULL;
+static struct pool_head *zlib_pool_head __read_mostly = NULL;
+static struct pool_head *zlib_pool_pending_buf __read_mostly = NULL;
 
 long zlib_used_memory = 0;
 
index 8b492e29db447c79339004c524451b86ecc52023..fcbb8faa4dfef52a3a17899325a34519937b2a6c 100644 (file)
@@ -20,7 +20,7 @@
 #include <haproxy/list.h>
 #include <haproxy/pool.h>
 
-struct pool_head *pool_head_buffer;
+struct pool_head *pool_head_buffer __read_mostly;
 
 /* perform minimal intializations, report 0 in case of error, 1 if OK. */
 int init_buffer()
index 79a63b2a6da42f67aef71cc0410d786935917017..808b4bb7140a675ec4fccf3f36ec36b7532a2245 100644 (file)
@@ -43,7 +43,7 @@
 
 
 static struct list pid_list = LIST_HEAD_INIT(pid_list);
-static struct pool_head *pool_head_pid_list;
+static struct pool_head *pool_head_pid_list __read_mostly;
 __decl_spinlock(pid_list_lock);
 
 struct extcheck_env {
index da81d296b510ec71afe9ee1432a8bcc3a1d01023..8df10319a8a74bb3654a4dad0a2bf0490b331b6a 100644 (file)
@@ -99,7 +99,7 @@ const struct http_hdr hpack_sht[HPACK_SHT_SIZE] = {
        [61] = { .n = IST("www-authenticate"),             .v = IST("")              },
 };
 
-struct pool_head *pool_head_hpack_tbl = NULL;
+struct pool_head *pool_head_hpack_tbl __read_mostly = NULL;
 
 #ifdef DEBUG_HPACK
 /* dump the whole dynamic header table */
index f49d07f321de70c14403e0438f6fdc5881588ad4..0a32107fa8ba439f765b6760bba76dcba0c503a2 100644 (file)
@@ -42,8 +42,8 @@
 
 extern const char *stat_status_codes[];
 
-struct pool_head *pool_head_requri = NULL;
-struct pool_head *pool_head_capture = NULL;
+struct pool_head *pool_head_requri __read_mostly = NULL;
+struct pool_head *pool_head_capture __read_mostly = NULL;
 
 
 static void http_end_request(struct stream *s);
index f1b0668abf72112c48cd966fcaafa0290bbf83d8..d3e593182b2e84cd413248bd3911dce85ba38d52 100644 (file)
@@ -482,14 +482,14 @@ static STACK_OF(X509_NAME)* ssl_get_client_ca_file(char *path)
        return ca_e->ca_list;
 }
 
-struct pool_head *pool_head_ssl_capture = NULL;
+struct pool_head *pool_head_ssl_capture __read_mostly = NULL;
 int ssl_capture_ptr_index = -1;
 int ssl_app_data_index = -1;
 
 #ifdef HAVE_OPENSSL_KEYLOG
 int ssl_keylog_index = -1;
-struct pool_head *pool_head_ssl_keylog = NULL;
-struct pool_head *pool_head_ssl_keylog_str = NULL;
+struct pool_head *pool_head_ssl_keylog __read_mostly = NULL;
+struct pool_head *pool_head_ssl_keylog_str __read_mostly = NULL;
 #endif
 
 #if (defined SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB && TLS_TICKETS_NO > 0)