]> git.lttng.org Git - userspace-rcu.git/commitdiff
urcu-bp: perform thread registration on urcu_bp_register_thread
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 22 Nov 2019 16:02:36 +0000 (11:02 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 22 Nov 2019 16:02:36 +0000 (11:02 -0500)
Some real-time use-cases (e.g. Xenomai) require to perform urcu-bp
thread registration early in the thread life-time before it starts
performing real-time tasks.

Currently, this can be achieved by issuing a urcu_bp_read_lock() and
urcu_bp_read_unlock() pair, or by using urcu_bp_read_ongoing(), while in
the initialization phrase.

However, it seems natural to expect that calling urcu_bp_register_thread()
would have the side effect to perform the lazy thread registration
immediately rather than being a no-op.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
README.md
include/urcu/urcu-bp.h
src/urcu-bp.c

index 601703bdf6209af39c9e27e47a9d0c9d3e2d6b13..2d6dcaa2a4bfba1199c7dee5bcad5ec743acebf8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -224,10 +224,11 @@ be overridden with `-DSIGRCU` by modifying `Makefile.build.inc`.
 
 The BP library flavor stands for "bulletproof". It is specifically
 designed to help tracing library to hook on applications without
-requiring to modify these applications. `urcu_bp_init()`,
-`urcu_bp_register_thread()` and `urcu_bp_unregister_thread()` all become
-nops. The state is dealt with by the library internally at the expense
-of read-side and write-side performance.
+requiring to modify these applications. `urcu_bp_init()`, and
+`urcu_bp_unregister_thread()` all become nops, whereas calling
+`urcu_bp_register_thread()` becomes optional. The state is dealt with by
+the library internally at the expense of read-side and write-side
+performance.
 
 
 ### Initialization
index d3d122d0f71df610a0276af0e3e5043a6adf4ee7..2ea17e6397391fae5e081118215ac717efbc0ae0 100644 (file)
@@ -151,12 +151,14 @@ extern void urcu_bp_after_fork_parent(void);
 extern void urcu_bp_after_fork_child(void);
 
 /*
- * In the bulletproof version, the following functions are no-ops.
+ * In the bulletproof version, thread registration is performed lazily,
+ * but it can be forced by issuing an explicit urcu_bp_register_thread().
  */
-static inline void urcu_bp_register_thread(void)
-{
-}
+extern void urcu_bp_register_thread(void);
 
+/*
+ * In the bulletproof version, the following functions are no-ops.
+ */
 static inline void urcu_bp_unregister_thread(void)
 {
 }
index 33f280799208c66f0337e25acfeaf8adce213aa1..05efd97eb67a2c05c99a09dfb5c6e29e888ff81e 100644 (file)
@@ -566,6 +566,12 @@ end:
 }
 URCU_ATTR_ALIAS("urcu_bp_register") void rcu_bp_register();
 
+void urcu_bp_register_thread(void)
+{
+       if (caa_unlikely(!URCU_TLS(urcu_bp_reader)))
+               urcu_bp_register(); /* If not yet registered. */
+}
+
 /* Disable signals, take mutex, remove from registry */
 static
 void urcu_bp_unregister(struct rcu_reader *rcu_reader_reg)
This page took 0.031324 seconds and 4 git commands to generate.