qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: imammedo@redhat.com, mst@redhat.com,
	Bharata B Rao <bharata@linux.vnet.ibm.com>,
	david@gibson.dropbear.id.au
Subject: [Qemu-devel] [PATCH v2 1/2] spapr: Accommadate alignment gaps in hotplug memory region
Date: Mon, 26 Oct 2015 13:30:37 +0530	[thread overview]
Message-ID: <1445846438-7324-2-git-send-email-bharata@linux.vnet.ibm.com> (raw)
In-Reply-To: <1445846438-7324-1-git-send-email-bharata@linux.vnet.ibm.com>

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 <bharata@linux.vnet.ibm.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
 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;
 
-- 
2.1.0

  reply	other threads:[~2015-10-26  8:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26  8:00 [Qemu-devel] [PATCH v2 0/2] Enforce gaps between DIMMs Bharata B Rao
2015-10-26  8:00 ` Bharata B Rao [this message]
2015-10-26  8:00 ` [Qemu-devel] [PATCH v2 2/2] spapr: Force gaps between DIMM's GPA Bharata B Rao
2015-10-26 10:21 ` [Qemu-devel] [PATCH v2 0/2] Enforce gaps between DIMMs Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445846438-7324-2-git-send-email-bharata@linux.vnet.ibm.com \
    --to=bharata@linux.vnet.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).