aboutsummaryrefslogtreecommitdiff
path: root/cpus.c
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2015-09-03 15:48:33 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2015-09-07 18:14:03 +0200
commit46036b2462c7ff56c0af6466ea6b9248197a38a8 (patch)
treeedcc2ee271920fdcd94aa1aa5e4884ac96628d6e /cpus.c
parentd12f7309483e20d1bae9304f4b812bf53a8e6510 (diff)
downloadqemu-46036b2462c7ff56c0af6466ea6b9248197a38a8.zip
qemu-46036b2462c7ff56c0af6466ea6b9248197a38a8.tar.gz
qemu-46036b2462c7ff56c0af6466ea6b9248197a38a8.tar.bz2
cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
When QEMU starts the RCU thread executes qemu_mutex_lock_thread causing error "qemu:qemu_cpu_kick_thread: No such process" and exits. This isn't occur frequently but in glibc the thread id can exist and this not guarantee that the thread is on active/running state. If is inserted a sleep(1) after newthread assignment [1] the issue appears. So not make assumption that thread exist if first_cpu->thread is set then change the validation of cpu to created that is set into cpu threads (kvm, tcg, dummy). [1] https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_create.c;h=d10f4ea8004e1d8f3a268b95cc0f8d93b8d89867;hb=HEAD#l621 Cc: qemu-stable@nongnu.org Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Message-Id: <1441313313-3040-1-git-send-email-anibal.limon@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'cpus.c')
-rw-r--r--cpus.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cpus.c b/cpus.c
index c1e74d9..e831aa3 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1166,7 +1166,7 @@ void qemu_mutex_lock_iothread(void)
* TCG code execution.
*/
if (!tcg_enabled() || qemu_in_vcpu_thread() ||
- !first_cpu || !first_cpu->thread) {
+ !first_cpu || !first_cpu->created) {
qemu_mutex_lock(&qemu_global_mutex);
atomic_dec(&iothread_requesting_mutex);
} else {