[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/11] numa: Parse initiator= attribute before cpus= attribute
From: |
Eduardo Habkost |
Subject: |
[PULL 11/11] numa: Parse initiator= attribute before cpus= attribute |
Date: |
Tue, 13 Jul 2021 12:09:57 -0400 |
From: Michal Privoznik <mprivozn@redhat.com>
When parsing cpus= attribute of -numa object couple of checks
is performed, such as correct initiator setting (see the if()
statement at the end of for() loop in
machine_set_cpu_numa_node()).
However, with the current code cpus= attribute is parsed before
initiator= attribute and thus the check may fail even though it
is not obvious why. But since parsing the initiator= attribute
does not depend on the cpus= attribute we can swap the order of
the two.
It's fairly easy to reproduce with the following command line
(snippet of an actual cmd line):
-smp 4,sockets=4,cores=1,threads=1 \
-object
'{"qom-type":"memory-backend-ram","id":"ram-node0","size":2147483648}' \
-numa node,nodeid=0,cpus=0-1,initiator=0,memdev=ram-node0 \
-object
'{"qom-type":"memory-backend-ram","id":"ram-node1","size":2147483648}' \
-numa node,nodeid=1,cpus=2-3,initiator=1,memdev=ram-node1 \
-numa
hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-latency,latency=5
\
-numa
hmat-lb,initiator=0,target=0,hierarchy=first-level,data-type=access-latency,latency=10
\
-numa
hmat-lb,initiator=1,target=1,hierarchy=memory,data-type=access-latency,latency=5
\
-numa
hmat-lb,initiator=1,target=1,hierarchy=first-level,data-type=access-latency,latency=10
\
-numa
hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-bandwidth,bandwidth=204800K
\
-numa
hmat-lb,initiator=0,target=0,hierarchy=first-level,data-type=access-bandwidth,bandwidth=208896K
\
-numa
hmat-lb,initiator=1,target=1,hierarchy=memory,data-type=access-bandwidth,bandwidth=204800K
\
-numa
hmat-lb,initiator=1,target=1,hierarchy=first-level,data-type=access-bandwidth,bandwidth=208896K
\
-numa
hmat-cache,node-id=0,size=10K,level=1,associativity=direct,policy=write-back,line=8
\
-numa
hmat-cache,node-id=1,size=10K,level=1,associativity=direct,policy=write-back,line=8
\
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id:
<b27a6a88986d63e3f610a728c845e01ff8d92e2e.1625662776.git.mprivozn@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/core/numa.c | 45 +++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/hw/core/numa.c b/hw/core/numa.c
index 1058d3697b1..510d096a888 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -88,6 +88,29 @@ static void parse_numa_node(MachineState *ms,
NumaNodeOptions *node,
return;
}
+ /*
+ * If not set the initiator, set it to MAX_NODES. And if
+ * HMAT is enabled and this node has no cpus, QEMU will raise error.
+ */
+ numa_info[nodenr].initiator = MAX_NODES;
+ if (node->has_initiator) {
+ if (!ms->numa_state->hmat_enabled) {
+ error_setg(errp, "ACPI Heterogeneous Memory Attribute Table "
+ "(HMAT) is disabled, enable it with -machine hmat=on "
+ "before using any of hmat specific options");
+ return;
+ }
+
+ if (node->initiator >= MAX_NODES) {
+ error_report("The initiator id %" PRIu16 " expects an integer "
+ "between 0 and %d", node->initiator,
+ MAX_NODES - 1);
+ return;
+ }
+
+ numa_info[nodenr].initiator = node->initiator;
+ }
+
for (cpus = node->cpus; cpus; cpus = cpus->next) {
CpuInstanceProperties props;
if (cpus->value >= max_cpus) {
@@ -142,28 +165,6 @@ static void parse_numa_node(MachineState *ms,
NumaNodeOptions *node,
numa_info[nodenr].node_memdev = MEMORY_BACKEND(o);
}
- /*
- * If not set the initiator, set it to MAX_NODES. And if
- * HMAT is enabled and this node has no cpus, QEMU will raise error.
- */
- numa_info[nodenr].initiator = MAX_NODES;
- if (node->has_initiator) {
- if (!ms->numa_state->hmat_enabled) {
- error_setg(errp, "ACPI Heterogeneous Memory Attribute Table "
- "(HMAT) is disabled, enable it with -machine hmat=on "
- "before using any of hmat specific options");
- return;
- }
-
- if (node->initiator >= MAX_NODES) {
- error_report("The initiator id %" PRIu16 " expects an integer "
- "between 0 and %d", node->initiator,
- MAX_NODES - 1);
- return;
- }
-
- numa_info[nodenr].initiator = node->initiator;
- }
numa_info[nodenr].present = true;
max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);
ms->numa_state->num_nodes++;
--
2.31.1
- [PULL 00/11] x86 queue, 2021-07-13, Eduardo Habkost, 2021/07/13
- [PULL 03/11] i386: make hyperv_expand_features() return bool, Eduardo Habkost, 2021/07/13
- [PULL 04/11] i386: expand Hyper-V features during CPU feature expansion time, Eduardo Habkost, 2021/07/13
- [PULL 05/11] i386: kill off hv_cpuid_check_and_set(), Eduardo Habkost, 2021/07/13
- [PULL 01/11] i386: clarify 'hv-passthrough' behavior, Eduardo Habkost, 2021/07/13
- [PULL 06/11] i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed, Eduardo Habkost, 2021/07/13
- [PULL 07/11] i386: Hyper-V SynIC requires POST_MESSAGES/SIGNAL_EVENTS privileges, Eduardo Habkost, 2021/07/13
- [PULL 10/11] numa: Report expected initiator, Eduardo Habkost, 2021/07/13
- [PULL 11/11] numa: Parse initiator= attribute before cpus= attribute,
Eduardo Habkost <=
- [PULL 02/11] i386: hardcode supported eVMCS version to '1', Eduardo Habkost, 2021/07/13
- [PULL 08/11] target/i386: suppress CPUID leaves not defined by the CPU vendor, Eduardo Habkost, 2021/07/13
- [PULL 09/11] target/i386: Fix cpuid level for AMD, Eduardo Habkost, 2021/07/13
- Re: [PULL 00/11] x86 queue, 2021-07-13, Peter Maydell, 2021/07/14