Use initial-exec tls model
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 18 Oct 2017 20:55:18 +0000 (16:55 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 19 Oct 2017 14:49:31 +0000 (10:49 -0400)
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>
include/urcu/tls-compat.h
src/urcu-bp.c
src/urcu-call-rcu-impl.h
src/urcu-defer-impl.h
src/urcu-qsbr.c
src/urcu.c

index 8ac1ea0615ddc2eb91ee51e9e15b89bd094d4c81..3a31eeb619bec3bee3fa034c45b3faf8f7dd1a32 100644 (file)
@@ -72,6 +72,9 @@ extern "C" {
 
 # 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 */
 
 /*
@@ -127,6 +130,9 @@ struct urcu_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)
index ebe96c57da9630d3e43168ee32fa96da95277bfa..675b5d6e8aea929e8b8a7a1e757c777292a89b4f 100644 (file)
@@ -142,7 +142,7 @@ struct rcu_gp rcu_gp = { .ctr = RCU_GP_COUNT };
  * 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);
 
index 4562ba4704f067bda7960ef225de46aca7ed0f3b..56fe943ac8d1ab8b9b5d260efca4d9e1ed8d7728 100644 (file)
@@ -88,7 +88,7 @@ static CDS_LIST_HEAD(call_rcu_data_list);
 
 /* 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.
index f96553365ba4f51035f427798edd2ac4eb981f13..b2e1b3cab6c72428c138e45fb800ebdedd0e0a53 100644 (file)
@@ -126,7 +126,7 @@ static int32_t defer_thread_stop;
  * 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;
 
index e029ace86a383b22256e2bf6da61cdb0fa526e1c..f343f0d836f642360b4b6f3e24dbae6358e1bbf4 100644 (file)
@@ -77,7 +77,7 @@ struct rcu_gp rcu_gp = { .ctr = RCU_GP_ONLINE };
  * 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);
 
index a81b12913e92d86b8eea95203f8d9054de8dda52..af8a2ce57f97b2f4d40247c0671c3c304ce0e7fe 100644 (file)
@@ -118,7 +118,7 @@ struct rcu_gp rcu_gp = { .ctr = RCU_GP_COUNT };
  * 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);
 
This page took 0.028963 seconds and 4 git commands to generate.