From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: qemu-devel@nongnu.org
Cc: "Aníbal Limón" <anibal.limon@linux.intel.com>
Subject: [Qemu-devel] [PATCH] cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
Date: Thu, 3 Sep 2015 15:48:33 -0500 [thread overview]
Message-ID: <1441313313-3040-1-git-send-email-anibal.limon@linux.intel.com> (raw)
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
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
cpus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cpus.c b/cpus.c
index 7e4786e..05e5400 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1171,7 +1171,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 {
--
1.9.1
next reply other threads:[~2015-09-03 20:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-03 20:48 Aníbal Limón [this message]
2015-09-04 8:15 ` [Qemu-devel] [PATCH] cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2015-09-03 19:24 Aníbal Limón
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=1441313313-3040-1-git-send-email-anibal.limon@linux.intel.com \
--to=anibal.limon@linux.intel.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).