From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQR3P-0006sU-VL for qemu-devel@nongnu.org; Thu, 21 Jul 2016 23:23:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQR3M-0003tR-5q for qemu-devel@nongnu.org; Thu, 21 Jul 2016 23:23:10 -0400 Date: Fri, 22 Jul 2016 11:41:52 +1000 From: David Gibson Message-ID: <20160722014152.GF15941@voom.fritz.box> References: <1469116479-233280-1-git-send-email-imammedo@redhat.com> <1469116479-233280-6-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yH1ZJFh+qWm+VodA" Content-Disposition: inline In-Reply-To: <1469116479-233280-6-git-send-email-imammedo@redhat.com> Subject: Re: [Qemu-devel] [PATCH 5/8] pc: init CPUState->cpu_index with index in possible_cpus[] List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, Paolo Bonzini , Peter Crosthwaite , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Alexander Graf , Riku Voipio , Bharata B Rao , qemu-ppc@nongnu.org --yH1ZJFh+qWm+VodA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 21, 2016 at 05:54:36PM +0200, Igor Mammedov wrote: > It will enshure that cpu_index for a given cpu stays the same > regardless of the order cpus has been created/deleted. >=20 > No compat code is needed as for initial cpus index in > possible_cpus[] matches cpu_index that's been auto-allocated > in cpu_exec_init(). >=20 > Tha same applies for hotplug with cpu-add command if cpus are > added sequentially in increasing order as 'id' matches cpu_index. >=20 > If cpu-add had been used for creating out-of-order cpus, > that created unmigratable instance since it were not possible > to start target with the same cpu_index using old way > of migrating instance with hotplugged cpus: >=20 > * source QEMU with CLI (-smp 1,maxcpus=3D3 and cpu-add id=3D2) > following set of cpu_index is allocated [0, 1] with > apics set [0, 2] respectivelly > * target QEMU is started with CLI -smp 2,maxcpus=3D3 > resulting in set of cpu_index [0, 1] but with > set of apics [0, 1] wich doesn't match source. >=20 > So we don't need compat code in this case as it's never worked > and newelly added device_add support would use stable cpu_index > set by machine to begin with, so it won't have above limitation > and source QEMU could be migrated to destination regardless > of the order cpus were created. >=20 > Signed-off-by: Igor Mammedov Reviewed-by: David Gibson > --- > hw/i386/pc.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index ac7a4d5..316fb43 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1872,6 +1872,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, > DeviceState *dev, Error **errp) > { > int idx; > + CPUState *cs; > CPUArchId *cpu_slot; > X86CPUTopoInfo topo; > X86CPU *cpu =3D X86_CPU(dev); > @@ -1972,6 +1973,9 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, > return; > } > cpu->thread_id =3D topo.smt_id; > + > + cs =3D CPU(cpu); > + cs->cpu_index =3D idx; > } > =20 > static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, --=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 --yH1ZJFh+qWm+VodA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXkXngAAoJEGw4ysog2bOS8psP/ixTVdUXxgCF0vBmfho8hNVe bcpE51iNC9+ZTAinubga6M7JXPCYxjbBh8blImNGROtOzZV9iLtWAI56+lX3cI6u ZbpMLg7DfyuQPCUPiZeFuYsIgZpK7nKHID0+gZRrrbKOHoZa7QmBtily6uOPiybs HHI8583ei7qU85NCkes0a0gGHzZfCf+xPJRDZCPLv+zIg3ueR+jBaxAxcmgdjbZi u4Rb99iOVAFF3hWQwzFjx6cwn8wxUvWhJlx3tcA7To1xg+19N1bIGT68M4vhhJlJ uVEPxTVa06Eo0DXbeSZKD0ewJ0I8Kch5Oegi7uxTj7WzGoCcR7tI0Gwd4XcRM1i2 DHutLvYBJnOA5sakODcPexMxRTi7kAlGflMT0J061QLp+tbhejlqKJexkBmhhX6l 9aMxmjUOQU8mDhdz3N9/VYUbwXbXqD0fI9vUGD2JGtv14EKxhYOIk4KM6mx2sLk2 kHw5tMKNjn8j2GFq7O5T+KuIKAX0zCcIlXnCiBSzmecEdiTuVgsuwmqgGjKFBhS3 nLMa/82pNo7smI5ToSQ81V9ReqSgAsQW7np8c3Y6OdQfcGmdzd5MhjnOub2Gpoal 5TPzJz2nvZztz4w46V2h2fR2QZfDtVcQVs4Q61/tzlFAWtSWptWpCP2ybwAHPIkx siJNs54sqx4b/L/V4mnn =DVpV -----END PGP SIGNATURE----- --yH1ZJFh+qWm+VodA--