From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXkMN-0002OK-Vi for qemu-devel@nongnu.org; Fri, 04 Sep 2015 02:20:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXkMK-0005mo-IU for qemu-devel@nongnu.org; Fri, 04 Sep 2015 02:20:27 -0400 Date: Fri, 4 Sep 2015 15:31:24 +1000 From: David Gibson Message-ID: <20150904053124.GV6537@voom.redhat.com> References: <1438838837-28504-1-git-send-email-bharata@linux.vnet.ibm.com> <1438838837-28504-2-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="VgNP6wxEowREGVu+" Content-Disposition: inline In-Reply-To: <1438838837-28504-2-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v4 01/11] exec: Remove cpu from cpus list during cpu_exec_exit() 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, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de --VgNP6wxEowREGVu+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 06, 2015 at 10:57:07AM +0530, Bharata B Rao wrote: > CPUState *cpu gets added to the cpus list during cpu_exec_init(). It > should be removed from cpu_exec_exit(). >=20 > cpu_exec_init() is called from generic CPU::instance_finalize and some > archs like PowerPC call it from CPU unrealizefn. So ensure that we > dequeue the cpu only once. >=20 > Instead of introducing a new field CPUState.queued, I could have used > CPUState.cpu_index to check if the cpu is already dequeued from the list. > Since that doesn't work for CONFIG_USER_ONLY, I had to add a new field. >=20 > Signed-off-by: Bharata B Rao This seems reasonable to me, but I'm wondering how x86 cpu hotplug / unplug is working without it. > --- > exec.c | 11 +++++++++++ > include/qom/cpu.h | 1 + > 2 files changed, 12 insertions(+) >=20 > diff --git a/exec.c b/exec.c > index 0a4a0c5..b196d68 100644 > --- a/exec.c > +++ b/exec.c > @@ -550,6 +550,10 @@ void cpu_exec_exit(CPUState *cpu) > return; > } > =20 > + if (cpu->queued) { > + QTAILQ_REMOVE(&cpus, cpu, node); > + cpu->queued =3D false; > + } > bitmap_clear(cpu_index_map, cpu->cpu_index, 1); > cpu->cpu_index =3D -1; > } > @@ -568,6 +572,12 @@ static int cpu_get_free_index(Error **errp) > =20 > void cpu_exec_exit(CPUState *cpu) > { > + cpu_list_lock(); > + if (cpu->queued) { > + QTAILQ_REMOVE(&cpus, cpu, node); > + cpu->queued =3D false; > + } > + cpu_list_unlock(); > } > #endif > =20 > @@ -595,6 +605,7 @@ void cpu_exec_init(CPUState *cpu, Error **errp) > return; > } > QTAILQ_INSERT_TAIL(&cpus, cpu, node); > + cpu->queued =3D true; > #if defined(CONFIG_USER_ONLY) > cpu_list_unlock(); > #endif > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 20aabc9..a00e3a8 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -284,6 +284,7 @@ struct CPUState { > int gdb_num_regs; > int gdb_num_g_regs; > QTAILQ_ENTRY(CPUState) node; > + bool queued; > =20 > /* ice debug support */ > QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; --=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 --VgNP6wxEowREGVu+ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJV6SysAAoJEGw4ysog2bOSmgsQAM+DzVn1COHxk2ksCAVVhjsL GgTTOz4OBbdrhNpSTtY5wJIa55ZsmqjuFgH73c0TfetppQhChiEc1n/Z6UzT5de6 vcm8ydXyv5BZ72OpInZNrI4oRkcQnMylaShn1szGkyUU4utArLBNFIAtMxQYMLe5 TozZfztk6F3svntJeu/iELgujrRXIYdlJm4tT5bZbGWMUhM5thmlYswtnCP87Qs0 1hSRd3kfD7ZZ+TyWKI9LyFQX8n+L2usg3lCv+LBowudZKlZAzotT9LV1dlUtDDLw NueORGuISe+h7s2pADkUSLCskBc3w5o28C3LBa1v+FweLyRmeETUmCpRhvxHIpeY knXILN6jkdvgSfcVNzzzveeCzKrlHbtntiP8oJiXskqxJRIJIvAJqbZ5AXCZByc2 tM9EdFbZwmYF5MEHq7U8aKb0m42MzRuKiycLdG932HV3updizoYWe/ix6taMTEz5 KIEFaV54wp3btAZSM7jf9IV6geK5vmUUWOAZ4PWc7s8MJuwZqPe0LnWucSvYxDwR nVSaR3SvlnrbD8zbRgWMImPWYyRFyO/F8ZAayZK/w53bRBU+6L85lNEROdxLJf0X bnpeFbKwRfgjkmco2ryZSo3k/4rE0BA6Jk5kOVfFTsuRKiYkp9L+s2miFL+ysXOS V5Iu143zlzTQYXGbwtIv =wqhc -----END PGP SIGNATURE----- --VgNP6wxEowREGVu+--