CLEANUP: tree-wide: reorder a few structures to plug some holes around locks

A few structures were slightly rearranged in order to plug some holes
left around the locks. Sizes ranging from 8 to 32 bytes could be saved
depending on the structures. No performance difference was noticed (none
was expected there), though memory usage might be slightly reduced in
some rare cases.
This commit is contained in:
Willy Tarreau 2020-10-18 11:08:41 +02:00
parent 8f1f177ed0
commit e72a3f4489
9 changed files with 30 additions and 29 deletions

View file

@ -617,8 +617,8 @@ struct tlv_ssl {
*/
struct idle_conns {
struct mt_list toremove_conns;
__decl_thread(HA_SPINLOCK_T takeover_lock);
struct task *cleanup_task;
__decl_thread(HA_SPINLOCK_T takeover_lock);
} THREAD_ALIGNED(64);
#endif /* _HAPROXY_CONNECTION_T_H */

View file

@ -164,12 +164,7 @@ struct dns_response_packet {
* current resolution are stored in a FIFO list.
*/
struct dns_resolvers {
char *id; /* resolvers unique identifier */
struct {
const char *file; /* file where the section appears */
int line; /* line where the section appears */
} conf; /* config information */
struct list nameservers; /* dns server list */
__decl_thread(HA_SPINLOCK_T lock);
unsigned int accepted_payload_size; /* maximum payload size we accept for responses */
int nb_nameservers; /* total number of active nameservers in a resolvers section */
int resolve_retries; /* number of retries before giving up */
@ -193,8 +188,13 @@ struct dns_resolvers {
struct eb_root query_ids; /* tree to quickly lookup/retrieve query ids currently in use
* used by each nameserver, but stored in resolvers since there must
* be a unique relation between an eb_root and an eb_node (resolution) */
__decl_thread(HA_SPINLOCK_T lock);
struct list list; /* resolvers list */
struct list nameservers; /* dns server list */
char *id; /* resolvers unique identifier */
struct {
const char *file; /* file where the section appears */
int line; /* line where the section appears */
} conf; /* config information */
};
/* Structure describing a name server used during name resolution.

View file

@ -157,7 +157,6 @@ struct bind_conf {
struct ssl_bind_conf *default_ssl_conf; /* custom SSL conf of default_ctx */
int strict_sni; /* refuse negotiation if sni doesn't match a certificate */
int ssl_options; /* ssl options */
__decl_thread(HA_RWLOCK_T sni_lock); /* lock the SNI trees during add/del operations */
struct eb_root sni_ctx; /* sni_ctx tree of all known certs full-names sorted by name */
struct eb_root sni_w_ctx; /* sni_ctx tree of all known certs wildcards sorted by name */
struct tls_keys_ref *keys_ref; /* TLS ticket keys reference */
@ -180,6 +179,7 @@ struct bind_conf {
char *arg; /* argument passed to "bind" for better error reporting */
char *file; /* file where the section appears */
int line; /* line where the section appears */
__decl_thread(HA_RWLOCK_T sni_lock); /* lock the SNI trees during add/del operations */
struct rx_settings settings; /* all the settings needed for the listening socket */
};
@ -193,6 +193,8 @@ struct listener {
short int nice; /* nice value to assign to the instantiated tasks */
int luid; /* listener universally unique ID, used for SNMP */
int options; /* socket options : LI_O_* */
__decl_thread(HA_SPINLOCK_T lock);
struct fe_counters *counters; /* statistics counters */
int nbconn; /* current number of connections on this listener */
int maxconn; /* maximum connections allowed on this listener */
@ -208,8 +210,6 @@ struct listener {
int tcp_ut; /* for TCP, user timeout */
char *name; /* listener's name */
__decl_thread(HA_SPINLOCK_T lock);
/* cache line boundary */
unsigned int thr_conn[MAX_THREADS]; /* number of connections per thread */

View file

@ -100,12 +100,12 @@ enum {
*/
struct pat_ref {
struct list list; /* Used to chain refs. */
unsigned int flags; /* flags PAT_REF_*. */
char *reference; /* The reference name. */
int unique_id; /* Each pattern reference have unique id. */
char *display; /* String displayed to identify the pattern origin. */
struct list head; /* The head of the list of struct pat_ref_elt. */
struct list pat; /* The head of the list of struct pattern_expr. */
unsigned int flags; /* flags PAT_REF_*. */
int unique_id; /* Each pattern reference have unique id. */
__decl_thread(HA_SPINLOCK_T lock); /* Lock used to protect pat ref elements */
};

View file

@ -50,6 +50,7 @@ struct shared_table {
struct peer {
int local; /* proxy state */
__decl_thread(HA_SPINLOCK_T lock); /* lock used to handle this peer section */
char *id;
struct {
const char *file; /* file where the section appears */
@ -78,7 +79,6 @@ struct peer {
struct shared_table *tables;
struct server *srv;
struct dcache *dcache; /* dictionary cache */
__decl_thread(HA_SPINLOCK_T lock); /* lock used to handle this peer section */
struct peer *next; /* next peer in the list */
};

View file

@ -252,7 +252,6 @@ struct proxy {
int options; /* PR_O_REDISP, PR_O_TRANSP, ... */
int options2; /* PR_O2_* */
int max_out_conns; /* Max number of idling connections we keep for a session */
unsigned int ck_opts; /* PR_CK_* (cookie options) */
unsigned int fe_req_ana, be_req_ana; /* bitmap of common request protocol analysers for the frontend and backend */
unsigned int fe_rsp_ana, be_rsp_ana; /* bitmap of common response protocol analysers for the frontend and backend */
@ -293,11 +292,12 @@ struct proxy {
unsigned int cookie_maxidle; /* max idle time for this cookie */
unsigned int cookie_maxlife; /* max life time for this cookie */
char *rdp_cookie_name; /* name of the RDP cookie to look for */
int rdp_cookie_len; /* strlen(rdp_cookie_name), computed only once */
char *capture_name; /* beginning of the name of the cookie to capture */
int rdp_cookie_len; /* strlen(rdp_cookie_name), computed only once */
int capture_namelen; /* length of the cookie name to match */
int capture_len; /* length of the string to be captured */
struct uri_auth *uri_auth; /* if non-NULL, the (list of) per-URI authentications */
int capture_len; /* length of the string to be captured */
int max_out_conns; /* Max number of idling connections we keep for a session */
int max_ka_queue; /* 1+maximum requests in queue accepted for reusing a K-A conn (0=none) */
int clitcpka_cnt; /* The maximum number of keepalive probes TCP should send before dropping the connection. (client side) */
int clitcpka_idle; /* The time (in seconds) the connection needs to remain idle before TCP starts sending keepalive probes. (client side) */
@ -321,6 +321,8 @@ struct proxy {
int clientfin; /* timeout to apply to client half-closed connections */
int serverfin; /* timeout to apply to server half-closed connections */
} timeout;
__decl_thread(HA_SPINLOCK_T lock); /* may be taken under the server's lock */
char *id, *desc; /* proxy id (name) and description */
struct eb_root pendconns; /* pending connections with no server assigned yet */
int nbpend; /* number of pending connections with no server assigned yet */
@ -348,7 +350,6 @@ struct proxy {
int redispatch_after; /* number of retries before redispatch */
unsigned down_trans; /* up-down transitions */
unsigned down_time; /* total time the proxy was down */
unsigned int log_count; /* number of logs produced by the frontend */
time_t last_change; /* last time, when the state was changed */
int (*accept)(struct stream *s); /* application layer's accept() */
struct conn_src conn_src; /* connection source settings */
@ -377,10 +378,11 @@ struct proxy {
struct task *task; /* the associated task, mandatory to manage rate limiting, stopping and resource shortage, NULL if disabled */
struct tcpcheck_rules tcpcheck_rules; /* tcp-check send / expect rules */
int grace; /* grace time after stop request */
char *check_command; /* Command to use for external agent checks */
char *check_path; /* PATH environment to use for external agent checks */
struct http_reply *replies[HTTP_ERR_SIZE]; /* HTTP replies for known errors */
unsigned int log_count; /* number of logs produced by the frontend */
int grace; /* grace time after stop request */
int uuid; /* universally unique proxy ID, used for SNMP */
unsigned int backlog; /* force the frontend's listen backlog */
unsigned long bind_proc; /* bitmask of processes using this proxy */
@ -444,7 +446,6 @@ struct proxy {
* name is used
*/
struct list filter_configs; /* list of the filters that are declared on this proxy */
__decl_thread(HA_SPINLOCK_T lock); /* may be taken under the server's lock */
EXTRA_COUNTERS(extra_counters_fe);
EXTRA_COUNTERS(extra_counters_be);

View file

@ -235,9 +235,10 @@ struct server {
unsigned int curr_used_conns; /* Current number of used connections */
unsigned int max_used_conns; /* Max number of used connections (the counter is reset at each connection purges */
unsigned int est_need_conns; /* Estimate on the number of needed connections (max of curr and previous max_used) */
unsigned int *curr_idle_thr; /* Current number of orphan idling connections per thread */
unsigned int next_takeover; /* thread ID to try to steal connections from next time */
unsigned int *curr_idle_thr; /* Current number of orphan idling connections per thread */
int max_reuse; /* Max number of requests on a same connection */
__decl_thread(HA_SPINLOCK_T lock); /* may enclose the proxy's lock, must not be taken under */
struct eb32_node idle_node; /* When to next do cleanup in the idle connections */
struct task *warmup; /* the task dedicated to the warmup when slowstart is set */
@ -329,7 +330,6 @@ struct server {
} ssl_ctx;
#endif
struct dns_srvrq *srvrq; /* Pointer representing the DNS SRV requeest, if any */
__decl_thread(HA_SPINLOCK_T lock); /* may enclose the proxy's lock, must not be taken under */
struct {
const char *file; /* file where the section appears */
struct eb32_node id; /* place in the tree of used IDs */

View file

@ -40,8 +40,8 @@ struct sink_forward_target {
struct server *srv; // used server
struct appctx *appctx; // appctx of current session
size_t ofs; // ring buffer reader offset
__decl_thread(HA_SPINLOCK_T lock); // lock to protect current struct
struct sink_forward_target *next;
__decl_thread(HA_SPINLOCK_T lock); // lock to protect current struct
};
/* describes the configuration and current state of an event sink */
@ -57,10 +57,10 @@ struct sink {
struct task *forward_task; // task to handle forward targets conns
struct sig_handler *forward_sighandler; /* signal handler */
struct {
__decl_thread(HA_RWLOCK_T lock); // shared/excl for dropped
struct ring *ring; // used by ring buffer and STRM sender
unsigned int dropped; // dropped events since last one.
int fd; // fd num for FD type sink
__decl_thread(HA_RWLOCK_T lock); // shared/excl for dropped
} ctx;
};

View file

@ -170,16 +170,11 @@ struct stktable {
struct stktable *next; /* The stick-table may be linked when belonging to
* the same configuration section.
*/
struct {
const char *file; /* The file where the stick-table is declared. */
int line; /* The line in this <file> the stick-table is declared. */
} conf;
struct ebpt_node name; /* Stick-table are lookup by name here. */
struct eb_root keys; /* head of sticky session tree */
struct eb_root exps; /* head of sticky session expiration tree */
struct eb_root updates; /* head of sticky updates sequence tree */
struct pool_head *pool; /* pool used to allocate sticky sessions */
__decl_thread(HA_SPINLOCK_T lock); /* spin lock related to the table */
struct task *exp_task; /* expiration task */
struct task *sync_task; /* sync task */
unsigned int update;
@ -208,6 +203,11 @@ struct stktable {
} data_arg[STKTABLE_DATA_TYPES]; /* optional argument of each data type */
struct proxy *proxy; /* The proxy this stick-table is attached to, if any.*/
struct proxy *proxies_list; /* The list of proxies which reference this stick-table. */
struct {
const char *file; /* The file where the stick-table is declared. */
int line; /* The line in this <file> the stick-table is declared. */
} conf;
__decl_thread(HA_SPINLOCK_T lock); /* spin lock related to the table */
};
extern struct stktable_data_type stktable_data_types[STKTABLE_DATA_TYPES];