From patchwork Mon Oct 26 08:00:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 535724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 117D6140D8E for ; Mon, 26 Oct 2015 19:01:32 +1100 (AEDT) Received: from localhost ([::1]:51071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqcif-0006UF-N4 for incoming@patchwork.ozlabs.org; Mon, 26 Oct 2015 04:01:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqciH-0005tK-QU for qemu-devel@nongnu.org; Mon, 26 Oct 2015 04:01:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqciD-000207-Mc for qemu-devel@nongnu.org; Mon, 26 Oct 2015 04:01:05 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:44573) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqciD-0001y3-0Z for qemu-devel@nongnu.org; Mon, 26 Oct 2015 04:01:01 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Oct 2015 13:30:56 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 26 Oct 2015 13:30:54 +0530 X-Helo: d28dlp01.in.ibm.com X-MailFrom: bharata@linux.vnet.ibm.com X-RcptTo: qemu-devel@nongnu.org Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 630ECE004C for ; Mon, 26 Oct 2015 13:31:00 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay03.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9Q80ojA29950136 for ; Mon, 26 Oct 2015 13:30:51 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9Q80niB010676 for ; Mon, 26 Oct 2015 13:30:49 +0530 Received: from bharata.in.ibm.com ([9.124.35.232]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t9Q80lDt010491; Mon, 26 Oct 2015 13:30:47 +0530 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Mon, 26 Oct 2015 13:30:37 +0530 Message-Id: <1445846438-7324-2-git-send-email-bharata@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1445846438-7324-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1445846438-7324-1-git-send-email-bharata@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15102608-0021-0000-0000-0000081AAAC1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 122.248.162.6 Cc: imammedo@redhat.com, mst@redhat.com, Bharata B Rao , david@gibson.dropbear.id.au Subject: [Qemu-devel] [PATCH v2 1/2] spapr: Accommadate alignment gaps in hotplug memory region X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 chucks between DIMMs in the hotplug 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 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 e1202ce..f29bb10 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -753,7 +753,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; @@ -1647,9 +1647,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++) { @@ -1825,6 +1824,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 16G 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 a DRC object 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, @@ -2147,7 +2160,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;