From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqAg8-0005q1-Lc for qemu-devel@nongnu.org; Wed, 06 May 2015 21:32:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqAg3-000601-Q6 for qemu-devel@nongnu.org; Wed, 06 May 2015 21:32:44 -0400 Date: Thu, 7 May 2015 11:12:36 +1000 From: David Gibson Message-ID: <20150507011236.GI1407@voom.redhat.com> References: <1429858066-12088-1-git-send-email-bharata@linux.vnet.ibm.com> <1429858066-12088-22-git-send-email-bharata@linux.vnet.ibm.com> <20150505104850.361388c8@nial.brq.redhat.com> <20150506082305.GS18380@in.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="u/L2/WlOHZg+YGU4" Content-Disposition: inline In-Reply-To: <20150506082305.GS18380@in.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v3 21/24] spapr: Initialize hotplug memory address space 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, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, Igor Mammedov , afaerber@suse.de --u/L2/WlOHZg+YGU4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 06, 2015 at 01:53:05PM +0530, Bharata B Rao wrote: > On Tue, May 05, 2015 at 10:48:50AM +0200, Igor Mammedov wrote: > > On Fri, 24 Apr 2015 12:17:43 +0530 > > Bharata B Rao wrote: > >=20 > > > Initialize a hotplug memory region under which all the hotplugged > > > memory is accommodated. Also enable memory hotplug by setting > > > CONFIG_MEM_HOTPLUG. > > >=20 > > > Modelled on i386 memory hotplug. > > >=20 > > > Signed-off-by: Bharata B Rao > > > --- > > > default-configs/ppc64-softmmu.mak | 1 + > > > hw/ppc/spapr.c | 38 +++++++++++++++++++++++++++++= +++++++++ > > > include/hw/ppc/spapr.h | 12 ++++++++++++ > > > 3 files changed, 51 insertions(+) > > >=20 > > > diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc6= 4-softmmu.mak > > > index 22ef132..16b3011 100644 > > > --- a/default-configs/ppc64-softmmu.mak > > > +++ b/default-configs/ppc64-softmmu.mak > > > @@ -51,3 +51,4 @@ CONFIG_XICS_KVM=3D$(and $(CONFIG_PSERIES),$(CONFIG_= KVM)) > > > # For PReP > > > CONFIG_MC146818RTC=3Dy > > > CONFIG_ISA_TESTDEV=3Dy > > > +CONFIG_MEM_HOTPLUG=3Dy > > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > > > index 910a50f..9dc4c36 100644 > > > --- a/hw/ppc/spapr.c > > > +++ b/hw/ppc/spapr.c > > > @@ -125,6 +125,9 @@ struct sPAPRMachineState { > > > =20 > > > /*< public >*/ > > > char *kvm_type; > > > + ram_addr_t hotplug_memory_base; > > > + MemoryRegion hotplug_memory; > > > + bool enforce_aligned_dimm; > > > }; > > > =20 > > > sPAPREnvironment *spapr; > > > @@ -1514,6 +1517,7 @@ static void ppc_spapr_init(MachineState *machin= e) > > > QemuOpts *opts =3D qemu_opts_find(qemu_find_opts("smp-opts"), NU= LL); > > > int sockets =3D opts ? qemu_opt_get_number(opts, "sockets", 0) := 0; > > > int cores =3D (smp_cpus/smp_threads) ? smp_cpus/smp_threads : 1; > > > + sPAPRMachineState *ms =3D SPAPR_MACHINE(machine); > > > =20 > > > sockets =3D sockets ? sockets : cores; > > > msi_supported =3D true; > > > @@ -1613,6 +1617,36 @@ static void ppc_spapr_init(MachineState *machi= ne) > > > memory_region_add_subregion(sysmem, 0, rma_region); > > > } > > > =20 > > > + /* initialize hotplug memory address space */ > > > + if (machine->ram_size < machine->maxram_size) { > > > + ram_addr_t hotplug_mem_size =3D > > > + machine->maxram_size - machine->ram_size; > > > + > > > + if (machine->ram_slots > SPAPR_MAX_RAM_SLOTS) { > > > + error_report("unsupported amount of memory slots: %"PRIu= 64, > > > + machine->ram_slots); > > > + exit(EXIT_FAILURE); > > > + } > > > + > > > + ms->hotplug_memory_base =3D ROUND_UP(machine->ram_size, > > > + SPAPR_HOTPLUG_MEM_ALIGN); > > > + > > > + if (ms->enforce_aligned_dimm) { > > > + hotplug_mem_size +=3D SPAPR_HOTPLUG_MEM_ALIGN * machine-= >ram_slots; > > > + } > > > + > > > + if ((ms->hotplug_memory_base + hotplug_mem_size) < hotplug_m= em_size) { > > > + error_report("unsupported amount of maximum memory: " RA= M_ADDR_FMT, > > > + machine->maxram_size); > > > + exit(EXIT_FAILURE); > > > + } > > > + > > > + memory_region_init(&ms->hotplug_memory, OBJECT(ms), > > > + "hotplug-memory", hotplug_mem_size); > > > + memory_region_add_subregion(sysmem, ms->hotplug_memory_base, > > > + &ms->hotplug_memory); > > > + } > > > + > > > filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin= "); > > > spapr->rtas_size =3D get_image_size(filename); > > > spapr->rtas_blob =3D g_malloc(spapr->rtas_size); > > > @@ -1844,11 +1878,15 @@ static void spapr_set_kvm_type(Object *obj, c= onst char *value, Error **errp) > > > =20 > > > static void spapr_machine_initfn(Object *obj) > > > { > > > + sPAPRMachineState *ms =3D SPAPR_MACHINE(obj); > > > + > > > object_property_add_str(obj, "kvm-type", > > > spapr_get_kvm_type, spapr_set_kvm_type, = NULL); > > > object_property_set_description(obj, "kvm-type", > > > "Specifies the KVM virtualizatio= n mode (HV, PR)", > > > NULL); > > > + > > > + ms->enforce_aligned_dimm =3D true; > > > } > > > =20 > > > static void ppc_cpu_do_nmi_on_cpu(void *arg) > > > diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h > > > index ecac6e3..53560e9 100644 > > > --- a/include/hw/ppc/spapr.h > > > +++ b/include/hw/ppc/spapr.h > > > @@ -542,6 +542,18 @@ struct sPAPREventLogEntry { > > > =20 > > > #define SPAPR_MEMORY_BLOCK_SIZE (1 << 28) /* 256MB */ > > > =20 > > > +/* > > > + * This defines the maximum number of DIMM slots we can have for sPA= PR > > > + * guest. This is not defined by sPAPR but we are defining it to 409= 6 slots > > > + * here. With the worst case addition of SPAPR_MEMORY_BLOCK_SIZE > > > + * (256MB) memory per slot, we should be able to support 1TB of guest > > > + * hotpluggable memory. > > > + */ > > > +#define SPAPR_MAX_RAM_SLOTS (1ULL << 12) > > why not write 4096 instead of (1ULL << 12), much easier to read. >=20 > Sure. >=20 > >=20 > > BTW: > > KVM supports upto 509 memory slots including slots consumed by > > initial memory. >=20 > I see that PowerPC defaults to 32 slots. So having 4096 slots is really > pointless then ? So to ensure more hot-pluggable memory space is available > should I be increasing the size of the minimum pluggable memory in a > dimm slot (as defined by SPAPR_MEMORY_BLOCK_SIZE above) ? That seems a bit nasty, since then the granularity of adding blocks will be enormous for small guests as well. Is it possible to increase the maximum size of a single DIMM, but not the minimum? That way you can still do small inserts for small guests. To get the full RAM for big guests youd have to insert big chunks though, due to the limited number of slots. --=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 --u/L2/WlOHZg+YGU4 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVSrwEAAoJEGw4ysog2bOSAP0P/RahDnt36J5PfXt1MD3llw8Z trGr02+wdYWMzxHQf9SjfJBdq71gbPwwXsE69wfBz482e7tq+bPmyP5uz8oIdww6 i1bf+qp65JmHOc+azbWpMElDig2g3sD4F723thckOrmlbxqM18BeoHnwj8yfmitd wvSplTSeiSHZD0dCTflrhjI+cT7EYDOtj0tEyShdyAKTBQiHk3t/wbNlyDVsvkai uoKBA2NfbqKP9A5StGMyzTZtscqXEY5EuZWjcBA3hgrxve+Evc5At3bp9EjTLkot SNPOaVYZMMUpxmagiFnpjR6NeEPwShy6kspmkgiyYEA1X9zL8eQ1CDnlGyB2l2lz DgtHFuq6ikhbWHV8VDBfD9LjwEpG3p4p7ngk3xy7kR11YZA/tu+yCTvzq6+TILdP x5juNlefFJtWuIvm36shWa0+IHWnkAF8qvON9/wbnV4W72dARpK5uR1ELTwPvb19 0QcOfeHOFJNVA+69G5zYuW0JHdm4qO4nqFL2HoDbmbHVY/VuD1if5alSq5KNH27v JEQnUgdCzaHtWz1Izsgf0CYXT//TZemdialGeYqALiortoH2f0CYCE4eYONDEY0v tDJGL8yr8Jm/UTahbmYlOJIMJsIj0t2GLtwA/DXoNjbCCAi8Xtjx89MAvhXhqwqx oF9+F6tNVQbQhiKnvYbA =/kNq -----END PGP SIGNATURE----- --u/L2/WlOHZg+YGU4--