From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Zxy-00074N-MB for qemu-devel@nongnu.org; Mon, 30 Nov 2015 20:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3Zxu-000195-Je for qemu-devel@nongnu.org; Mon, 30 Nov 2015 20:42:50 -0500 Date: Tue, 1 Dec 2015 11:44:03 +1100 From: David Gibson Message-ID: <20151201004403.GA31343@voom.redhat.com> References: <1448024079-20808-1-git-send-email-bharata@linux.vnet.ibm.com> <1448024079-20808-3-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mYCpIKhGyMATD0i+" Content-Disposition: inline In-Reply-To: <1448024079-20808-3-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v5 02/10] 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, pbonzini@redhat.com, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 20, 2015 at 06:24:31PM +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 > Now -1 value for cpu->cpu_index indicates that we have already dequeued > the cpu for CONFIG_USER_ONLY case also. It's not clear to me if you're intending this just as an interim step or not. Surely we should fix the existing code to be consistent about where the QTAILQ_REMOVE is done, rather than using a special -1 flag? >=20 > Signed-off-by: Bharata B Rao > --- > exec.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) >=20 > diff --git a/exec.c b/exec.c > index b09f18b..fbac85b 100644 > --- a/exec.c > +++ b/exec.c > @@ -593,6 +593,7 @@ void cpu_exec_exit(CPUState *cpu) > return; > } > =20 > + QTAILQ_REMOVE(&cpus, cpu, node); > bitmap_clear(cpu_index_map, cpu->cpu_index, 1); > cpu->cpu_index =3D -1; > } > @@ -611,6 +612,15 @@ static int cpu_get_free_index(Error **errp) > =20 > void cpu_exec_exit(CPUState *cpu) > { > + cpu_list_lock(); > + if (cpu->cpu_index =3D=3D -1) { =2E. especially since as far as I can tell you're only testing for the -1 value here, which is in the USER_ONLY version of this function. > + cpu_list_unlock(); > + return; > + } > + > + QTAILQ_REMOVE(&cpus, cpu, node); Again, as the user only version of the function, is this redundant with the removals in linux-user/{main.c,syscall.c}? > + cpu->cpu_index =3D -1; > + cpu_list_unlock(); > } > #endif > =20 --=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 --mYCpIKhGyMATD0i+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWXO1TAAoJEGw4ysog2bOS1YAQAK7pmSd65Cz+zF6F770OSgMx qhSF7H7blqdXrlMKjcea9VonzZbf5qvHOKsszutPipLI5WRghB3VmxNLjYvTzmUG tNmxcjh/L3LQG2p/b8C0tM5OShdPuuCyU14FIAzqy6UXAbtnPKuITiD+Fcj2oL6n TLtpKih4xDzAA2FXKU1GgE1e+DRrcGH+Ue/GaML3GBTvxkjTRdvWJ+Ka1wSN4xpQ 27HdSIYG9VCtrGoaDu8sAyVaraIEukPzPwW0nE6qXXlOR0CR5Kkw9sPs+WWzzK3X WUmRLTAWu+HzivLrRGde+oGEbQnRts62xpdpGl8EgjO4kR4IGglDZjDDw6sYlwy6 O0gacDtqDN1pY09GEBVN7qiwcPj1yBJDDVHLP/QdF4uOhwtEvnqI8wQ/h2zJj7WO 6wirIahPAKKG0cDriWvJmyzKYjWnpsQbFZ80S3gx8nSPBLX/NLZbNESCzlTsQmrx LUidUaQKCjkvN9D8S4sMQj51tS9+gpvq/jiuBrVr3egF7BU8/JbnaRf/uPadiBB4 yINLtRn3XPXdBawNVD25MjVjsIFGAbbmR6m9DB5HA8q3nRbNFKuSM1morLv/WaOe x+23joKlxb88/VtN4w21KSOwlI+Sm0TJlEKUiY1HK4vSYO++UORleCCt4JEHh5J8 sA8vEzAdsw7TVy4NnEQt =zE94 -----END PGP SIGNATURE----- --mYCpIKhGyMATD0i+--