From: paulmck@linux.vnet.ibm.com (Paul E. McKenney)
Subject: [ltt-dev] [PATCH urcu 1/5] Provide pthread_atfork-friendly interfaces
Date: Thu, 2 Jun 2011 16:45:00 -0700 [thread overview]
Message-ID: <1307058304-22793-1-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20110602234414.GA22701@linux.vnet.ibm.com>
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 at linux.vnet.ibm.com>
---
README | 4 ++++
urcu-call-rcu.c | 26 +++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/README b/README
index f7f0dec..56e98d7 100644
--- 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().
diff --git a/urcu-call-rcu.c b/urcu-call-rcu.c
index bb56dbb..9cc56c5 100644
--- a/urcu-call-rcu.c
+++ b/urcu-call-rcu.c
@@ -566,13 +566,37 @@ 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.
--
1.7.3.2
next prev parent reply other threads:[~2011-06-02 23:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-02 23:44 [ltt-dev] [PATCH userspace-rcu] Allow multiple flavors of RCU in same executable Paul E. McKenney
2011-06-02 23:45 ` Paul E. McKenney [this message]
2011-06-02 23:45 ` [ltt-dev] [PATCH urcu 2/5] Map symbols to allow multiple RCU flavors to be used in one binary Paul E. McKenney
2011-06-02 23:45 ` [ltt-dev] [PATCH urcu 3/5] Allow taking address of rcu_read_lock() and rcu_read_unlock() Paul E. McKenney
2011-06-02 23:45 ` [ltt-dev] [PATCH urcu 4/5] Make defer_rcu() usable from library using multiple URCU implementations Paul E. McKenney
2011-06-02 23:45 ` [ltt-dev] [PATCH urcu 5/5] Document the new call_rcu() primitives Paul E. McKenney
2011-06-03 16:47 ` [ltt-dev] [PATCH userspace-rcu] Allow multiple flavors of RCU in same executable Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1307058304-22793-1-git-send-email-paulmck@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox