Revert "rcu: do not create thread in pthread_atfork callback"
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Mar 2016 13:00:51 +0000 (14:00 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 8 Aug 2017 08:40:19 +0000 (10:40 +0200)
This reverts commit a59629fcc6f603e19b516dc08f75334e5c480bd0.
This is not needed anymore because the IOThread mutex is not
"magic" anymore (need not kick the CPU thread)and also because
fork callbacks are only enabled at the very beginning of
QEMU's execution.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/qemu/rcu.h
linux-user/syscall.c
os-posix.c
util/rcu.c

index c0da9907e88d817cc4ee9675f9c14519452e508b..f19413d649ab1dacb9363746cf3b2b91d866c0ba 100644 (file)
@@ -111,7 +111,6 @@ extern void rcu_unregister_thread(void);
  */
 extern void rcu_enable_atfork(void);
 extern void rcu_disable_atfork(void);
-extern void rcu_after_fork(void);
 
 struct rcu_head;
 typedef void RCUCBFunc(struct rcu_head *head);
index 54343c06bedb8a8b93297213eae67714c9964241..9b6364a266dc18a1020db25a0620336634a73309 100644 (file)
@@ -6354,7 +6354,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
         ret = fork();
         if (ret == 0) {
             /* Child Process.  */
-            rcu_after_fork();
             cpu_clone_regs(env, newsp);
             fork_end(1);
             /* There is a race condition here.  The parent process could
index c6ddb7d830198929d2805d74b64336fae12def08..92e9d852158b39c128623bf871d547b11acb0bc8 100644 (file)
@@ -34,7 +34,6 @@
 #include "sysemu/sysemu.h"
 #include "net/slirp.h"
 #include "qemu-options.h"
-#include "qemu/rcu.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "qemu/cutils.h"
@@ -249,7 +248,6 @@ void os_daemonize(void)
         signal(SIGTSTP, SIG_IGN);
         signal(SIGTTOU, SIG_IGN);
         signal(SIGTTIN, SIG_IGN);
-        rcu_after_fork();
     }
 }
 
index 2142ddd93baf4e82725799d25f2a394f3cc93b64..ca5a63e36af68a4fb115c94f4c9b260341d66494 100644 (file)
@@ -350,18 +350,22 @@ static void rcu_init_unlock(void)
     qemu_mutex_unlock(&rcu_registry_lock);
     qemu_mutex_unlock(&rcu_sync_lock);
 }
-#endif
 
-void rcu_after_fork(void)
+static void rcu_init_child(void)
 {
+    if (atfork_depth < 1) {
+        return;
+    }
+
     memset(&registry, 0, sizeof(registry));
     rcu_init_complete();
 }
+#endif
 
 static void __attribute__((__constructor__)) rcu_init(void)
 {
 #ifdef CONFIG_POSIX
-    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_unlock);
+    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_child);
 #endif
     rcu_init_complete();
 }