From patchwork Thu May 23 08:47:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanlong Gao X-Patchwork-Id: 245848 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C11172C02AF for ; Thu, 23 May 2013 18:49:59 +1000 (EST) Received: from localhost ([::1]:53962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfRDh-0008Ie-Uw for incoming@patchwork.ozlabs.org; Thu, 23 May 2013 04:49:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfRDC-0008DX-3K for qemu-devel@nongnu.org; Thu, 23 May 2013 04:49:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfRDA-0002PJ-Op for qemu-devel@nongnu.org; Thu, 23 May 2013 04:49:25 -0400 Received: from [222.73.24.84] (port=30059 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfRDA-0002Oo-C3 for qemu-devel@nongnu.org; Thu, 23 May 2013 04:49:24 -0400 X-IronPort-AV: E=Sophos;i="4.87,726,1363104000"; d="scan'208";a="7343726" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 23 May 2013 16:46:22 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r4N8nAWu026969 for ; Thu, 23 May 2013 16:49:10 +0800 Received: from G08FNSTD121251.fnst.cn.fujitsu.com ([10.167.233.84]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013052316475013-1468513 ; Thu, 23 May 2013 16:47:50 +0800 From: Wanlong Gao To: qemu-devel@nongnu.org Date: Thu, 23 May 2013 16:47:19 +0800 Message-Id: <1369298842-6295-2-git-send-email-gaowanlong@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.rc2.10.g0c2b1cf In-Reply-To: <1369298842-6295-1-git-send-email-gaowanlong@cn.fujitsu.com> References: <1369298842-6295-1-git-send-email-gaowanlong@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/23 16:47:50, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/23 16:47:50, Serialize complete at 2013/05/23 16:47:50 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: Wanlong Gao Subject: [Qemu-devel] [PATCH 2/5] memory: check if the total numa memory size is equal to ram_size 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 If the total number of the assigned numa nodes memory is not equal to the assigned total ram size, the guest will recognize all memory to one node. eg: -m 1024 -smp sockets=2,cores=1,threads=1 -numa node,cpus=0,nodeid=0,mem=512 \ -numa node,nodeid=1,cpus=1,mem=256 (qemu) info numa 2 nodes node 0 cpus: 0 node 0 size: 512 MB node 1 cpus: 1 node 1 size: 256 MB $ numactl -H avaliable: 1 nodes (0) node 0 cpus: 0 1 node 0 size: 1023 MB node 0 free: 821 MB node distances: node 0 0: 10 Signed-off-by: Wanlong Gao --- vl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vl.c b/vl.c index 59dc0b4..ce24bcd 100644 --- a/vl.c +++ b/vl.c @@ -4238,6 +4238,15 @@ int main(int argc, char **argv, char **envp) node_mem[i] = ram_size - usedmem; } + uint64_t numa_total = 0; + for (i = 0; i < nb_numa_nodes; i++) + numa_total += node_mem[i]; + if (numa_total != ram_size) { + fprintf(stderr, "qemu: numa nodes total memory size " + "should equal ram size\n"); + exit(1); + } + for (i = 0; i < nb_numa_nodes; i++) { if (!bitmap_empty(node_cpumask[i], MAX_CPUMASK_BITS)) { break;