From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Cc: andre.przywara@amd.com, aliguori@us.ibm.com, ehabkost@redhat.com,
qemu-devel@nongnu.org, y-goto@jp.fujitsu.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 5/7] NUMA: add qmp command set-mpol to set memory policy for NUMA node
Date: Tue, 18 Jun 2013 11:21:58 +0200 [thread overview]
Message-ID: <51C026B6.8030606@redhat.com> (raw)
In-Reply-To: <1371542991-15911-6-git-send-email-gaowanlong@cn.fujitsu.com>
Il 18/06/2013 10:09, Wanlong Gao ha scritto:
> 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 mpol=membind nodemask=0-1
>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
How would this work with mem-path?
Paolo
> ---
> cpus.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
> include/sysemu/sysemu.h | 1 +
> qapi-schema.json | 13 +++++++++++
> qmp-commands.hx | 35 ++++++++++++++++++++++++++++
> vl.c | 2 +-
> 5 files changed, 111 insertions(+), 1 deletion(-)
>
> diff --git a/cpus.c b/cpus.c
> index b868932..a2836e9 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1431,3 +1431,64 @@ 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_nodemask, const char *nodemask, Error **errp)
> +{
> + unsigned int ret;
> + 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) {
> + goto error;
> + }
> + return;
> + }
> +
> + if (!strcmp(mpol, "membind")) {
> + numa_info[nodeid].flags |= NODE_HOST_BIND;
> + } else if (!strcmp(mpol, "interleave")) {
> + numa_info[nodeid].flags |= NODE_HOST_INTERLEAVE;
> + } else if (!strcmp(mpol, "preferred")) {
> + numa_info[nodeid].flags |= NODE_HOST_PREFERRED;
> + } else {
> + error_setg(errp, "Invalid NUMA policy '%s'", mpol);
> + goto error;
> + }
> +
> + if (!has_nodemask) {
> + bitmap_fill(numa_info[nodeid].host_mem, MAX_CPUMASK_BITS);
> + }
> +
> + if (nodemask) {
> + ret = numa_node_parse_mpol(nodemask, numa_info[nodeid].host_mem);
> + }
> + if (ret == 4) {
> + goto error;
> + } else if (ret & 1) {
> + numa_info[nodeid].flags |= NODE_HOST_RELATIVE;
> + }
> +
> + if (set_node_mpol(nodeid) == -1) {
> + 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/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 993b8e0..7d804af 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -144,6 +144,7 @@ struct node_info {
> unsigned int flags;
> };
> extern struct node_info numa_info[MAX_NODES];
> +extern unsigned int numa_node_parse_mpol(const char *str, unsigned long *bm);
>
> #define MAX_OPTION_ROMS 16
> typedef struct QEMUOptionRom {
> diff --git a/qapi-schema.json b/qapi-schema.json
> index a80ee40..403c703 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -3608,3 +3608,16 @@
> '*cpuid-input-ecx': 'int',
> 'cpuid-register': 'X86CPURegister32',
> 'features': 'int' } }
> +
> +# @set-mpol:
> +#
> +# Set the host memory binding policy for guest NUMA node.
> +#
> +# @node-id: The node ID of guest NUMA node to set memory policy to.
> +#
> +# @mpol: The memory policy string to set.
> +#
> +# Since: 1.6.0
> +##
> +{ 'command': 'set-mpol', 'data': {'nodeid': 'int', '*mpol': 'str',
> + '*nodemask': 'str'} }
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 8cea5e5..930c844 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -2997,3 +2997,38 @@ Example:
> <- { "return": {} }
>
> EQMP
> +
> + {
> + .name = "set-mpol",
> + .args_type = "nodeid:i,mpol:s?,nodemask: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)
> +- "mpol": The memory policy string to set.
> + (json-string, optional)
> +- "nodemask": The node mask contained to mpol.
> + (json-string, optional)
> +
> +Example:
> +
> +-> { "execute": "set-mpol", "arguments": { "nodeid": 0, "mpol": "membind",
> + "nodemask": "0-1" }}
> +<- { "return": {} }
> +
> +Notes:
> + 1. If "mpol" is not set, the memory policy of this "nodeid" will be set
> + to "default".
> + 2. If "nodemask" is not set, the node mask of this "mpol" will be set
> + to "all".
> +EQMP
> diff --git a/vl.c b/vl.c
> index ada9fb2..73af85e 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1348,7 +1348,7 @@ error:
> exit(1);
> }
>
> -static unsigned int numa_node_parse_mpol(const char *str, unsigned long *bm)
> +unsigned int numa_node_parse_mpol(const char *str, unsigned long *bm)
> {
> unsigned long long value, endvalue;
> char *endptr;
>
next prev parent reply other threads:[~2013-06-18 9:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 8:09 [Qemu-devel] [PATCH 0/7] Add support for binding guest numa nodes to host numa nodes Wanlong Gao
2013-06-18 8:09 ` [Qemu-devel] [PATCH 1/7] Add numa_info structure to contain numa nodes info Wanlong Gao
2013-06-18 8:09 ` [Qemu-devel] [PATCH 2/7] Add Linux libnuma detection Wanlong Gao
2013-06-18 8:09 ` [Qemu-devel] [PATCH 3/7] NUMA: parse guest numa nodes memory policy Wanlong Gao
2013-06-18 9:20 ` Paolo Bonzini
2013-06-18 9:54 ` Wanlong Gao
2013-06-18 19:00 ` Eduardo Habkost
2013-06-18 20:19 ` Bandan Das
2013-06-19 8:01 ` Wanlong Gao
2013-06-19 17:39 ` Paolo Bonzini
2013-06-20 0:01 ` Wanlong Gao
2013-06-18 8:09 ` [Qemu-devel] [PATCH 4/7] NUMA: set " Wanlong Gao
2013-06-18 8:09 ` [Qemu-devel] [PATCH 5/7] NUMA: add qmp command set-mpol to set memory policy for NUMA node Wanlong Gao
2013-06-18 9:21 ` Paolo Bonzini [this message]
2013-06-18 9:44 ` Wanlong Gao
2013-06-18 9:57 ` Paolo Bonzini
2013-06-18 8:09 ` [Qemu-devel] [PATCH 6/7] NUMA: add hmp command set-mpol Wanlong Gao
2013-06-18 9:23 ` Paolo Bonzini
2013-06-18 9:49 ` Wanlong Gao
2013-06-18 8:09 ` [Qemu-devel] [PATCH 7/7] 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=51C026B6.8030606@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=andre.przywara@amd.com \
--cc=ehabkost@redhat.com \
--cc=gaowanlong@cn.fujitsu.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).