From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNV8r-0005bi-BX for qemu-devel@nongnu.org; Wed, 13 Jul 2016 21:08:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNV8o-0003hF-Sa for qemu-devel@nongnu.org; Wed, 13 Jul 2016 21:08:40 -0400 Date: Thu, 14 Jul 2016 10:51:27 +1000 From: David Gibson Message-ID: <20160714005127.GH14615@voom.fritz.box> References: <1468392620-25599-1-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ewQ5hdP4CtoTt3oD" Content-Disposition: inline In-Reply-To: <1468392620-25599-1-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH 1/1] spapr: Ensure CPU cores are added contiguously and removed in LIFO order List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, imammedo@redhat.com, groug@kaod.org --ewQ5hdP4CtoTt3oD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 13, 2016 at 12:20:20PM +0530, Bharata B Rao wrote: > If CPU core addition or removal is allowed in random order leading to > holes in the core id range (and hence in the cpu_index range), migration > can fail as migration with holes in cpu_index range isn't yet handled > correctly. >=20 > Prevent this situation by enforcing the addition in contiguous order > and removal in LIFO order so that we never end up with holes in > cpu_index range. >=20 > Signed-off-by: Bharata B Rao > --- > While there is work in progress to support migration when there are holes > in cpu_index range resulting from out-of-order plug or unplug, this patch > is intended as a last resort if no easy, risk-free and elegant solution > emerges before 2.7 dev cycle ends. Applied to ppc-for-2.7. We can revert it once the problems with cpu_index are sorted out. >=20 > hw/ppc/spapr_cpu_core.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > index bc52b3c..4bfc96b 100644 > --- a/hw/ppc/spapr_cpu_core.c > +++ b/hw/ppc/spapr_cpu_core.c > @@ -126,12 +126,23 @@ static void spapr_core_release(DeviceState *dev, vo= id *opaque) > void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, > Error **errp) > { > + sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); > CPUCore *cc =3D CPU_CORE(dev); > sPAPRDRConnector *drc =3D > spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, cc->core_i= d); > sPAPRDRConnectorClass *drck; > Error *local_err =3D NULL; > + int smt =3D kvmppc_smt_threads(); > + int index =3D cc->core_id / smt; > + int spapr_max_cores =3D max_cpus / smp_threads; > + int i; > =20 > + for (i =3D spapr_max_cores - 1; i > index; i--) { > + if (spapr->cores[i]) { > + error_setg(errp, "core-id %d should be removed first", i * s= mt); > + return; > + } > + } > g_assert(drc); > =20 > drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); > @@ -214,7 +225,7 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev,= DeviceState *dev, > sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(OBJECT(hotplug_de= v)); > sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); > int spapr_max_cores =3D max_cpus / smp_threads; > - int index; > + int index, i; > int smt =3D kvmppc_smt_threads(); > Error *local_err =3D NULL; > CPUCore *cc =3D CPU_CORE(dev); > @@ -252,6 +263,14 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev= , DeviceState *dev, > goto out; > } > =20 > + for (i =3D 0; i < index; i++) { > + if (!spapr->cores[i]) { > + error_setg(&local_err, "core-id %d should be added first", > + i * smt); > + goto out; > + } > + } > + > out: > g_free(base_core_type); > error_propagate(errp, local_err); --=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 --ewQ5hdP4CtoTt3oD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXhuIPAAoJEGw4ysog2bOSob0P/iDakiz6ofpbafpn2zlPrgRB tjQZLaIJLjwjFFhdArCBBd4GSGabPa4xyrjIqatSo1ZDy8CFYlF2ulTs9QXBY6DR fDNT5aUtL41GLgmiLak7ACsmYD/DNDsi+wMDo6sMb1z4fNnhYZTkNJt6EgI4w0iu 7bh8GJLx3zntgQE+5fwzVFnXdTCyqfVYQdBQ0/k+aijqO0h9ftbwiKo8sWOToVYX nyTEAbU57YRrGoHGMNW5VzZE4YSg9rJfqoGKx0ggYuZud02MNDvH/2offU9g1q2L vc/FbbioblOE779FHevGTaYj7nz1t1j27ubSWf1Oh54KLZ92MpcVUrYMV40/A2KV jbnZwqJHAUudyBduprDxFHlaiyZkF/7CMYiTcr5p6GHEOv54IKGeCUfe9ZxKQ3fG YGNQ6X0mvbW3yFwdr0D7AirHGebQP2Etzz+SyXAO6OcMMO/PV5wtQsBo/5f1EHIB laSEAx8Khtvqj7rXeNSBdvqCifk40l+24yekqO0JpBSwM8+grsWq2PlEC5hLBaT5 AiYAYhsmQpQRA5jEoip1e4dX4xKHbW8Uyvw5uU0eBeM9uYLcJT+ED1WJMJFecOkB BF/uNmT0PC9iSjCjNp+lgZzRYZkNqgY229xTo874HhZdyTOcIZZNnG1kdOiSG4pX 9foHgweCWROmcmmWTO/M =Tat3 -----END PGP SIGNATURE----- --ewQ5hdP4CtoTt3oD--