fork: child should issue synchronize_rcu() for urcu-bp garbage collection
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 3 Mar 2011 16:46:20 +0000 (11:46 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 3 Mar 2011 16:46:20 +0000 (11:46 -0500)
After a fork(), the child process should execute synchronize_rcu() before any
new thread can be created. Failure to do so could lead to a deadlock in the
unlikely scenario where a thread ID appearing in the parent is reused in the
child before GC is performed.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
libust/tracectl.c

index bef4537dd4ffeb5311c4e83dabbf60adfbb3fbd3..3b60975391abf72c155f9822a1b06fe3db68004d 100644 (file)
@@ -1711,7 +1711,7 @@ static void ust_after_fork_common(ust_fork_info_t *fork_info)
 
 void ust_after_fork_parent(ust_fork_info_t *fork_info)
 {
-       /* Reenable signals */
+       /* Release mutexes and reenable signals */
        ust_after_fork_common(fork_info);
 }
 
@@ -1720,7 +1720,15 @@ void ust_after_fork_child(ust_fork_info_t *fork_info)
        /* First sanitize the child */
        ust_fork();
 
-       /* Then reenable interrupts */
+       /* Then release mutexes and reenable signals */
        ust_after_fork_common(fork_info);
+
+       /*
+        * Make sure we clean up the urcu-bp thread list in the child by running
+        * the garbage collection before any pthread_create can be called.
+        * Failure to do so could lead to a deadlock caused by reuse of a thread
+        * ID before urcu-bp garbage collection is performed.
+        */
+       synchronize_rcu();
 }
 
This page took 0.025121 seconds and 4 git commands to generate.