From nobody Thu Nov 6 20:34:46 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 1487747244080948.6980767310833; Tue, 21 Feb 2017 23:07:24 -0800 (PST) Received: from localhost ([::1]:50309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgR1E-000113-Ou for importer@patchew.org; Wed, 22 Feb 2017 02:07:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQVB-00038A-AQ for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgQV8-00088q-10 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:13 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:36469) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgQV7-00081x-GJ; Wed, 22 Feb 2017 01:34:09 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vSndL2KRVz9sMh; Wed, 22 Feb 2017 17:33:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1487745238; bh=gMlJMzAhfUFu6BEQBzYE9peKlJ/ol81EXhdPQ0JX7vg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kurLNiXkL6tm3JTIt3yzxGYpPjRezdBAKK/ULD+VuwCTGBYtL2Z8XdYF1+HqGgki+ Ul/LVcdXysawLL+5pjdqtwjZVbVasLFwIEZ2KHQODK1BjhEZc4HVHuqlPsEOW1vRaF pfEaY7zdlc26a4ofW3GoLxVQSU2yCAIr/9V+jg2k= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 22 Feb 2017 17:33:39 +1100 Message-Id: <20170222063348.32176-35-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170222063348.32176-1-david@gibson.dropbear.id.au> References: <20170222063348.32176-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 34/43] pc: calculate topology only once when possible_cpus is initialised 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: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, imammedo@redhat.com, David Gibson 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 Fill in CpuInstanceProperties once at board init time and just copy them whenever query_hotpluggable_cpus() is called. It will keep topology info always available without need to recalculate it every time it's needed. Considering it has NUMA node id, it will be used to keep NUMA node to cpu mapping instead of numa_info[i].node_cpu bitmasks. Signed-off-by: Igor Mammedov Signed-off-by: David Gibson --- hw/i386/pc.c | 24 ++++++++++++------------ include/hw/boards.h | 2 ++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index a187748..50ba977 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2268,7 +2268,17 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids= (MachineState *ms) sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len =3D max_cpus; for (i =3D 0; i < ms->possible_cpus->len; i++) { + X86CPUTopoInfo topo; + ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(= i); + x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, + smp_cores, smp_threads, &topo); + ms->possible_cpus->cpus[i].props.has_socket_id =3D true; + ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; + ms->possible_cpus->cpus[i].props.has_core_id =3D true; + ms->possible_cpus->cpus[i].props.core_id =3D topo.core_id; + ms->possible_cpus->cpus[i].props.has_thread_id =3D true; + ms->possible_cpus->cpus[i].props.thread_id =3D topo.smt_id; } return ms->possible_cpus; } @@ -2285,23 +2295,13 @@ static HotpluggableCPUList *pc_query_hotpluggable_c= pus(MachineState *machine) cpu_type =3D object_class_get_name(OBJECT_CLASS(CPU_GET_CLASS(cpu))); =20 for (i =3D 0; i < machine->possible_cpus->len; i++) { - X86CPUTopoInfo topo; HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); - CpuInstanceProperties *cpu_props =3D g_new0(typeof(*cpu_props), 1); - const uint32_t apic_id =3D machine->possible_cpus->cpus[i].arch_id; - - x86_topo_ids_from_apicid(apic_id, smp_cores, smp_threads, &topo); =20 cpu_item->type =3D g_strdup(cpu_type); cpu_item->vcpus_count =3D 1; - cpu_props->has_socket_id =3D true; - cpu_props->socket_id =3D topo.pkg_id; - cpu_props->has_core_id =3D true; - cpu_props->core_id =3D topo.core_id; - cpu_props->has_thread_id =3D true; - cpu_props->thread_id =3D topo.smt_id; - cpu_item->props =3D cpu_props; + cpu_item->props =3D g_memdup(&machine->possible_cpus->cpus[i].prop= s, + sizeof(*cpu_item->props)); =20 cpu =3D machine->possible_cpus->cpus[i].cpu; if (cpu) { diff --git a/include/hw/boards.h b/include/hw/boards.h index 64e8c07..4023b38 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -46,9 +46,11 @@ void machine_register_compat_props(MachineState *machine= ); * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU * @cpu - pointer to corresponding CPU object if it's present on NULL othe= rwise + * @props - CPU object properties, initialized by board */ typedef struct { uint64_t arch_id; + CpuInstanceProperties props; struct CPUState *cpu; } CPUArchId; =20 --=20 2.9.3