Fix: perform the initialization memory barrier out of loop body
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 18 May 2018 19:08:14 +0000 (15:08 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 18 May 2018 19:16:08 +0000 (15:16 -0400)
The memory barrier used by the client thread should be performed
after the lttng_sessiond_ready counter has been seen to have
reached zero.

This ensures that loads are not speculatively performed before
this point as the thread will interact with data structures
initialized by the support threads for which it was waiting for
the initialization to complete.

See the comment as to why this read barrier is promoted to a
full barrier.

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

index d5759b39180d1d789d7171ef6b5c68202ac03c01..125a18769107269322813923d438e51f062694ae 100644 (file)
@@ -4441,8 +4441,17 @@ static void *thread_manage_clients(void *data)
                if (ret > 0 || (ret < 0 && errno != EINTR)) {
                        goto exit;
                }
-               cmm_smp_rmb();
        }
+       /*
+        * This barrier is paired with the one in sessiond_notify_ready() to
+        * ensure that loads accessing data initialized by the other threads,
+        * on which this thread was waiting, are not performed before this point.
+        *
+        * Note that this could be a 'read' memory barrier, but a full barrier
+        * is used in case the code changes. The performance implications of
+        * this choice are minimal since this is a slow path.
+        */
+       cmm_smp_mb();
 
        /* This testpoint is after we signal readiness to the parent. */
        if (testpoint(sessiond_thread_manage_clients)) {
This page took 0.026675 seconds and 4 git commands to generate.