From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
Eduardo Habkost <ehabkost@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>,
Andrew Jones <drjones@redhat.com>
Subject: [Qemu-devel] [PATCH v3 3/7] numa: make sure that all cpus have has_node_id set if numa is enabled
Date: Tue, 30 May 2017 18:23:58 +0200 [thread overview]
Message-ID: <1496161442-96665-4-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1496161442-96665-1-git-send-email-imammedo@redhat.com>
It fixes/add missing _PXM object for non mapped CPU (x86)
and missing fdt node (virt-arm).
It ensures that possible_cpus contains complete mapping if
numa is enabled by the time machine_init() is executed.
As result non completely mapped CPUs:
1) appear in ACPI/fdt blobs
2) QMP query-hotpluggable-cpus command shows bound nodes for such CPUs
3) allows to drop checks for has_node_id in numa only code,
reducing number of invariants incomplete mapping could produce
4) moves fixup/implicit node init from runtime numa_cpu_pre_plug()
(when CPU object is created) to machine_numa_finish_init() which
helps to fix [1, 2] and make possible_cpus complete source
of numa mapping available even before CPUs are created.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
hw/arm/virt-acpi-build.c | 4 +---
hw/core/machine.c | 16 ++++++++++------
hw/i386/acpi-build.c | 3 +--
hw/i386/pc.c | 4 +---
numa.c | 16 +++++-----------
5 files changed, 18 insertions(+), 25 deletions(-)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index e585206..977a794 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -496,12 +496,10 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
srat->reserved1 = cpu_to_le32(1);
for (i = 0; i < cpu_list->len; ++i) {
- int node_id = cpu_list->cpus[i].props.has_node_id ?
- cpu_list->cpus[i].props.node_id : 0;
core = acpi_data_push(table_data, sizeof(*core));
core->type = ACPI_SRAT_PROCESSOR_GICC;
core->length = sizeof(*core);
- core->proximity = cpu_to_le32(node_id);
+ core->proximity = cpu_to_le32(cpu_list->cpus[i].props.node_id);
core->acpi_processor_uid = cpu_to_le32(i);
core->flags = cpu_to_le32(1);
}
diff --git a/hw/core/machine.c b/hw/core/machine.c
index aaf3cff..964b75d 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -720,19 +720,23 @@ static void machine_numa_finish_init(MachineState *machine)
const CPUArchId *cpu_slot = &possible_cpus->cpus[i];
if (!cpu_slot->props.has_node_id) {
- if (default_mapping) {
- /* fetch default mapping from board and enable it */
- CpuInstanceProperties props = cpu_slot->props;
- props.has_node_id = true;
- machine_set_cpu_numa_node(machine, &props, &error_fatal);
- } else {
+ /* fetch default mapping from board and enable it */
+ CpuInstanceProperties props = cpu_slot->props;
+
+ if (!default_mapping) {
/* record slots with not set mapping,
* TODO: make it hard error in future */
char *cpu_str = cpu_slot_to_string(cpu_slot);
g_string_append_printf(s, "%sCPU %d [%s]",
s->len ? ", " : "", i, cpu_str);
g_free(cpu_str);
+
+ /* non mapped cpus used to fallback to node 0 */
+ props.node_id = 0;
}
+
+ props.has_node_id = true;
+ machine_set_cpu_numa_node(machine, &props, &error_fatal);
}
}
if (s->len) {
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index afcadac..873880d 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2335,8 +2335,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
srat->reserved1 = cpu_to_le32(1);
for (i = 0; i < apic_ids->len; i++) {
- int node_id = apic_ids->cpus[i].props.has_node_id ?
- apic_ids->cpus[i].props.node_id : 0;
+ int node_id = apic_ids->cpus[i].props.node_id;
uint32_t apic_id = apic_ids->cpus[i].arch_id;
if (apic_id < 255) {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index cf09949..84f0a6f 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -788,9 +788,7 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms)
for (i = 0; i < cpus->len; i++) {
unsigned int apic_id = cpus->cpus[i].arch_id;
assert(apic_id < pcms->apic_id_limit);
- if (cpus->cpus[i].props.has_node_id) {
- numa_fw_cfg[apic_id + 1] = cpu_to_le64(cpus->cpus[i].props.node_id);
- }
+ numa_fw_cfg[apic_id + 1] = cpu_to_le64(cpus->cpus[i].props.node_id);
}
for (i = 0; i < nb_numa_nodes; i++) {
numa_fw_cfg[pcms->apic_id_limit + 1 + i] =
diff --git a/numa.c b/numa.c
index 45ad70a..abed45c 100644
--- a/numa.c
+++ b/numa.c
@@ -510,22 +510,16 @@ void parse_numa_opts(MachineState *ms)
void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp)
{
- int mapped_node_id; /* set by -numa option */
int node_id = object_property_get_int(OBJECT(dev), "node-id", &error_abort);
- /* by default CPUState::numa_node was 0 if it wasn't set explicitly
- * TODO: make it error when incomplete numa mapping support is removed
- */
- mapped_node_id = slot->props.node_id;
- if (!slot->props.has_node_id) {
- mapped_node_id = 0;
- }
-
if (node_id == CPU_UNSET_NUMA_NODE_ID) {
/* due to bug in libvirt, it doesn't pass node-id from props on
* device_add as expected, so we have to fix it up here */
- object_property_set_int(OBJECT(dev), mapped_node_id, "node-id", errp);
- } else if (node_id != mapped_node_id) {
+ if (slot->props.has_node_id) {
+ object_property_set_int(OBJECT(dev), slot->props.node_id,
+ "node-id", errp);
+ }
+ } else if (node_id != slot->props.node_id) {
error_setg(errp, "node-id=%d must match numa node specified "
"with -numa option", node_id);
}
--
2.7.4
next prev parent reply other threads:[~2017-05-30 16:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-30 16:23 [Qemu-devel] [PATCH v3 0/7] numa: code consolidation and fixes Igor Mammedov
2017-05-30 16:23 ` [Qemu-devel] [PATCH v3 1/7] numa: consolidate cpu_preplug fixups/checks for pc/arm/spapr Igor Mammedov
2017-05-30 16:23 ` [Qemu-devel] [PATCH v3 2/7] numa: move default mapping init to machine Igor Mammedov
2017-05-30 16:23 ` Igor Mammedov [this message]
2017-05-30 16:23 ` [Qemu-devel] [PATCH v3 4/7] numa: make hmp 'info numa' fetch numa nodes from qmp_query_cpus() result Igor Mammedov
2017-05-30 16:24 ` [Qemu-devel] [PATCH v3 5/7] numa: move numa_node from CPUState into target specific classes Igor Mammedov
2017-05-30 16:30 ` Eric Blake
2017-05-30 19:47 ` Eduardo Habkost
2017-05-30 16:24 ` [Qemu-devel] [PATCH v3 6/7] spapr: cleanup spapr_fixup_cpu_numa_dt() usage Igor Mammedov
2017-05-30 16:40 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-05-30 19:47 ` Eduardo Habkost
2017-05-30 16:24 ` [Qemu-devel] [PATCH v3 7/7] numa: cpu: calculate/set default node-ids after all -numa CLI options are parsed Igor Mammedov
2017-05-30 20:03 ` Eduardo Habkost
2017-05-31 8:50 ` Igor Mammedov
2017-05-31 13:32 ` Eduardo Habkost
2017-06-01 10:53 ` [Qemu-devel] [PATCH v4 " Igor Mammedov
2017-06-02 17:16 ` Eduardo Habkost
2017-05-30 18:07 ` [Qemu-devel] [PATCH v3 0/7] numa: code consolidation and fixes no-reply
2017-05-30 19:48 ` Eduardo Habkost
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=1496161442-96665-4-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=drjones@redhat.com \
--cc=ehabkost@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).