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 b79b90a..58936d1 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 462c865..ace8a22 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 c94860e..e0e03fc 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 ade0323..5c720c1 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 da6213e..1d275ed 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 8b492e2..fcbb8fa 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 79a63b2..808b4bb 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 da81d29..8df1031 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 f49d07f..0a32107 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 f1b0668..d3e5931 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)