The initial-exec tls model removes requirement on performing memory
allocation the first time a tls variable is touched by any given thread.
This is needed to ensure usage of the TLS from a signal handler works
fine.
Given that the link-editor figures out the right model to use at
runtime, we can change the tls model without changing the soname major
version.
This also brings interesting speedups over the GD model. This does not
affects TLS accesses performed by executables, but does affect TLS
accesses performed by libraries.
* Executable (no change)
./test_urcu 1 0 10
SUMMARY /media/truecrypt1/compudj/doc/userspace-rcu/tests/benchmark/.libs/test_urcu testdur 10 nr_readers 1 rdur 0 wdur 0 nr_writers 0 wdelay 0 nr_reads
4420328692 nr_writes 0 nr_ops
4420328692
(with initial-exec)
./test_urcu 1 0 10
SUMMARY /media/truecrypt1/compudj/doc/userspace-rcu/tests/benchmark/.libs/test_urcu testdur 10 nr_readers 1 rdur 0 wdur 0 nr_writers 0 wdelay 0 nr_reads
4424925864 nr_writes 0 nr_ops
4424925864
* Library
(with global-dynamic)
./test_urcu_dynamic_link 1 0 10
SUMMARY /media/truecrypt1/compudj/doc/userspace-rcu/tests/benchmark/.libs/test_urcu_dynamic_link testdur 10 nr_readers 1 rdur 0 wdur 0 nr_writers 0 wdelay 0 nr_reads
573209491 nr_writes 0 nr_ops
573209491
(with initial-exec)
./test_urcu_dynamic_link 1 0 10
SUMMARY /media/truecrypt1/compudj/doc/userspace-rcu/tests/benchmark/.libs/test_urcu_dynamic_link testdur 10 nr_readers 1 rdur 0 wdur 0 nr_writers 0 wdelay 0 nr_reads
1088836185 nr_writes 0 nr_ops
1088836185
Link: https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter8-20.html
Link: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#Common-Variable-Attributes
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
# define URCU_TLS(name) (name)
+# define DEFINE_URCU_TLS_IE(type, name) \
+ CONFIG_RCU_TLS __attribute__((tls_model("initial-exec"))) type name
+
#else /* #ifndef CONFIG_RCU_TLS */
/*
# define DEFINE_URCU_TLS(type, name) \
DEFINE_URCU_TLS_1(type, name)
+# define DEFINE_URCU_TLS_IE(type, name) \
+ DEFINE_URCU_TLS_1(type, name)
+
# define URCU_TLS_1(name) (*__tls_access_ ## name())
# define URCU_TLS(name) URCU_TLS_1(name)
* Pointer to registry elements. Written to only by each individual reader. Read
* by both the reader and the writers.
*/
-DEFINE_URCU_TLS(struct rcu_reader *, rcu_reader);
+DEFINE_URCU_TLS_IE(struct rcu_reader *, rcu_reader);
static CDS_LIST_HEAD(registry);
/* Link a thread using call_rcu() to its call_rcu thread. */
-static DEFINE_URCU_TLS(struct call_rcu_data *, thread_call_rcu_data);
+static DEFINE_URCU_TLS_IE(struct call_rcu_data *, thread_call_rcu_data);
/*
* Guard call_rcu thread creation and atfork handlers.
* Written to only by each individual deferer. Read by both the deferer and
* the reclamation tread.
*/
-static DEFINE_URCU_TLS(struct defer_queue, defer_queue);
+static DEFINE_URCU_TLS_IE(struct defer_queue, defer_queue);
static CDS_LIST_HEAD(registry_defer);
static pthread_t tid_defer;
* Written to only by each individual reader. Read by both the reader and the
* writers.
*/
-DEFINE_URCU_TLS(struct rcu_reader, rcu_reader);
+DEFINE_URCU_TLS_IE(struct rcu_reader, rcu_reader);
static CDS_LIST_HEAD(registry);
* Written to only by each individual reader. Read by both the reader and the
* writers.
*/
-DEFINE_URCU_TLS(struct rcu_reader, rcu_reader);
+DEFINE_URCU_TLS_IE(struct rcu_reader, rcu_reader);
static CDS_LIST_HEAD(registry);