Provide pthread_atfork-friendly interfaces
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Fri, 3 Jun 2011 16:42:00 +0000 (12:42 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 3 Jun 2011 16:42:00 +0000 (12:42 -0400)
Provides call_rcu_before_fork() and call_rcu_after_fork_parent() to
go with the existing call_rcu_after_fork_child().

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
README
urcu-call-rcu.c

diff --git a/README b/README
index f7f0dece2249bb764af9932a35cbf1ca57abffa3..56e98d768e960ede0a80245a8a1a725218de33d4 100644 (file)
--- a/README
+++ b/README
@@ -204,3 +204,7 @@ Interaction with fork()
        liburcu-bp, which is designed to handle fork() by calling
        rcu_bp_before_fork, rcu_bp_after_fork_parent and
        rcu_bp_after_fork_child.
+
+       Applications that use call_rcu() are required to invoke
+       call_rcu_after_fork_child() from the child process after a
+       successful fork() system call that is not followed by exec().
index bb56dbb891fa0a270e7058bd18a47bfe4d554cbf..9cc56c54fafc39dfabef67c984663e3ba0d0155e 100644 (file)
@@ -565,14 +565,38 @@ void free_all_cpu_call_rcu_data(void)
        }
 }
 
+/*
+ * Acquire the call_rcu_mutex in order to ensure that the child sees
+ * all of the call_rcu() data structures in a consistent state.
+ * Suitable for pthread_atfork() and friends.
+ */
+void call_rcu_before_fork(void)
+{
+       call_rcu_lock(&call_rcu_mutex);
+}
+
+/*
+ * Clean up call_rcu data structures in the parent of a successful fork()
+ * that is not followed by exec() in the child.  Suitable for
+ * pthread_atfork() and friends.
+ */
+void call_rcu_after_fork_parent(void)
+{
+       call_rcu_unlock(&call_rcu_mutex);
+}
+
 /*
  * Clean up call_rcu data structures in the child of a successful fork()
- * that is not followed by exec().
+ * that is not followed by exec().  Suitable for pthread_atfork() and
+ * friends.
  */
 void call_rcu_after_fork_child(void)
 {
        struct call_rcu_data *crdp;
 
+       /* Release the mutex. */
+       call_rcu_unlock(&call_rcu_mutex);
+
        /*
         * Allocate a new default call_rcu_data structure in order
         * to get a working call_rcu thread to go with it.
This page took 0.026579 seconds and 4 git commands to generate.