From: linzhecheng <linzc@zju.edu.cn>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, crosthwaite.peter@gmail.com,
rth@twiddle.net, linzhecheng <linzc@zju.edu.cn>,
linzhecheng <linzhecheng@huawei.com>
Subject: [Qemu-devel] [PATCH] vcpu: join vcpu thread after it exiting
Date: Thu, 1 Feb 2018 13:38:43 +0800 [thread overview]
Message-ID: <1517463523-21394-1-git-send-email-linzc@zju.edu.cn> (raw)
As we create vcpu thread with QEMU_THREAD_JOINABLE mode,
we should join it after it exiting to cleanup resources.
Signed-off-by: linzhecheng <linzhecheng@huawei.com>
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index f290f48..6ff71e4 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -282,9 +282,9 @@ err:
static int kvm_get_vcpu(KVMState *s, unsigned long vcpu_id)
{
- struct KVMParkedVcpu *cpu;
+ struct KVMParkedVcpu *cpu, *next_cpu;
- QLIST_FOREACH(cpu, &s->kvm_parked_vcpus, node) {
+ QLIST_FOREACH_SAFE(cpu, &s->kvm_parked_vcpus, node, *next_cpu) {
if (cpu->vcpu_id == vcpu_id) {
int kvm_fd;
diff --git a/cpus.c b/cpus.c
index 2cb0af9..1890bfe 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1205,6 +1205,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
cpu->created = false;
qemu_cond_signal(&qemu_cpu_cond);
qemu_mutex_unlock_iothread();
+ rcu_unregister_thread();
return NULL;
}
@@ -1759,6 +1760,7 @@ void cpu_remove_sync(CPUState *cpu)
cpu_remove(cpu);
while (cpu->created) {
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
+ qemu_thread_join(cpu->thread);
}
}
--
1.8.3.1
next reply other threads:[~2018-02-01 5:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-01 5:38 linzhecheng [this message]
2018-02-01 5:55 ` [Qemu-devel] [PATCH] vcpu: join vcpu thread after it exiting no-reply
2018-02-01 6:06 ` no-reply
2018-02-01 6:29 ` no-reply
2018-02-01 6:40 ` no-reply
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=1517463523-21394-1-git-send-email-linzc@zju.edu.cn \
--to=linzc@zju.edu.cn \
--cc=crosthwaite.peter@gmail.com \
--cc=linzhecheng@huawei.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).