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 1496689286292167.3645663967892; Mon, 5 Jun 2017 12:01:26 -0700 (PDT) Received: from localhost ([::1]:34727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHxFk-0002vV-P8 for importer@patchew.org; Mon, 05 Jun 2017 15:01:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHxE3-0001je-Qs for qemu-devel@nongnu.org; Mon, 05 Jun 2017 14:59:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHxE2-0007oh-Do for qemu-devel@nongnu.org; Mon, 05 Jun 2017 14:59:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dHxE2-0007nr-4o for qemu-devel@nongnu.org; Mon, 05 Jun 2017 14:59:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D52680461; Mon, 5 Jun 2017 18:59:37 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id D44247B131; Mon, 5 Jun 2017 18:59:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D52680461 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1D52680461 From: Eduardo Habkost To: Peter Maydell , Stefan Hajnoczi Date: Mon, 5 Jun 2017 15:59:19 -0300 Message-Id: <20170605185927.12111-3-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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 05 Jun 2017 18:59:37 +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 02/10] numa: consolidate cpu_preplug fixups/checks for pc/arm/spapr 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 Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Message-Id: <1496161442-96665-2-git-send-email-imammedo@redhat.com> [ehabkost: Fix indentation] Signed-off-by: Eduardo Habkost --- include/sysemu/numa.h | 1 + hw/arm/virt.c | 16 ++-------------- hw/i386/pc.c | 17 +---------------- hw/ppc/spapr.c | 17 +---------------- numa.c | 23 +++++++++++++++++++++++ 5 files changed, 28 insertions(+), 46 deletions(-) diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 7ffde5b119..610eece211 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -35,4 +35,5 @@ void numa_legacy_auto_assign_ram(MachineClass *mc, NodeIn= fo *nodes, int nb_nodes, ram_addr_t size); void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, int nb_nodes, ram_addr_t size); +void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **er= rp); #endif diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4db2d4207c..010f7244bf 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1372,7 +1372,6 @@ static void machvirt_init(MachineState *machine) for (n =3D 0; n < possible_cpus->len; n++) { Object *cpuobj; CPUState *cs; - int node_id; =20 if (n >=3D smp_cpus) { break; @@ -1385,19 +1384,8 @@ static void machvirt_init(MachineState *machine) cs =3D CPU(cpuobj); cs->cpu_index =3D n; =20 - node_id =3D possible_cpus->cpus[cs->cpu_index].props.node_id; - if (!possible_cpus->cpus[cs->cpu_index].props.has_node_id) { - /* by default CPUState::numa_node was 0 if it's not set via CLI - * keep it this way for now but in future we probably should - * refuse to start up with incomplete numa mapping */ - node_id =3D 0; - } - if (cs->numa_node =3D=3D CPU_UNSET_NUMA_NODE_ID) { - cs->numa_node =3D node_id; - } else { - /* CPU isn't device_add compatible yet, this shouldn't happen = */ - error_setg(&error_abort, "user set node-id not implemented"); - } + numa_cpu_pre_plug(&possible_cpus->cpus[cs->cpu_index], DEVICE(cpuo= bj), + &error_fatal); =20 if (!vms->secure) { object_property_set_bool(cpuobj, false, "has_el3", NULL); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 107a34125b..5b07be61cf 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1893,7 +1893,6 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, Error **errp) { int idx; - int node_id; CPUState *cs; CPUArchId *cpu_slot; X86CPUTopoInfo topo; @@ -1984,21 +1983,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_= dev, cs =3D CPU(cpu); cs->cpu_index =3D idx; =20 - node_id =3D cpu_slot->props.node_id; - if (!cpu_slot->props.has_node_id) { - /* by default CPUState::numa_node was 0 if it's not set via CLI - * keep it this way for now but in future we probably should - * refuse to start up with incomplete numa mapping */ - node_id =3D 0; - } - if (cs->numa_node =3D=3D CPU_UNSET_NUMA_NODE_ID) { - cs->numa_node =3D node_id; - } else if (cs->numa_node !=3D node_id) { - error_setg(errp, "node-id %d must match numa node specified" - "with -numa option for cpu-index %d", - cs->numa_node, cs->cpu_index); - return; - } + numa_cpu_pre_plug(cpu_slot, dev, errp); } =20 static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ab3aab1279..94563cd8f5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2922,11 +2922,9 @@ static void spapr_core_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); Error *local_err =3D NULL; CPUCore *cc =3D CPU_CORE(dev); - sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(dev); char *base_core_type =3D spapr_get_cpu_core_type(machine->cpu_model); const char *type =3D object_get_typename(OBJECT(dev)); CPUArchId *core_slot; - int node_id; int index; =20 if (dev->hotplugged && !mc->has_hotpluggable_cpus) { @@ -2967,20 +2965,7 @@ static void spapr_core_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, goto out; } =20 - node_id =3D core_slot->props.node_id; - if (!core_slot->props.has_node_id) { - /* by default CPUState::numa_node was 0 if it's not set via CLI - * keep it this way for now but in future we probably should - * refuse to start up with incomplete numa mapping */ - node_id =3D 0; - } - if (sc->node_id =3D=3D CPU_UNSET_NUMA_NODE_ID) { - sc->node_id =3D node_id; - } else if (sc->node_id !=3D node_id) { - error_setg(&local_err, "node-id %d must match numa node specified" - "with -numa option for cpu-index %d", sc->node_id, cc->core_id= ); - goto out; - } + numa_cpu_pre_plug(core_slot, dev, &local_err); =20 out: g_free(base_core_type); diff --git a/numa.c b/numa.c index be50c62aa9..1c35a79b57 100644 --- a/numa.c +++ b/numa.c @@ -533,6 +533,29 @@ 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); + + /* 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) { + error_setg(errp, "node-id=3D%d must match numa node specified " + "with -numa option", node_id); + } +} + static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, const char *name, uint64_t ram_size) --=20 2.11.0.259.g40922b1