From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIqc0-0001EZ-D0 for qemu-devel@nongnu.org; Mon, 11 Jan 2016 23:31:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIqbz-0001i8-9S for qemu-devel@nongnu.org; Mon, 11 Jan 2016 23:31:16 -0500 Date: Tue, 12 Jan 2016 15:16:15 +1100 From: David Gibson Message-ID: <20160112041615.GN22925@voom.redhat.com> References: <1452236119-24452-1-git-send-email-bharata@linux.vnet.ibm.com> <1452236119-24452-7-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gqEssfNGWsEa4HfM" Content-Disposition: inline In-Reply-To: <1452236119-24452-7-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v6 06/11] cpu: Add a sync version of cpu_remove() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao 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 --gqEssfNGWsEa4HfM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > Sync version of this call is needed to correctly recover from CPU > realization failures when ->plug() handler fails. >=20 > Signed-off-by: Bharata B Rao > Reviewed-by: David Gibson > --- > cpus.c | 12 ++++++++++++ > include/qom/cpu.h | 8 ++++++++ > 2 files changed, 20 insertions(+) >=20 > 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 =3D 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_mutex_unlock_iothread(); > return NULL; > } > @@ -1171,6 +1173,8 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) > } > if (remove_cpu) { > qemu_tcg_destroy_vcpu(remove_cpu); > + cpu->created =3D false; > + qemu_cond_signal(&qemu_cpu_cond); > remove_cpu =3D NULL; > } > } > @@ -1336,6 +1340,14 @@ void cpu_remove(CPUState *cpu) > qemu_cpu_kick(cpu); > } > =20 > +void cpu_remove_sync(CPUState *cpu) > +{ > + cpu_remove(cpu); > + while (cpu->created) { > + qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); > + } > +} > + > /* For temporary buffers for forming a name */ > #define VCPU_THREAD_NAME_SIZE 16 > =20 > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 67e05b0..7fc6696 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -705,6 +705,14 @@ void cpu_resume(CPUState *cpu); > */ > void cpu_remove(CPUState *cpu); > =20 > + /** > + * cpu_remove_sync: > + * @cpu: The CPU to remove. > + * > + * Requests the CPU to be removed and waits till it is removed. > + */ > +void cpu_remove_sync(CPUState *cpu); > + > /** > * qemu_init_vcpu: > * @cpu: The vCPU to initialize. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --gqEssfNGWsEa4HfM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWlH4PAAoJEGw4ysog2bOSiKYQALzcPdgtXw+nwRzCjx9JJ9VL 4kS9/F8n9B6B0bFASTEysDHHRqjSB1/gvw6yornSchONy4pe+sq/9wtGzOf+lB3R TnKK8bHLXC/DdDYJZ+iMxZccGWpjOc1w6AAovXqAkFzxaGb0k6zZ9nOQFzSrOWU4 2lbHknEKnADvopc6Zu6fZ/8/ckKi43bEjF5zIBn6vSlo2HWAoKCIKu42XPNCt/2U zad/3qtqx6Ecy8zw3iADbW1SxT1PYI3bXpAmqkQGmmPXzgJih0RMMLc1pcVJDYeo g5CbJqCndrpbYYYlB/lslPzlbuPi2ZFCTMWGTXZcKSjC37N3cFlrbhCFW3pWnxA2 09vSjKmToKYv76FhnYCt3/Gf95WziVLVxyjBxduH9xaNNgTnLYlC+/R9D+LZfJRv 5Ew+/JE5wsQLZBp/ox+o71KmK6Ej5kra+CuNYVh8aHiYjopIzrzjHkhXerXAaDyH 30eNQNTbu07l5tbUiA9//2cqq+kIERF0UxefzrvaM+E5MT1MEXh1jOHOBCD/lMsw bDF1bjXH2TpdUdFSfkv8I3zBnnmAnQ5V4SeP771CvpEr3cREvxZp4e+LFnnCmRg7 4V55bDyk0x555nY2T+HVUcvIh8G3Y1rtrAyaQ2oGHubUthz2BW/41qL7vsRRuEm3 wseNmJutCWcx1P8tXsRd =2lv9 -----END PGP SIGNATURE----- --gqEssfNGWsEa4HfM--