From nobody Wed Nov 5 17:45:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496689433703140.10136818923036; Mon, 5 Jun 2017 12:03:53 -0700 (PDT) Received: from localhost ([::1]:34734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHxI4-0005L4-AI for importer@patchew.org; Mon, 05 Jun 2017 15:03:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHxEC-0001rI-Jt for qemu-devel@nongnu.org; Mon, 05 Jun 2017 14:59:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHxEA-0007zW-FB for qemu-devel@nongnu.org; Mon, 05 Jun 2017 14:59:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35526) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dHxEA-0007yE-6a for qemu-devel@nongnu.org; Mon, 05 Jun 2017 14:59:46 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 147D3381285; Mon, 5 Jun 2017 18:59:45 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E7F860461; Mon, 5 Jun 2017 18:59:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 147D3381285 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 147D3381285 From: Eduardo Habkost To: Peter Maydell , Stefan Hajnoczi Date: Mon, 5 Jun 2017 15:59:21 -0300 Message-Id: <20170605185927.12111-5-ehabkost@redhat.com> In-Reply-To: <20170605185927.12111-1-ehabkost@redhat.com> References: <20170605185927.12111-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 05 Jun 2017 18:59:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/10] numa: make sure that all cpus have has_node_id set if numa is enabled X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov 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 Message-Id: <1496161442-96665-4-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- 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 2079828c22..3d78ff68e6 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, Vi= rtMachineState *vms) srat->reserved1 =3D cpu_to_le32(1); =20 for (i =3D 0; i < cpu_list->len; ++i) { - int node_id =3D cpu_list->cpus[i].props.has_node_id ? - cpu_list->cpus[i].props.node_id : 0; core =3D acpi_data_push(table_data, sizeof(*core)); core->type =3D ACPI_SRAT_PROCESSOR_GICC; core->length =3D sizeof(*core); - core->proximity =3D cpu_to_le32(node_id); + core->proximity =3D cpu_to_le32(cpu_list->cpus[i].props.node_id); core->acpi_processor_uid =3D cpu_to_le32(i); core->flags =3D cpu_to_le32(1); } diff --git a/hw/core/machine.c b/hw/core/machine.c index c1434e6a69..2e7e9778cd 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -721,19 +721,23 @@ static void machine_numa_finish_init(MachineState *ma= chine) const CPUArchId *cpu_slot =3D &possible_cpus->cpus[i]; =20 if (!cpu_slot->props.has_node_id) { - if (default_mapping) { - /* fetch default mapping from board and enable it */ - CpuInstanceProperties props =3D cpu_slot->props; - props.has_node_id =3D true; - machine_set_cpu_numa_node(machine, &props, &error_fatal); - } else { + /* fetch default mapping from board and enable it */ + CpuInstanceProperties props =3D cpu_slot->props; + + if (!default_mapping) { /* record slots with not set mapping, * TODO: make it hard error in future */ char *cpu_str =3D 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 =3D 0; } + + props.has_node_id =3D true; + machine_set_cpu_numa_node(machine, &props, &error_fatal); } } if (s->len && !qtest_enabled()) { diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 82bd44f38e..ce74c84460 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2335,8 +2335,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) srat->reserved1 =3D cpu_to_le32(1); =20 for (i =3D 0; i < apic_ids->len; i++) { - int node_id =3D apic_ids->cpus[i].props.has_node_id ? - apic_ids->cpus[i].props.node_id : 0; + int node_id =3D apic_ids->cpus[i].props.node_id; uint32_t apic_id =3D apic_ids->cpus[i].arch_id; =20 if (apic_id < 255) { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5b07be61cf..5b8c6fbbea 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -788,9 +788,7 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PC= MachineState *pcms) for (i =3D 0; i < cpus->len; i++) { unsigned int apic_id =3D 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] =3D cpu_to_le64(cpus->cpus[i].props.n= ode_id); - } + numa_fw_cfg[apic_id + 1] =3D cpu_to_le64(cpus->cpus[i].props.node_= id); } for (i =3D 0; i < nb_numa_nodes; i++) { numa_fw_cfg[pcms->apic_id_limit + 1 + i] =3D diff --git a/numa.c b/numa.c index 4ec3eaf687..65701cb6c8 100644 --- a/numa.c +++ b/numa.c @@ -509,22 +509,16 @@ void parse_numa_opts(MachineState *ms) =20 void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **er= rp) { - int mapped_node_id; /* set by -numa option */ int node_id =3D object_property_get_int(OBJECT(dev), "node-id", &error= _abort); =20 - /* 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 =3D slot->props.node_id; - if (!slot->props.has_node_id) { - mapped_node_id =3D 0; - } - if (node_id =3D=3D 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", er= rp); - } else if (node_id !=3D 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 !=3D slot->props.node_id) { error_setg(errp, "node-id=3D%d must match numa node specified " "with -numa option", node_id); } --=20 2.11.0.259.g40922b1