Received: from eggs.gnu.org ([2001:4830:134:3::10]:42517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjQPN-0006Pv-Eo for qemu-devel@nongnu.org; Thu, 21 Nov 2013 04:18:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjQP8-0005O5-F9 for qemu-devel@nongnu.org; Thu, 21 Nov 2013 04:18:45 -0500 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:46310) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjQP8-0005Ns-5k for qemu-devel@nongnu.org; Thu, 21 Nov 2013 04:18:30 -0500 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 21 Nov 2013 09:18:28 -0000 Date: Thu, 21 Nov 2013 10:17:07 +0100 From: Thomas Huth Message-ID: <20131121101707.1639550d@oc7435384737.ibm.com> In-Reply-To: <1384748372-24131-3-git-send-email-aik@ozlabs.ru> References: <1384748372-24131-1-git-send-email-aik@ozlabs.ru> <1384748372-24131-3-git-send-email-aik@ozlabs.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [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: Alexey Kardashevskiy Cc: Paul Mackerras , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Alexander Graf On Mon, 18 Nov 2013 15:19:32 +1100 Alexey Kardashevskiy wrote: > From: Paul Mackerras > > This makes sure that all NUMA memory blocks beside within RAM or s/beside/reside/ ? > 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; Apart from the typo in the commit message, the patch looks good to me. Reviewed-by: Thomas Huth