From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIsqL-0006Wt-Ko for qemu-devel@nongnu.org; Tue, 12 Jan 2016 01:54:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIsqI-0008Mb-EK for qemu-devel@nongnu.org; Tue, 12 Jan 2016 01:54:13 -0500 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:37369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIsqH-0008MR-S3 for qemu-devel@nongnu.org; Tue, 12 Jan 2016 01:54:10 -0500 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Jan 2016 16:54:01 +1000 Date: Tue, 12 Jan 2016 12:23:03 +0530 From: Bharata B Rao Message-ID: <20160112065302.GA11785@in.ibm.com> References: <1452236119-24452-1-git-send-email-bharata@linux.vnet.ibm.com> <1452236119-24452-7-git-send-email-bharata@linux.vnet.ibm.com> <20160112041615.GN22925@voom.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160112041615.GN22925@voom.redhat.com> Subject: Re: [Qemu-devel] [PATCH v6 06/11] cpu: Add a sync version of cpu_remove() Reply-To: bharata@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, pbonzini@redhat.com, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de, ehabkost@redhat.com On Tue, Jan 12, 2016 at 03:16:15PM +1100, David Gibson wrote: > On Fri, Jan 08, 2016 at 12:25:14PM +0530, Bharata B Rao wrote: > > This sync API will be used by the CPU hotplug code to wait for the CPU to > > completely get removed before flagging the failure to the device_add > > command. > > > > Sync version of this call is needed to correctly recover from CPU > > realization failures when ->plug() handler fails. > > > > Signed-off-by: Bharata B Rao > > Reviewed-by: David Gibson > > --- > > cpus.c | 12 ++++++++++++ > > include/qom/cpu.h | 8 ++++++++ > > 2 files changed, 20 insertions(+) > > > > diff --git a/cpus.c b/cpus.c > > index 12374af..c829bd6 100644 > > --- a/cpus.c > > +++ b/cpus.c > > @@ -1067,6 +1067,8 @@ 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); > > + cpu->created = false; > > + qemu_cond_signal(&qemu_cpu_cond); > > I know I reviewed this earlier, but I suspect this needs to be > qemu_cond_broadcast. qemu_cpu_cond is global, so there could (at > least in theory) be multiple things waiting on it, and we don't know > which one is waiting on *this* cpu, rather than another one (or on any > other condition handled by this qemu_cpu_cond). qemu_cpu_cond condition variable is currently handling the CPU creation condition where qemu_cond_signal() is being used. From what I understand, only main thread will be waiting on this condition. In this patch, I am using the same condition variable to track CPU deletion condition too. After this too, I think only main thread will be waiting for the deletion to get completed. So using qemu_cond_signal() should be ok isn't ? Regards, Bharata.