From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3ySE-0002hL-8I for qemu-devel@nongnu.org; Tue, 01 Dec 2015 22:51:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3ySB-0000ky-0e for qemu-devel@nongnu.org; Tue, 01 Dec 2015 22:51:42 -0500 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:43679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3ySA-0000ki-F2 for qemu-devel@nongnu.org; Tue, 01 Dec 2015 22:51:38 -0500 Received: from localhost by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Dec 2015 13:51:35 +1000 Date: Wed, 2 Dec 2015 09:20:38 +0530 From: Bharata B Rao Message-ID: <20151202035037.GD16342@in.ibm.com> References: <1448024079-20808-1-git-send-email-bharata@linux.vnet.ibm.com> <1448024079-20808-5-git-send-email-bharata@linux.vnet.ibm.com> <565BFB2C.6040201@ozlabs.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <565BFB2C.6040201@ozlabs.ru> Subject: Re: [Qemu-devel] [PATCH v5 04/10] cpu: Reclaim vCPU objects Reply-To: bharata@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Zhu Guihua , mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-devel@nongnu.org, Chen Fan , pbonzini@redhat.com, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, Gu Zheng , imammedo@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au On Mon, Nov 30, 2015 at 06:30:52PM +1100, Alexey Kardashevskiy wrote: > On 11/20/2015 11:54 PM, Bharata B Rao wrote: > >From: Gu Zheng > > > >In order to deal well with the kvm vcpus (which can not be removed without any > >protection), we do not close KVM vcpu fd, just record and mark it as stopped > >into a list, so that we can reuse it for the appending cpu hot-add request if > >possible. It is also the approach that kvm guys suggested: > >https://www.mail-archive.com/kvm@vger.kernel.org/msg102839.html > > > >Signed-off-by: Chen Fan > >Signed-off-by: Gu Zheng > >Signed-off-by: Zhu Guihua > >Signed-off-by: Bharata B Rao > > [- Explicit CPU_REMOVE() from qemu_kvm/tcg_destroy_vcpu() > > isn't needed as it is done from cpu_exec_exit()] > >Reviewed-by: David Gibson > >--- > > cpus.c | 41 +++++++++++++++++++++++++++++++++++++ > > include/qom/cpu.h | 10 +++++++++ > > include/sysemu/kvm.h | 1 + > > kvm-all.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++- > > kvm-stub.c | 5 +++++ > > 5 files changed, 113 insertions(+), 1 deletion(-) > > > >diff --git a/cpus.c b/cpus.c > >index 877bd70..af2b274 100644 > >--- a/cpus.c > >+++ b/cpus.c > >@@ -953,6 +953,21 @@ void async_run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data) > > qemu_cpu_kick(cpu); > > } > > > >+static void qemu_kvm_destroy_vcpu(CPUState *cpu) > >+{ > >+ if (kvm_destroy_vcpu(cpu) < 0) { > >+ error_report("kvm_destroy_vcpu failed.\n"); > >+ exit(EXIT_FAILURE); > >+ } > >+ > >+ object_unparent(OBJECT(cpu)); > >+} > >+ > >+static void qemu_tcg_destroy_vcpu(CPUState *cpu) > >+{ > >+ object_unparent(OBJECT(cpu)); > >+} > >+ > > static void flush_queued_work(CPUState *cpu) > > { > > struct qemu_work_item *wi; > >@@ -1053,6 +1068,11 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) > > } > > } > > qemu_kvm_wait_io_event(cpu); > >+ if (cpu->exit && !cpu_can_run(cpu)) { > >+ qemu_kvm_destroy_vcpu(cpu); > >+ qemu_mutex_unlock(&qemu_global_mutex); > > > Nit: qemu_mutex_unlock_iothread() may be? Or it is important for > iothread_locked to remain "true"? It does not seem to be used much though. This patch is quite old and qemu_global_mutex got changed to qemu_mutex_unlock_iothread() some time ago in this part of the code. Thanks for noticing this, will fix this in next version. Regards, Bharata.