MINOR: global: declare a read_mostly section
authorWilly Tarreau <w@1wt.eu>
Sat, 10 Apr 2021 14:53:05 +0000 (16:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 10 Apr 2021 17:27:41 +0000 (19:27 +0200)
commitf459640ef6492f8e06967c23305f48e06858df11
tree37fbe4ea0d679c04cbdd4a1bf40a8c536b17f834
parentba386f6a8d62fe6778666f02f23de7c56b2739d5
MINOR: global: declare a read_mostly section

Some variables are mostly read (mostly pointers) but they tend to be
merged with other ones in the same cache line, slowing their access down
in multi-thread setups. This patch declares an empty, aligned variable
in a section called "read_mostly". This will force a cache-line alignment
on this section so that any variable declared in it will be certain to
avoid false sharing with other ones. The section will be eliminated at
link time if not used.

A __read_mostly attribute was added to compiler.h to ease use of this
section.
include/haproxy/compiler.h
src/haproxy.c