Clean-up: explicit mb before decrementing lttng_sessiond_ready
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 18 May 2018 19:03:13 +0000 (15:03 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 18 May 2018 19:07:51 +0000 (15:07 -0400)
This is mostly a documentation fix as there are no thread-safety
implications to this change. uatomic_sub_return() was used since it
performs a full memory barrier before and after the atomic operation
(as per the urcu documentation).

The barrier performed after the substraction is not needed in this
particular case. Moreover, using an explicit cmm_smp_mb() statement
makes the code clearer; see the comment as to why this barrier is
needed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/main.c

index f9b41d2707bd26aff4f95a72aa1885d2f2f09280..9c2458eb1a15a1bee49d1a1babe3d0390418390e 100644 (file)
@@ -366,10 +366,21 @@ LTTNG_HIDDEN
 void sessiond_notify_ready(void)
 {
        /*
-        * The _return variant is used since the implied memory barriers are
-        * required.
+        * This memory barrier is paired with the one performed by
+        * the client thread after it has seen that 'lttng_sessiond_ready' is 0.
+        *
+        * The purpose of these memory barriers is to ensure that all
+        * initialization operations of the various threads that call this
+        * function to signal that they are ready are commited/published
+        * before the client thread can see the 'lttng_sessiond_ready' counter
+        * reach 0.
+        *
+        * Note that this could be a 'write' memory barrier, but a full barrier
+        * is used in case the code using this utility changes. The performance
+        * implications of this choice are minimal since this is a slow path.
         */
-       (void) uatomic_sub_return(&lttng_sessiond_ready, 1);
+       cmm_smp_mb();
+       uatomic_sub(&lttng_sessiond_ready, 1);
 }
 
 static
This page took 0.02825 seconds and 5 git commands to generate.