From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIqby-0001Cp-Vb for qemu-devel@nongnu.org; Mon, 11 Jan 2016 23:31:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIqbx-0001hQ-Tk for qemu-devel@nongnu.org; Mon, 11 Jan 2016 23:31:14 -0500 Date: Tue, 12 Jan 2016 15:06:53 +1100 From: David Gibson Message-ID: <20160112040653.GK22925@voom.redhat.com> References: <1452236119-24452-1-git-send-email-bharata@linux.vnet.ibm.com> <1452236119-24452-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="RNGrj7vazCqBHNw7" Content-Disposition: inline In-Reply-To: <1452236119-24452-3-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v6 02/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, 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 --RNGrj7vazCqBHNw7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 08, 2016 at 12:25:10PM +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. >=20 > Signed-off-by: Bharata B Rao Reviewed-by: David Gibson > --- > exec.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) >=20 > diff --git a/exec.c b/exec.c > index 8718a75..25c0f36 100644 > --- a/exec.c > +++ b/exec.c > @@ -578,6 +578,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; > } > @@ -596,6 +597,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) { > + cpu_list_unlock(); > + return; > + } > + > + QTAILQ_REMOVE(&cpus, cpu, node); > + 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 --RNGrj7vazCqBHNw7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWlHvdAAoJEGw4ysog2bOSy7QP/0HwhsOmezkMczsxS1Iq8SsO aERcjBf4Ar9tJdZmPrSaFhdwFNN4w/35aqUBnhiRB5OcqFCbGNWmzb76tCcKJA2n eOyyVh9/J7zWmkvS2O/5AJPfLVzIAok0BtqcokYq53P/jEQbXxQkmlbBqkpuvJWb CHjcYWtuRVHPqsRP6hnNHXBT/reS1lpbNsZej+SoeSGH2jk2HvfHp7xCq1WBnqcQ 7lSRtZp/x6yl96oWbJDxTIZHWQcFdVVMRjcU0ho7C7CioQlJt9LmPfr35Z78UvSc HGgGFRZJvQuEgrMcpSPrwT+7tAZrs9IIiNY9Jk8sXYIuiHoDQhys5qeLq7ZBmnoZ OZThCLsAL5XoZXfxioX5vF7CehypF6Sjcfa6dWkkFMG1gjGl2V7ObTRSzd44j6bR CjMlNZlyUvpELXTz7BW1NJnPgOF1rym1qGVuGV+pxdYM2vqkZ2GGv7MW9h4XFP/0 YYrDnJRxxHUgP61gjuSOPTiL6RT2N6cgoFgtoJczACGCZqwY0P8BTSepB0xAYAYO WW2Efqo62XMLRFfZToiHzANs5BXuwu7bGmxT4K+IrodMISjD82m7WHUt764oryQO fp63pE7IYEcfmI75rB00taknRN+5qd7ucfB5XC+CY5AJLpfc0IAZwqvxwodNMoey 3DgFv4LrwCdiliezRV2w =Nknu -----END PGP SIGNATURE----- --RNGrj7vazCqBHNw7--