From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZldC2-0000Ac-V3 for qemu-devel@nongnu.org; Mon, 12 Oct 2015 09:31:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZldBx-0006Gm-2F for qemu-devel@nongnu.org; Mon, 12 Oct 2015 09:31:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZldBw-0006Ga-S5 for qemu-devel@nongnu.org; Mon, 12 Oct 2015 09:31:05 -0400 Date: Mon, 12 Oct 2015 15:30:58 +0200 From: Igor Mammedov Message-ID: <20151012153058.211c69ae@igors-macbook-pro.local> In-Reply-To: <1444373400-18423-2-git-send-email-bharata@linux.vnet.ibm.com> References: <1444373400-18423-1-git-send-email-bharata@linux.vnet.ibm.com> <1444373400-18423-2-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v1 1/2] spapr: Accommadate alignment gaps in hotplug memory region List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: mst@redhat.com, qemu-devel@nongnu.org, david@gibson.dropbear.id.au On Fri, 9 Oct 2015 12:19:59 +0530 Bharata B Rao wrote: > Accommodate enough space in hotplug memory region so that it will > be possible to align memory in each slot to 256M. When PowerPC memory > hotplug enables inter-dimm gaps, then we could end up having > unused/unassigned 256M memory chuck between DIMMs in the hotplug s/chuck/chunks/ > memory region. Hence create DRC objects spanning the entire > alignment-adjusted hotplug memory region instead of just the acutal > hotpluggable size (machine->maxram_size - machine->ram_size). > > In addition, pass 256M alignment to pc_dimm_memory_plug() so that > the DIMM address gets aligned to 256M. > > Signed-off-by: Bharata B Rao beside fixup above, Reviewed-by: Igor Mammedov > --- > hw/ppc/spapr.c | 21 +++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index fc5e7d6..4a901f0 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -721,7 +721,7 @@ static int > spapr_populate_drconf_memory(sPAPRMachineState *spapr, void *fdt) int > ret, i, offset; uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE; > uint32_t prop_lmb_size[] = {0, cpu_to_be32(lmb_size)}; > - uint32_t nr_lmbs = (machine->maxram_size - > machine->ram_size)/lmb_size; > + uint32_t nr_lmbs = > memory_region_size(&spapr->hotplug_memory.mr)/lmb_size; uint32_t > *int_buf, *cur_index, buf_len; int nr_nodes = nb_numa_nodes ? > nb_numa_nodes : 1; > @@ -1614,9 +1614,8 @@ static void spapr_drc_reset(void *opaque) > > static void spapr_create_lmb_dr_connectors(sPAPRMachineState *spapr) > { > - MachineState *machine = MACHINE(spapr); > uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE; > - uint32_t nr_lmbs = (machine->maxram_size - > machine->ram_size)/lmb_size; > + uint32_t nr_lmbs = > memory_region_size(&spapr->hotplug_memory.mr)/lmb_size; int i; > > for (i = 0; i < nr_lmbs; i++) { > @@ -1792,6 +1791,20 @@ static void ppc_spapr_init(MachineState > *machine) > spapr->hotplug_memory.base = ROUND_UP(machine->ram_size, > SPAPR_HOTPLUG_MEM_ALIGN); > + > + /* > + * Ensure that there is enough space in the hotplug memory > + * region to support a maximum alignment of 256M per slot. > + * Though PowerPC has 16M and 16G huge pages, PowerKVM > supports > + * only 16M and hence 256M alignment works until we start > + * supporting 1G hugepage. > + * > + * Instead of max hugepage size alignment, we go with 256M > + * alignment because we require the DIMM address to be 256M > + * aligned as we maintain DRC objects for every 256M memory > + * chunk in the hotplug memory region. > + */ > + hotplug_mem_size += SPAPR_MEMORY_BLOCK_SIZE * > machine->ram_slots; memory_region_init(&spapr->hotplug_memory.mr, > OBJECT(spapr), "hotplug-memory", hotplug_mem_size); > memory_region_add_subregion(sysmem, > spapr->hotplug_memory.base, @@ -2114,7 +2127,7 @@ static void > spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, > PCDIMMDevice *dimm = PC_DIMM(dev); PCDIMMDeviceClass *ddc = > PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr = > ddc->get_memory_region(dimm); > - uint64_t align = memory_region_get_alignment(mr); > + uint64_t align = SPAPR_MEMORY_BLOCK_SIZE; > uint64_t size = memory_region_size(mr); > uint64_t addr; >