From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ9Qa-0007aK-5i for qemu-devel@nongnu.org; Thu, 25 Feb 2016 22:50:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZ9QZ-0007nh-13 for qemu-devel@nongnu.org; Thu, 25 Feb 2016 22:50:52 -0500 Date: Fri, 26 Feb 2016 14:45:35 +1100 From: David Gibson Message-ID: <20160226034535.GF20657@voom.fritz.box> References: <1456417362-20652-1-git-send-email-bharata@linux.vnet.ibm.com> <1456417362-20652-4-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="27ZtN5FSuKKSZcBU" Content-Disposition: inline In-Reply-To: <1456417362-20652-4-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v0 3/6] spapr: Represent boot CPUs as spapr-cpu-core devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: mjrosato@linux.vnet.ibm.com, agraf@suse.de, thuth@redhat.com, pkrempa@redhat.com, ehabkost@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, armbru@redhat.com, borntraeger@de.ibm.com, qemu-ppc@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com, afaerber@suse.de, mdroth@linux.vnet.ibm.com --27ZtN5FSuKKSZcBU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 25, 2016 at 09:52:39PM +0530, Bharata B Rao wrote: > Initialize boot CPUs as spapr-cpu-core devices and create links from > machine object to these core devices. These links can be considered > as CPU slots in which core devices will get hot-plugged. spapr-cpu-core > device's slot property indicates the slot where it is plugged. Information > about all the CPU slots can be obtained by walking these links. >=20 > Signed-off-by: Bharata B Rao > --- > hw/ppc/spapr.c | 65 +++++++++++++++++++++++++++++++++++++++++++-= ------ > include/hw/ppc/spapr.h | 3 +++ > 2 files changed, 60 insertions(+), 8 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index e214a34..1f0d232 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -64,6 +64,7 @@ > =20 > #include "hw/compat.h" > #include "qemu-common.h" > +#include "hw/ppc/spapr_cpu_core.h" > =20 > #include > =20 > @@ -1720,6 +1721,21 @@ static void spapr_validate_node_memory(MachineStat= e *machine, Error **errp) > } > } > =20 > +/* > + * Check to see if core is being hot-plugged into an already populated s= lot. > + */ > +static void spapr_cpu_core_allow_set_link(Object *obj, const char *name, > + Object *val, Error **errp) > +{ > + Object *core =3D object_property_get_link(qdev_get_machine(), name, = NULL); > + > + if (core) { > + char *path =3D object_get_canonical_path(core); > + error_setg(errp, "Slot %s already populated with %s", name, path= ); > + g_free(path); > + } > +} > + > /* pSeries LPAR / sPAPR hardware init */ > static void ppc_spapr_init(MachineState *machine) > { > @@ -1728,7 +1744,6 @@ static void ppc_spapr_init(MachineState *machine) > const char *kernel_filename =3D machine->kernel_filename; > const char *kernel_cmdline =3D machine->kernel_cmdline; > const char *initrd_filename =3D machine->initrd_filename; > - PowerPCCPU *cpu; > PCIHostState *phb; > int i; > MemoryRegion *sysmem =3D get_system_memory(); > @@ -1742,6 +1757,8 @@ static void ppc_spapr_init(MachineState *machine) > long load_limit, fw_size; > bool kernel_le =3D false; > char *filename; > + int spapr_cores =3D smp_cpus / smp_threads; > + int spapr_max_cores =3D max_cpus / smp_threads; > =20 > msi_supported =3D true; > =20 > @@ -1800,13 +1817,38 @@ static void ppc_spapr_init(MachineState *machine) > if (machine->cpu_model =3D=3D NULL) { > machine->cpu_model =3D kvm_enabled() ? "host" : "POWER7"; > } > - for (i =3D 0; i < smp_cpus; i++) { > - cpu =3D cpu_ppc_init(machine->cpu_model); > - if (cpu =3D=3D NULL) { > - error_report("Unable to find PowerPC CPU definition"); > - exit(1); > + > + spapr->cores =3D g_malloc0(spapr_max_cores * sizeof(Object)); > + > + for (i =3D 0; i < spapr_max_cores; i++) { > + Object *spapr_cpu_core =3D object_new(TYPE_SPAPR_CPU_CORE); So.. if I understand correctly this will always construct maxcpus threads at startup. I's just that the ones beyond initial cpus won't be realized. Was that your intention? I thought the plan was to only construct the hotplugged cpus when they were hotplugged (in contrast to my earlier proposal). > + char name[32]; > + > + object_property_set_str(spapr_cpu_core, machine->cpu_model, "cpu= _model", > + &error_fatal); > + object_property_set_int(spapr_cpu_core, smp_threads, "nr_threads= ", > + &error_fatal); > + /* > + * Create links from machine objects to all possible cores. > + */ > + snprintf(name, sizeof(name), "%s[%d]", SPAPR_MACHINE_CPU_CORE_PR= OP, i); Why do SPAPR_MACHINE_CPU_CORE_PROP and SPAPR_CPU_CORE_SLOT_PROP get #defines, but the other properties get bare strings? I find the bare strings are usually easier to follow. > + object_property_add_link(OBJECT(spapr), name, TYPE_SPAPR_CPU_COR= E, > + (Object **)&spapr->cores[i], > + spapr_cpu_core_allow_set_link, 0, > + &error_fatal); > + > + /* > + * Set the link from machine object to core object for all > + * boot time CPUs specified with -smp and realize them. > + * For rest of the hotpluggable cores this is happens from > + * the core hotplug/realization path. > + */ > + if (i < spapr_cores) { > + object_property_set_str(spapr_cpu_core, name, > + SPAPR_CPU_CORE_SLOT_PROP, &error_fat= al); > + object_property_set_bool(spapr_cpu_core, true, "realized", > + &error_fatal); > } > - spapr_cpu_init(spapr, cpu, &error_fatal); > } > =20 > if (kvm_enabled()) { > @@ -2209,6 +2251,7 @@ static void spapr_machine_device_plug(HotplugHandle= r *hotplug_dev, > DeviceState *dev, Error **errp) > { > sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(qdev_get_machine(= )); > + sPAPRMachineState *ms =3D SPAPR_MACHINE(hotplug_dev); > =20 > if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { > int node; > @@ -2245,6 +2288,11 @@ static void spapr_machine_device_plug(HotplugHandl= er *hotplug_dev, > } > =20 > spapr_memory_plug(hotplug_dev, dev, node, errp); > + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { > + CPUState *cs =3D CPU(dev); > + PowerPCCPU *cpu =3D POWERPC_CPU(cs); > + > + spapr_cpu_init(ms, cpu, errp); I tend to thin the spapr_cpu_init() should be done from the core's create_threads() function, but I'm willing to be persuaded otherwise. > } > } > =20 > @@ -2259,7 +2307,8 @@ static void spapr_machine_device_unplug(HotplugHand= ler *hotplug_dev, > static HotplugHandler *spapr_get_hotpug_handler(MachineState *machine, > DeviceState *dev) > { > - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { > + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || > + object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { > return HOTPLUG_HANDLER(machine); > } > return NULL; > diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h > index 098d85d..20b3417 100644 > --- a/include/hw/ppc/spapr.h > +++ b/include/hw/ppc/spapr.h > @@ -79,8 +79,11 @@ struct sPAPRMachineState { > /*< public >*/ > char *kvm_type; > MemoryHotplugState hotplug_memory; > + Object *cores; > }; > =20 > +#define SPAPR_MACHINE_CPU_CORE_PROP "core" > + > #define H_SUCCESS 0 > #define H_BUSY 1 /* Hardware busy -- retry later */ > #define H_CLOSED 2 /* Resource closed */ --=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 --27ZtN5FSuKKSZcBU Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIbBAEBAgAGBQJWz8pfAAoJEGw4ysog2bOS3BMP9Ro6uCGh7ezDaUMCOrKThI4y tCPKtwp775fNXqlgdGKW/PoFry7oWWlQ10xDYhCtixPCqrj+BnwHgXJsHWMBF/1T MYCwPMRLIEk5sLpEhA7tqcJ/hEFMh3Ne5RP3L1WTfrvfroUivupbfStKgykvOfFP lem7v3DZbfoLzHMOVt9xT6S5ESKfJqeLAOEBKxpSaLiscK0TwWRugAAV7qqhnNXZ 5uyVCfxZVWCevfvYxE/H2sCgbyPTufVn4n6fVmrYUXwMFIpOF8oTY/AYIQH30+Ib 7Tmb5rS7+7EfBesi/2H5YHulpxU4r5s+jdFNES6pHDrGzVmG+4MyZOcRaasqr7T3 ug3ajY9EDxDOfnunDqzNsze5eEqYLbs9MjfHDN8FjalegITrcK8cVpZ7qwd7fyfj lwhs6pIHxa1PPBuqu0C3nkInnq7SABIva7IFfS4DF7Zdc1e/TphGIsXGaGNJ43ko lqHHZpa4uQtcnYeX90dpqhEvhhh8kWWDsFRI4TEwVzkYgMiiCsMsTNQ62wRsV8wi AtsliR4F34V1re5QYQCiWFDwcNk0Nn46nQK1vtJHmawf1uXg8AIugLDL/feOKs/F 2ffBryUePo0xSf2fWO0VFUecyPQgG916qsrOBqP7fSFwJu8i3I/XMfAlbt5dR4ym djFN5MX1nnMYz5/IVnU= =CwOR -----END PGP SIGNATURE----- --27ZtN5FSuKKSZcBU--