From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViGJb-0005f8-BN for qemu-devel@nongnu.org; Sun, 17 Nov 2013 23:20:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ViGJS-0001RL-C4 for qemu-devel@nongnu.org; Sun, 17 Nov 2013 23:19:59 -0500 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:45544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViGJR-0001R2-Jq for qemu-devel@nongnu.org; Sun, 17 Nov 2013 23:19:50 -0500 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Nov 2013 14:19:38 +1000 From: Alexey Kardashevskiy Date: Mon, 18 Nov 2013 15:19:32 +1100 Message-Id: <1384748372-24131-3-git-send-email-aik@ozlabs.ru> In-Reply-To: <1384748372-24131-1-git-send-email-aik@ozlabs.ru> References: <1384748372-24131-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH v5 2/2] spapr: limit numa memory regions by ram size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru, qemu-ppc@nongnu.org, Paul Mackerras , Alexander Graf From: Paul Mackerras This makes sure that all NUMA memory blocks beside within RAM or have zero length. Signed-off-by: Alexey Kardashevskiy --- This is a bugfix for: -m 500 -smp 8,sockets=2,cores=2,threads=2 -numa node,nodeid=0,cpus=0-3,mem=500 -numa node,nodeid=1,cpus=4-7,mem=500 --- hw/ppc/spapr.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 036246c..a7f6af8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -526,12 +526,16 @@ static int spapr_populate_memory(sPAPREnvironment *spapr, void *fdt) cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(0x0)}; char mem_name[32]; - hwaddr node0_size, mem_start; + hwaddr node0_size, mem_start, node_size; uint64_t mem_reg_property[2]; int i, off; /* memory node(s) */ - node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size; + if (nb_numa_nodes > 1 && node_mem[0] < ram_size) { + node0_size = node_mem[0]; + } else { + node0_size = ram_size; + } /* RMA */ mem_reg_property[0] = 0; @@ -563,7 +567,15 @@ static int spapr_populate_memory(sPAPREnvironment *spapr, void *fdt) mem_start = node0_size; for (i = 1; i < nb_numa_nodes; i++) { mem_reg_property[0] = cpu_to_be64(mem_start); - mem_reg_property[1] = cpu_to_be64(node_mem[i]); + if (mem_start >= ram_size) { + node_size = 0; + } else { + node_size = node_mem[i]; + if (node_size > ram_size - mem_start) { + node_size = ram_size - mem_start; + } + } + mem_reg_property[1] = cpu_to_be64(node_size); associativity[3] = associativity[4] = cpu_to_be32(i); sprintf(mem_name, "memory@" TARGET_FMT_lx, mem_start); off = fdt_add_subnode(fdt, 0, mem_name); @@ -573,7 +585,7 @@ static int spapr_populate_memory(sPAPREnvironment *spapr, void *fdt) sizeof(mem_reg_property)))); _FDT((fdt_setprop(fdt, off, "ibm,associativity", associativity, sizeof(associativity)))); - mem_start += node_mem[i]; + mem_start += node_size; } return 0; -- 1.8.4.rc4