From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, ehabkost@redhat.com, bsd@redhat.com,
pbonzini@redhat.com, y-goto@jp.fujitsu.com, afaerber@suse.de,
gaowanlong@cn.fujitsu.com
Subject: [Qemu-devel] [PATCH V2 7/9] NUMA: add qmp command set-mpol to set memory policy for NUMA node
Date: Fri, 21 Jun 2013 14:25:58 +0800 [thread overview]
Message-ID: <1371795960-10478-8-git-send-email-gaowanlong@cn.fujitsu.com> (raw)
In-Reply-To: <1371795960-10478-1-git-send-email-gaowanlong@cn.fujitsu.com>
The QMP command let it be able to set node's memory policy
through the QMP protocol. The qmp-shell command is like:
set-mpol nodeid=0 mem-policy=membind mem-hostnode=0-1
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
cpus.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
qapi-schema.json | 15 +++++++++++++++
qmp-commands.hx | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+)
diff --git a/cpus.c b/cpus.c
index 677ee15..9c2706c 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1432,3 +1432,57 @@ void qmp_inject_nmi(Error **errp)
error_set(errp, QERR_UNSUPPORTED);
#endif
}
+
+void qmp_set_mpol(int64_t nodeid, bool has_mpol, const char *mpol,
+ bool has_hostnode, const char *hostnode, Error **errp)
+{
+ unsigned int flags;
+ DECLARE_BITMAP(host_mem, MAX_CPUMASK_BITS);
+
+ if (nodeid >= nb_numa_nodes) {
+ error_setg(errp, "Only has '%d' NUMA nodes", nb_numa_nodes);
+ return;
+ }
+
+ bitmap_copy(host_mem, numa_info[nodeid].host_mem, MAX_CPUMASK_BITS);
+ flags = numa_info[nodeid].flags;
+
+ numa_info[nodeid].flags = NODE_HOST_NONE;
+ bitmap_zero(numa_info[nodeid].host_mem, MAX_CPUMASK_BITS);
+
+ if (!has_mpol) {
+ if (set_node_mpol(nodeid) == -1) {
+ error_setg(errp, "Failed to set memory policy for node%lu", nodeid);
+ goto error;
+ }
+ return;
+ }
+
+ numa_node_parse_mpol(nodeid, mpol, errp);
+ if (error_is_set(errp)) {
+ goto error;
+ }
+
+ if (!has_hostnode) {
+ bitmap_fill(numa_info[nodeid].host_mem, MAX_CPUMASK_BITS);
+ }
+
+ if (hostnode) {
+ numa_node_parse_hostnode(nodeid, hostnode, errp);
+ if (error_is_set(errp)) {
+ goto error;
+ }
+ }
+
+ if (set_node_mpol(nodeid) == -1) {
+ error_setg(errp, "Failed to set memory policy for node%lu", nodeid);
+ goto error;
+ }
+
+ return;
+
+error:
+ bitmap_copy(numa_info[nodeid].host_mem, host_mem, MAX_CPUMASK_BITS);
+ numa_info[nodeid].flags = flags;
+ return;
+}
diff --git a/qapi-schema.json b/qapi-schema.json
index a80ee40..cedcbe1 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3608,3 +3608,18 @@
'*cpuid-input-ecx': 'int',
'cpuid-register': 'X86CPURegister32',
'features': 'int' } }
+
+# @set-mpol:
+#
+# Set the host memory binding policy for guest NUMA node.
+#
+# @nodeid: The node ID of guest NUMA node to set memory policy to.
+#
+# @mem-policy: The memory policy string to set.
+#
+# @mem-hostnode: The host node or node range for memory policy.
+#
+# Since: 1.6.0
+##
+{ 'command': 'set-mpol', 'data': {'nodeid': 'int', '*mem-policy': 'str',
+ '*mem-hostnode': 'str'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 8cea5e5..7bb5038 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2997,3 +2997,38 @@ Example:
<- { "return": {} }
EQMP
+
+ {
+ .name = "set-mpol",
+ .args_type = "nodeid:i,mem-policy:s?,mem-hostnode:s?",
+ .help = "Set the host memory binding policy for guest NUMA node",
+ .mhandler.cmd_new = qmp_marshal_input_set_mpol,
+ },
+
+SQMP
+set-mpol
+------
+
+Set the host memory binding policy for guest NUMA node
+
+Arguments:
+
+- "nodeid": The nodeid of guest NUMA node to set memory policy to.
+ (json-int)
+- "mem-policy": The memory policy string to set.
+ (json-string, optional)
+- "mem-hostnode": The host nodes contained to mpol.
+ (json-string, optional)
+
+Example:
+
+-> { "execute": "set-mpol", "arguments": { "nodeid": 0, "mem-policy": "membind",
+ "mem-hostnode": "0-1" }}
+<- { "return": {} }
+
+Notes:
+ 1. If "mem-policy" is not set, the memory policy of this "nodeid" will be set
+ to "default".
+ 2. If "mem-hostnode" is not set, the node mask of this "mpol" will be set
+ to "all".
+EQMP
--
1.8.3.1.448.gfb7dfaa
next prev parent reply other threads:[~2013-06-21 6:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 6:25 [Qemu-devel] [PATCH V2 0/9] Add support for binding guest numa nodes to host numa nodes Wanlong Gao
2013-06-21 6:25 ` [Qemu-devel] [PATCH V2 1/9] NUMA: Support multiple CPU ranges on -numa option Wanlong Gao
2013-06-21 6:25 ` [Qemu-devel] [PATCH V2 2/9] NUMA: Add numa_info structure to contain numa nodes info Wanlong Gao
2013-06-21 6:25 ` [Qemu-devel] [PATCH V2 3/9] NUMA: Add Linux libnuma detection Wanlong Gao
2013-06-21 6:25 ` [Qemu-devel] [PATCH V2 4/9] NUMA: parse guest numa nodes memory policy Wanlong Gao
2013-06-21 15:34 ` Bandan Das
2013-06-21 6:25 ` [Qemu-devel] [PATCH V2 5/9] NUMA: set " Wanlong Gao
2013-06-21 6:25 ` [Qemu-devel] [PATCH V2 6/9] NUMA: handle Error in mpol and hostnode parser Wanlong Gao
2013-06-21 6:25 ` Wanlong Gao [this message]
2013-06-21 6:25 ` [Qemu-devel] [PATCH V2 8/9] NUMA: add hmp command set-mpol Wanlong Gao
2013-06-21 6:26 ` [Qemu-devel] [PATCH V2 9/9] NUMA: show host memory policy info in info numa command 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=1371795960-10478-8-git-send-email-gaowanlong@cn.fujitsu.com \
--to=gaowanlong@cn.fujitsu.com \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=bsd@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.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).