summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-03-31 13:01:05 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2015-04-01 10:06:38 +0200
commita59629fcc6f603e19b516dc08f75334e5c480bd0 (patch)
tree4c663417db01a79eedc121f83e176dfb7c503b93 /util
parente65bef6954415b24ee17184b959333d9456bece8 (diff)
downloadqemu-a59629fcc6f603e19b516dc08f75334e5c480bd0.tar.gz
qemu-a59629fcc6f603e19b516dc08f75334e5c480bd0.tar.bz2
qemu-a59629fcc6f603e19b516dc08f75334e5c480bd0.zip
rcu: do not create thread in pthread_atfork callback
If QEMU forks after the CPU threads have been created, qemu_mutex_lock_iothread will not be able to do qemu_cpu_kick_thread. There is no solution other than assuming that forks after the CPU threads have been created will end up in an exec. Forks before the CPU threads have been created (such as -daemonize) have to call rcu_after_fork manually. Notably, the oxygen theme for GTK+ forks and shows a "No such process" error without this patch. This patch can be reverted once the iothread loses the "kick the TCG thread" magic. User-mode emulation does not use the iothread, so it can also call rcu_after_fork. Reported by: Dr. David Alan Gilbert <dgilbert@redhat.com> Tested by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/rcu.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/util/rcu.c b/util/rcu.c
index 27802a4bed..7270151bef 100644
--- a/util/rcu.c
+++ b/util/rcu.c
@@ -311,19 +311,18 @@ static void rcu_init_unlock(void)
{
qemu_mutex_unlock(&rcu_gp_lock);
}
+#endif
-static void rcu_init_child(void)
+void rcu_after_fork(void)
{
- qemu_mutex_unlock(&rcu_gp_lock);
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_child);
+ pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_unlock);
#endif
rcu_init_complete();
}