From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: linzc@zju.edu.cn
Subject: [Qemu-devel] [PATCH 6/6] cpus: join thread when removing a vCPU
Date: Thu, 1 Feb 2018 09:44:30 -0500 [thread overview]
Message-ID: <20180201144430.14441-7-pbonzini@redhat.com> (raw)
In-Reply-To: <20180201144430.14441-1-pbonzini@redhat.com>
If no one joins the thread, its associated memory is leaked.
Reported-by: CheneyLin <linzc@zju.edu.cn>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
cpus.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/cpus.c b/cpus.c
index 03b4533b7d..e8c3ba064c 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1795,19 +1795,14 @@ void resume_all_vcpus(void)
}
}
-void cpu_remove(CPUState *cpu)
+void cpu_remove_sync(CPUState *cpu)
{
cpu->stop = true;
cpu->unplug = true;
qemu_cpu_kick(cpu);
-}
-
-void cpu_remove_sync(CPUState *cpu)
-{
- cpu_remove(cpu);
- while (cpu->created) {
- qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
- }
+ qemu_mutex_unlock_iothread();
+ qemu_thread_join(cpu->thread);
+ qemu_mutex_lock_iothread();
}
/* For temporary buffers for forming a name */
--
2.14.3
prev parent reply other threads:[~2018-02-01 14:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-01 14:44 [Qemu-devel] [PATCH 0/6] cpus: fix various issues with vCPU unplug Paolo Bonzini
2018-02-01 14:44 ` [Qemu-devel] [PATCH 1/6] cpus: hax: register/unregister thread with RCU, exit loop on unplug Paolo Bonzini
2018-02-01 14:44 ` [Qemu-devel] [PATCH 2/6] cpus: kvm: unregister thread with RCU Paolo Bonzini
2018-02-01 14:44 ` [Qemu-devel] [PATCH 3/6] cpus: dummy: unregister thread with RCU, exit loop on unplug Paolo Bonzini
2018-02-01 14:44 ` [Qemu-devel] [PATCH 4/6] cpus: tcg: unregister thread with RCU, fix exiting of " Paolo Bonzini
2018-02-01 15:05 ` Eric Blake
2018-02-01 14:44 ` [Qemu-devel] [PATCH 5/6] cpus: hvf: unregister thread with RCU Paolo Bonzini
2018-02-01 14:44 ` Paolo Bonzini [this message]
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=20180201144430.14441-7-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=linzc@zju.edu.cn \
--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).