From: Tao Xu <tao3.xu@intel.com>
To: imammedo@redhat.com, eblake@redhat.com, ehabkost@redhat.com
Cc: jingqi.liu@intel.com, tao3.xu@intel.com, fan.du@intel.com,
qemu-devel@nongnu.org, jonathan.cameron@huawei.com,
dan.j.williams@intel.com
Subject: [Qemu-devel] [PATCH RESEND v6 13/14] QMP: Add QMP interface to update HMAT at runtime
Date: Tue, 9 Jul 2019 15:15:19 +0800 [thread overview]
Message-ID: <20190709071520.8745-14-tao3.xu@intel.com> (raw)
In-Reply-To: <20190709071520.8745-1-tao3.xu@intel.com>
Add QMP interface to introduce new HMAT data (including System Locality
Latency and Bandwidth Information Structure, Memory Side Cache
Information Structure) at runtime. The interface can
also replace existing HMAT data.
Suggested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Tao Xu <tao3.xu@intel.com>
---
hw/acpi/acpi-stub.c | 7 ++++++
hw/core/machine-qmp-cmds.c | 39 ++++++++++++++++++++++++++++++
hw/core/numa.c | 17 +++++++------
include/sysemu/numa.h | 4 ++--
qapi/machine.json | 49 ++++++++++++++++++++++++++++++++++++++
5 files changed, 107 insertions(+), 9 deletions(-)
diff --git a/hw/acpi/acpi-stub.c b/hw/acpi/acpi-stub.c
index 4c9d081ed4..757570ee7f 100644
--- a/hw/acpi/acpi-stub.c
+++ b/hw/acpi/acpi-stub.c
@@ -22,8 +22,15 @@
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
#include "hw/acpi/acpi.h"
+#include "sysemu/numa.h"
+#include "hw/acpi/hmat.h"
void acpi_table_add(const QemuOpts *opts, Error **errp)
{
error_setg(errp, QERR_UNSUPPORTED);
}
+
+void hmat_update(NumaState *nstat)
+{
+ /* For qmp_set_hmat_lb and qmp_set_hmat_cache in numa.c can compile */
+}
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 5bd95b8ab0..fe6ed418b1 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -17,6 +17,7 @@
#include "sysemu/hw_accel.h"
#include "sysemu/numa.h"
#include "sysemu/sysemu.h"
+#include "hw/acpi/hmat.h"
CpuInfoList *qmp_query_cpus(Error **errp)
{
@@ -283,6 +284,44 @@ void qmp_set_numa_node(NumaOptions *cmd, Error **errp)
set_numa_options(MACHINE(qdev_get_machine()), cmd, errp);
}
+void qmp_set_hmat_lb(NumaHmatLBOptions *node, Error **errp)
+{
+ MachineState *ms = MACHINE(qdev_get_machine());
+
+ if (ms->numa_state == NULL || ms->numa_state->num_nodes <= 0) {
+ error_setg(errp, "NUMA is not supported");
+ return;
+ }
+
+ if (ms->numa_state->hma_enabled) {
+ parse_numa_hmat_lb(ms, node, 1, errp);
+ hmat_update(ms->numa_state);
+ } else {
+ error_setg(errp, "HMAT can't be changed at runtime when QEMU boot"
+ " without setting HMAT latency, bandwidth or memory cache"
+ " information");
+ }
+}
+
+void qmp_set_hmat_cache(NumaHmatCacheOptions *node, Error **errp)
+{
+ MachineState *ms = MACHINE(qdev_get_machine());
+
+ if (ms->numa_state == NULL || ms->numa_state->num_nodes <= 0) {
+ error_setg(errp, "NUMA is not supported");
+ return;
+ }
+
+ if (ms->numa_state->hma_enabled) {
+ parse_numa_hmat_cache(ms, node, 1, errp);
+ hmat_update(ms->numa_state);
+ } else {
+ error_setg(errp, "HMAT can't be changed at runtime when QEMU boot"
+ " without setting HMAT latency, bandwidth or memory cache"
+ " information");
+ }
+}
+
static int query_memdev(Object *obj, void *opaque)
{
MemdevList **list = opaque;
diff --git a/hw/core/numa.c b/hw/core/numa.c
index 5ed53ef05e..e8ee4edd67 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -185,7 +185,7 @@ void parse_numa_distance(MachineState *ms, NumaDistOptions *dist, Error **errp)
}
void parse_numa_hmat_lb(MachineState *ms, NumaHmatLBOptions *node,
- Error **errp)
+ bool runtime_flag, Error **errp)
{
int nb_numa_nodes = ms->numa_state->num_nodes;
NodeInfo *numa_info = ms->numa_state->nodes;
@@ -262,7 +262,8 @@ void parse_numa_hmat_lb(MachineState *ms, NumaHmatLBOptions *node,
if (!hmat_lb) {
hmat_lb = g_malloc0(sizeof(*hmat_lb));
ms->numa_state->hmat_lb[node->hierarchy][node->data_type] = hmat_lb;
- } else if (hmat_lb->latency[node->initiator][node->target]) {
+ } else if (!runtime_flag &&
+ hmat_lb->latency[node->initiator][node->target]) {
error_setg(errp, "Duplicate configuration of the latency for "
"initiator=%" PRIu16 " and target=%" PRIu16 ".",
node->initiator, node->target);
@@ -283,7 +284,8 @@ void parse_numa_hmat_lb(MachineState *ms, NumaHmatLBOptions *node,
if (!hmat_lb) {
hmat_lb = g_malloc0(sizeof(*hmat_lb));
ms->numa_state->hmat_lb[node->hierarchy][node->data_type] = hmat_lb;
- } else if (hmat_lb->bandwidth[node->initiator][node->target]) {
+ } else if (!runtime_flag &&
+ hmat_lb->bandwidth[node->initiator][node->target]) {
error_setg(errp, "Duplicate configuration of the bandwidth for "
"initiator=%" PRIu16 " and target=%" PRIu16 ".",
node->initiator, node->target);
@@ -310,7 +312,7 @@ void parse_numa_hmat_lb(MachineState *ms, NumaHmatLBOptions *node,
}
void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node,
- Error **errp)
+ bool runtime_flag, Error **errp)
{
int nb_numa_nodes = ms->numa_state->num_nodes;
HMAT_Cache_Info *hmat_cache = NULL;
@@ -335,7 +337,8 @@ void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node,
node->level, node->total);
return;
}
- if (ms->numa_state->hmat_cache[node->node_id][node->level]) {
+ if (!runtime_flag &&
+ ms->numa_state->hmat_cache[node->node_id][node->level]) {
error_setg(errp, "Duplicate configuration of the side cache for "
"node-id=%" PRIu32 " and level=%" PRIu8 ".",
node->node_id, node->level);
@@ -414,13 +417,13 @@ void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp)
&err);
break;
case NUMA_OPTIONS_TYPE_HMAT_LB:
- parse_numa_hmat_lb(ms, &object->u.hmat_lb, &err);
+ parse_numa_hmat_lb(ms, &object->u.hmat_lb, 0, &err);
if (err) {
goto end;
}
break;
case NUMA_OPTIONS_TYPE_HMAT_CACHE:
- parse_numa_hmat_cache(ms, &object->u.hmat_cache, &err);
+ parse_numa_hmat_cache(ms, &object->u.hmat_cache, 0, &err);
if (err) {
goto end;
}
diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h
index ba040b8b76..e5899f0764 100644
--- a/include/sysemu/numa.h
+++ b/include/sysemu/numa.h
@@ -49,9 +49,9 @@ typedef struct NumaState NumaState;
void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp);
void parse_numa_opts(MachineState *ms);
void parse_numa_hmat_lb(MachineState *ms, NumaHmatLBOptions *node,
- Error **errp);
+ bool runtime_flag, Error **errp);
void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node,
- Error **errp);
+ bool runtime_flag, Error **errp);
void numa_complete_configuration(MachineState *ms);
void query_numa_node_mem(NumaNodeMem node_mem[], MachineState *ms);
extern QemuOptsList qemu_numa_opts;
diff --git a/qapi/machine.json b/qapi/machine.json
index b0d42cff21..3cb69d2c6e 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -606,6 +606,31 @@
'*latency': 'uint16',
'*bandwidth': 'uint16' }}
+##
+# @set-hmat-lb:
+#
+# Set @NumaHmatLBOptions at runtime.
+#
+# Since: 4.1
+#
+# Example:
+# Set the processors in node 0 access memory in node with access-latency 5
+# nanoseconds(base latency is 10):
+#
+# -> { "execute": "set-hmat-lb",
+# "arguments": { "initiator": 0,
+# "target": 1,
+# "hierarchy": "memory",
+# "data-type": "access-latency",
+# "base-lat": 10,
+# "latency": 5 } }
+# <- { "return": {} }
+##
+{ 'command': 'set-hmat-lb', 'boxed': true,
+ 'data': 'NumaHmatLBOptions',
+ 'allow-preconfig': true
+}
+
##
# @HmatCacheAssociativity:
#
@@ -680,6 +705,30 @@
'policy': 'HmatCacheWritePolicy',
'line': 'uint16' }}
+##
+# @set-hmat-cache:
+#
+# Set @NumaHmatCacheOptions at runtime.
+#
+# Since: 4.1
+#
+# Example:
+# Set Memory Side Cache Information in node 1:
+#
+# -> { "execute": "set-hmat-cache",
+# "arguments": { "node-id": 1,
+# "size": 0x20000,
+# "total": 3,
+# "level": "direct",
+# "policy": "write-back",
+# "line": 8 } }
+# <- { "return": {} }
+##
+{ 'command': 'set-hmat-cache', 'boxed': true,
+ 'data': 'NumaHmatCacheOptions',
+ 'allow-preconfig': true
+}
+
##
# @HostMemPolicy:
#
--
2.20.1
next prev parent reply other threads:[~2019-07-09 7:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-09 7:15 [Qemu-devel] [PATCH RESEND v6 00/14] Build ACPI Heterogeneous Memory Attribute Table (HMAT) Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 01/14] hw/arm: simplify arm_load_dtb Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 02/14] numa: move numa global variable nb_numa_nodes into MachineState Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 03/14] numa: move numa global variable have_numa_distance " Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 04/14] numa: move numa global variable numa_info " Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 05/14] numa: Extend CLI to provide initiator information for numa nodes Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 06/14] hmat acpi: Build Memory Proximity Domain Attributes Structure(s) Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 07/14] hmat acpi: Build System Locality Latency and Bandwidth Information Structure(s) Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 08/14] hmat acpi: Build Memory Side Cache " Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 09/14] numa: Extend the CLI to provide memory latency and bandwidth information Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 10/14] numa: Extend the CLI to provide memory side cache information Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 11/14] acpi: introduce aml_build_runtime_buf for NFIT generalizations Tao Xu
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 12/14] hmat acpi: Implement _HMA method to update HMAT at runtime Tao Xu
2019-07-09 7:15 ` Tao Xu [this message]
2019-07-09 7:15 ` [Qemu-devel] [PATCH RESEND v6 14/14] tests/bios-tables-test: add test cases for ACPI HMAT Tao Xu
2019-07-09 7:41 ` [Qemu-devel] [PATCH RESEND v6 00/14] Build ACPI Heterogeneous Memory Attribute Table (HMAT) no-reply
2019-07-09 7:46 ` no-reply
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=20190709071520.8745-14-tao3.xu@intel.com \
--to=tao3.xu@intel.com \
--cc=dan.j.williams@intel.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=fan.du@intel.com \
--cc=imammedo@redhat.com \
--cc=jingqi.liu@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=qemu-devel@nongnu.org \
/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).