qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: drjones@redhat.com, ehabkost@redhat.com, lersek@redhat.com,
	hutao@cn.fujitsu.com, mtosatti@redhat.com,
	peter.huangpeng@huawei.com, lcapitulino@redhat.com,
	bsd@redhat.com, anthony@codemonkey.ws, y-goto@jp.fujitsu.com,
	pbonzini@redhat.com, afaerber@suse.de, gaowanlong@cn.fujitsu.com
Subject: [Qemu-devel] [PATCH V16 06/11] NUMA: add "-numa mem," options
Date: Fri, 22 Nov 2013 10:08:33 +0800	[thread overview]
Message-ID: <1385086118-11699-8-git-send-email-gaowanlong@cn.fujitsu.com> (raw)
In-Reply-To: <1385086118-11699-1-git-send-email-gaowanlong@cn.fujitsu.com>

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 <lersek@redhat.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 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 20b05a3..291aa6a 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -135,6 +135,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 8b94264..e6afb6f 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 e67f34a..064b821 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];
@@ -2817,6 +2818,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();
-- 
1.8.5.rc3

  parent reply	other threads:[~2013-11-22  2:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-22  2:08 [Qemu-devel] [PATCH V16 00/11] Add support for binding guest numa nodes to host numa nodes Wanlong Gao
2013-11-22  2:08 ` [Qemu-devel] [PATCH] fixup Wanlong Gao
2013-11-22  2:10   ` Wanlong Gao
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 01/11] NUMA: move numa related code to new file numa.c Wanlong Gao
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 02/11] NUMA: check if the total numa memory size is equal to ram_size Wanlong Gao
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 03/11] NUMA: Add numa_info structure to contain numa nodes info Wanlong Gao
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 04/11] NUMA: convert -numa option to use OptsVisitor Wanlong Gao
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 05/11] NUMA: introduce NumaMemOptions Wanlong Gao
2013-11-22  2:08 ` Wanlong Gao [this message]
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 07/11] NUMA: expand MAX_NODES from 64 to 128 Wanlong Gao
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 08/11] NUMA: parse guest numa nodes memory policy Wanlong Gao
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 09/11] NUMA: set " Wanlong Gao
2013-11-27 14:35   ` Paolo Bonzini
2013-11-27 15:09     ` Wanlong Gao
2013-11-27 16:19     ` Andrew Jones
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 10/11] NUMA: add qmp command query-numa Wanlong Gao
2013-11-22  2:08 ` [Qemu-devel] [PATCH V16 11/11] NUMA: convert hmp command info_numa to use qmp command query_numa Wanlong Gao

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=1385086118-11699-8-git-send-email-gaowanlong@cn.fujitsu.com \
    --to=gaowanlong@cn.fujitsu.com \
    --cc=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=bsd@redhat.com \
    --cc=drjones@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=lcapitulino@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=y-goto@jp.fujitsu.com \
    /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).