From patchwork Wed Sep 4 09:03:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanlong Gao X-Patchwork-Id: 272558 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6319E2C00BC for ; Wed, 4 Sep 2013 20:00:48 +1000 (EST) Received: from localhost ([::1]:51187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VH94d-0007ea-5w for incoming@patchwork.ozlabs.org; Wed, 04 Sep 2013 05:08:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VH91f-0003qe-JJ for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VH91Y-0007o7-96 for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:05:23 -0400 Received: from [222.73.24.84] (port=17538 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VH91X-0007nB-Ry for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:05:16 -0400 X-IronPort-AV: E=Sophos;i="4.89,1020,1367942400"; d="scan'208";a="8405805" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 04 Sep 2013 17:02:03 +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 r84955bW010423; Wed, 4 Sep 2013 17:05:09 +0800 Received: from G08FNSTD121251.fnst.cn.fujitsu.com ([10.167.226.75]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013090417025177-1215159 ; Wed, 4 Sep 2013 17:02:51 +0800 From: Wanlong Gao To: qemu-devel@nongnu.org Date: Wed, 4 Sep 2013 17:03:35 +0800 Message-Id: <1378285422-7361-7-git-send-email-gaowanlong@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.21.g992c386 In-Reply-To: <1378285422-7361-1-git-send-email-gaowanlong@cn.fujitsu.com> References: <1378285422-7361-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/09/04 17:02:51, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/09/04 17:03:02, Serialize complete at 2013/09/04 17:03:02 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: aliguori@us.ibm.com, ehabkost@redhat.com, lersek@redhat.com, peter.huangpeng@huawei.com, lcapitulino@redhat.com, drjones@redhat.com, bsd@redhat.com, hutao@cn.fujitsu.com, y-goto@jp.fujitsu.com, pbonzini@redhat.com, afaerber@suse.de, gaowanlong@cn.fujitsu.com Subject: [Qemu-devel] [PATCH V12 06/13] NUMA: add "-numa mem," options 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 Add "-numa mem," option like following as Paolo suggested: -numa mem,nodeid=0,size=1G This new option will make later coming memory hotplug better. We will use the new options to specify nodes memory info, and just remain "-numa node,mem=xx" as legacy. Reviewed-by: Laszlo Ersek Signed-off-by: Wanlong Gao --- include/sysemu/sysemu.h | 1 + numa.c | 36 ++++++++++++++++++++++++++++++++++++ qemu-options.hx | 6 ++++-- vl.c | 2 ++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 797490e..58c728c 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -130,6 +130,7 @@ extern QEMUClockType rtc_clock; #define MAX_NODES 64 #define MAX_CPUMASK_BITS 255 extern int nb_numa_nodes; +extern int nb_numa_mem_nodes; typedef struct node_info { uint64_t node_mem; DECLARE_BITMAP(node_cpu, MAX_CPUMASK_BITS); diff --git a/numa.c b/numa.c index c4fa665..c676c5e 100644 --- a/numa.c +++ b/numa.c @@ -74,6 +74,31 @@ static int numa_node_parse(NumaNodeOptions *opts) return 0; } +static int numa_mem_parse(NumaMemOptions *opts) +{ + uint16_t nodenr; + uint64_t mem_size; + + if (opts->has_nodeid) { + nodenr = opts->nodeid; + } else { + nodenr = nb_numa_mem_nodes; + } + + if (nodenr >= MAX_NODES) { + fprintf(stderr, "qemu: Max number of NUMA nodes reached: %" + PRIu16 "\n", nodenr); + return -1; + } + + if (opts->has_size) { + mem_size = opts->size; + numa_info[nodenr].node_mem = mem_size; + } + + return 0; +} + int numa_init_func(QemuOpts *opts, void *opaque) { NumaOptions *object = NULL; @@ -101,6 +126,13 @@ int numa_init_func(QemuOpts *opts, void *opaque) } nb_numa_nodes++; break; + case NUMA_OPTIONS_KIND_MEM: + ret = numa_mem_parse(object->mem); + if (ret) { + goto error; + } + nb_numa_mem_nodes++; + break; default: fprintf(stderr, "qemu: Invalid NUMA options type.\n"); ret = -1; @@ -119,6 +151,10 @@ error: void set_numa_nodes(void) { + if (nb_numa_mem_nodes > nb_numa_nodes) { + nb_numa_nodes = nb_numa_mem_nodes; + } + if (nb_numa_nodes > 0) { int i; diff --git a/qemu-options.hx b/qemu-options.hx index d15338e..e9123b8 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -95,11 +95,13 @@ specifies the maximum number of hotpluggable CPUs. ETEXI DEF("numa", HAS_ARG, QEMU_OPTION_numa, - "-numa node[,mem=size][,cpus=cpu[-cpu]][,nodeid=node]\n", QEMU_ARCH_ALL) + "-numa node[,nodeid=node][,cpus=cpu[-cpu]]\n" + "-numa mem[,nodeid=node][,size=size]\n" + , QEMU_ARCH_ALL) STEXI @item -numa @var{opts} @findex -numa -Simulate a multi node NUMA system. If mem and cpus are omitted, resources +Simulate a multi node NUMA system. If @var{size} and @var{cpus} are omitted, resources are split equally. ETEXI diff --git a/vl.c b/vl.c index bbded8f..fd2afc7 100644 --- a/vl.c +++ b/vl.c @@ -250,6 +250,7 @@ static QTAILQ_HEAD(, FWBootEntry) fw_boot_order = QTAILQ_HEAD_INITIALIZER(fw_boot_order); int nb_numa_nodes; +int nb_numa_mem_nodes; NodeInfo numa_info[MAX_NODES]; uint8_t qemu_uuid[16]; @@ -2890,6 +2891,7 @@ int main(int argc, char **argv, char **envp) } nb_numa_nodes = 0; + nb_numa_mem_nodes = 0; nb_nics = 0; bdrv_init_with_whitelist();