From nobody Sat May 4 11:20:14 2024 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 1486638775228803.110737121701; Thu, 9 Feb 2017 03:12:55 -0800 (PST) Received: from localhost ([::1]:37012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmej-0004lg-Jd for importer@patchew.org; Thu, 09 Feb 2017 06:12:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmak-0001cV-IK for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbmaj-00042L-2a for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35170) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbmai-00041H-Pf; Thu, 09 Feb 2017 06:08:44 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B4477FB85; Thu, 9 Feb 2017 11:08:45 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19B8e6v022393; Thu, 9 Feb 2017 06:08:43 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 12:08:32 +0100 Message-Id: <1486638518-171446-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1486638518-171446-1-git-send-email-imammedo@redhat.com> References: <1486638518-171446-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 09 Feb 2017 11:08: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] [PATCH 1/7] machine: move possible_cpus to MachineState 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: drjones@redhat.com, ehabkost@redhat.com, Alexander Graf , qemu-ppc@nongnu.org, Bharata B Rao , Marcel Apfelbaum , 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" so that it would be possible to reuse it with spapr/virt-aarch64 targets. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson --- include/hw/boards.h | 1 + include/hw/i386/pc.h | 1 - hw/i386/pc.c | 57 ++++++++++++++++++++++++++----------------------= ---- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index ac891a8..64e8c07 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -178,6 +178,7 @@ struct MachineState { char *initrd_filename; const char *cpu_model; AccelState *accelerator; + CPUArchIdList *possible_cpus; }; =20 #define DEFINE_MACHINE(namestr, machine_initfn) \ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 079e8d9..d1f4554 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -73,7 +73,6 @@ struct PCMachineState { /* CPU and apic information: */ bool apic_xrupt_override; unsigned apic_id_limit; - CPUArchIdList *possible_cpus; uint16_t boot_cpus; =20 /* NUMA information: */ diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e3fcd51..cf2bec4 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -707,7 +707,8 @@ static void pc_build_smbios(PCMachineState *pcms) size_t smbios_tables_len, smbios_anchor_len; struct smbios_phys_mem_area *mem_array; unsigned i, array_count; - X86CPU *cpu =3D X86_CPU(pcms->possible_cpus->cpus[0].cpu); + MachineState *ms =3D MACHINE(pcms); + X86CPU *cpu =3D X86_CPU(ms->possible_cpus->cpus[0].cpu); =20 /* tell smbios about cpuid version and features */ smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]= ); @@ -1111,7 +1112,7 @@ static void pc_new_cpu(const char *typename, int64_t = apic_id, Error **errp) void pc_hot_add_cpu(const int64_t id, Error **errp) { ObjectClass *oc; - PCMachineState *pcms =3D PC_MACHINE(qdev_get_machine()); + MachineState *ms =3D MACHINE(qdev_get_machine()); int64_t apic_id =3D x86_cpu_apic_id_from_index(id); Error *local_err =3D NULL; =20 @@ -1127,8 +1128,8 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) return; } =20 - assert(pcms->possible_cpus->cpus[0].cpu); /* BSP is always present */ - oc =3D OBJECT_CLASS(CPU_GET_CLASS(pcms->possible_cpus->cpus[0].cpu)); + assert(ms->possible_cpus->cpus[0].cpu); /* BSP is always present */ + oc =3D OBJECT_CLASS(CPU_GET_CLASS(ms->possible_cpus->cpus[0].cpu)); pc_new_cpu(object_class_get_name(oc), apic_id, &local_err); if (local_err) { error_propagate(errp, local_err); @@ -1178,11 +1179,11 @@ void pc_cpus_init(PCMachineState *pcms) * This is used for FW_CFG_MAX_CPUS. See comments on bochs_bios_init(). */ pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(max_cpus - 1) + 1; - pcms->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + - sizeof(CPUArchId) * max_cpus); + machine->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + + sizeof(CPUArchId) * max_cpus); for (i =3D 0; i < max_cpus; i++) { - pcms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_inde= x(i); - pcms->possible_cpus->len++; + machine->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_i= ndex(i); + machine->possible_cpus->len++; if (i < smp_cpus) { pc_new_cpu(typename, x86_cpu_apic_id_from_index(i), &error_fat= al); } @@ -1191,7 +1192,8 @@ void pc_cpus_init(PCMachineState *pcms) =20 static void pc_build_feature_control_file(PCMachineState *pcms) { - X86CPU *cpu =3D X86_CPU(pcms->possible_cpus->cpus[0].cpu); + MachineState *ms =3D MACHINE(pcms); + X86CPU *cpu =3D X86_CPU(ms->possible_cpus->cpus[0].cpu); CPUX86State *env =3D &cpu->env; uint32_t unused, ecx, edx; uint64_t feature_control_bits =3D 0; @@ -1781,21 +1783,20 @@ static int pc_apic_cmp(const void *a, const void *b) } =20 /* returns pointer to CPUArchId descriptor that matches CPU's apic_id - * in pcms->possible_cpus->cpus, if pcms->possible_cpus->cpus has no + * in ms->possible_cpus->cpus, if ms->possible_cpus->cpus has no * entry corresponding to CPU's apic_id returns NULL. */ -static CPUArchId *pc_find_cpu_slot(PCMachineState *pcms, CPUState *cpu, - int *idx) +static CPUArchId *pc_find_cpu_slot(MachineState *ms, CPUState *cpu, int *i= dx) { CPUClass *cc =3D CPU_GET_CLASS(cpu); CPUArchId apic_id, *found_cpu; =20 apic_id.arch_id =3D cc->get_arch_id(CPU(cpu)); - found_cpu =3D bsearch(&apic_id, pcms->possible_cpus->cpus, - pcms->possible_cpus->len, sizeof(*pcms->possible_cpus->cpus), + found_cpu =3D bsearch(&apic_id, ms->possible_cpus->cpus, + ms->possible_cpus->len, sizeof(*ms->possible_cpus->cpus), pc_apic_cmp); if (found_cpu && idx) { - *idx =3D found_cpu - pcms->possible_cpus->cpus; + *idx =3D found_cpu - ms->possible_cpus->cpus; } return found_cpu; } @@ -1825,7 +1826,7 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); } =20 - found_cpu =3D pc_find_cpu_slot(pcms, CPU(dev), NULL); + found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), NULL); found_cpu->cpu =3D CPU(dev); out: error_propagate(errp, local_err); @@ -1838,7 +1839,7 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *= hotplug_dev, Error *local_err =3D NULL; PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 - pc_find_cpu_slot(pcms, CPU(dev), &idx); + pc_find_cpu_slot(MACHINE(pcms), CPU(dev), &idx); assert(idx !=3D -1); if (idx =3D=3D 0) { error_setg(&local_err, "Boot CPU is unpluggable"); @@ -1872,7 +1873,7 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_= dev, goto out; } =20 - found_cpu =3D pc_find_cpu_slot(pcms, CPU(dev), NULL); + found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), NULL); found_cpu->cpu =3D NULL; object_unparent(OBJECT(dev)); =20 @@ -1930,13 +1931,15 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, cpu->apic_id =3D apicid_from_topo_ids(smp_cores, smp_threads, &top= o); } =20 - cpu_slot =3D pc_find_cpu_slot(pcms, CPU(dev), &idx); + cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), &idx); if (!cpu_slot) { + MachineState *ms =3D MACHINE(pcms); + x86_topo_ids_from_apicid(cpu->apic_id, smp_cores, smp_threads, &to= po); error_setg(errp, "Invalid CPU [socket: %u, core: %u, thread: %u] w= ith" " APIC ID %" PRIu32 ", valid index range 0:%d", topo.pkg_id, topo.core_id, topo.smt_id, cpu->apic_id, - pcms->possible_cpus->len - 1); + ms->possible_cpus->len - 1); return; } =20 @@ -2247,9 +2250,8 @@ static unsigned pc_cpu_index_to_socket_id(unsigned cp= u_index) =20 static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *machine) { - PCMachineState *pcms =3D PC_MACHINE(machine); - assert(pcms->possible_cpus); - return pcms->possible_cpus; + assert(machine->possible_cpus); + return machine->possible_cpus; } =20 static HotpluggableCPUList *pc_query_hotpluggable_cpus(MachineState *machi= ne) @@ -2257,19 +2259,18 @@ static HotpluggableCPUList *pc_query_hotpluggable_c= pus(MachineState *machine) int i; CPUState *cpu; HotpluggableCPUList *head =3D NULL; - PCMachineState *pcms =3D PC_MACHINE(machine); const char *cpu_type; =20 - cpu =3D pcms->possible_cpus->cpus[0].cpu; + cpu =3D machine->possible_cpus->cpus[0].cpu; assert(cpu); /* BSP is always present */ cpu_type =3D object_class_get_name(OBJECT_CLASS(CPU_GET_CLASS(cpu))); =20 - for (i =3D 0; i < pcms->possible_cpus->len; i++) { + 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 pcms->possible_cpus->cpus[i].arch_id; + const uint32_t apic_id =3D machine->possible_cpus->cpus[i].arch_id; =20 x86_topo_ids_from_apicid(apic_id, smp_cores, smp_threads, &topo); =20 @@ -2283,7 +2284,7 @@ static HotpluggableCPUList *pc_query_hotpluggable_cpu= s(MachineState *machine) cpu_props->thread_id =3D topo.smt_id; cpu_item->props =3D cpu_props; =20 - cpu =3D pcms->possible_cpus->cpus[i].cpu; + cpu =3D machine->possible_cpus->cpus[i].cpu; if (cpu) { cpu_item->has_qom_path =3D true; cpu_item->qom_path =3D object_get_canonical_path(OBJECT(cpu)); --=20 2.7.4 From nobody Sat May 4 11:20:14 2024 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 1486638939968914.3370937085022; Thu, 9 Feb 2017 03:15:39 -0800 (PST) Received: from localhost ([::1]:37027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmhO-0006is-H7 for importer@patchew.org; Thu, 09 Feb 2017 06:15:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmam-0001cf-87 for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbmal-00045f-5G for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52882) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbmak-000445-Sp; Thu, 09 Feb 2017 06:08:47 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2169180464; Thu, 9 Feb 2017 11:08:47 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19B8e6w022393; Thu, 9 Feb 2017 06:08:45 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 12:08:33 +0100 Message-Id: <1486638518-171446-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1486638518-171446-1-git-send-email-imammedo@redhat.com> References: <1486638518-171446-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 09 Feb 2017 11:08:47 +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] [PATCH 2/7] pc: move pcms->possible_cpus init out of pc_cpus_init() 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: drjones@redhat.com, ehabkost@redhat.com, Alexander Graf , qemu-ppc@nongnu.org, Bharata B Rao , Marcel Apfelbaum , 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" possible_cpus could be initialized earlier then cpu objects, i.e. when -smp is parsed so move init code to possible_cpu_arch_ids() interface func and do initialization on the first call. it should help later with making -numa cpu/-smp parsing a machine state properties. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson --- hw/i386/pc.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index cf2bec4..a6cfc97 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1144,7 +1144,9 @@ void pc_cpus_init(PCMachineState *pcms) ObjectClass *oc; const char *typename; gchar **model_pieces; + const CPUArchIdList *possible_cpus; MachineState *machine =3D MACHINE(pcms); + MachineClass *mc =3D MACHINE_GET_CLASS(pcms); =20 /* init CPUs */ if (machine->cpu_model =3D=3D NULL) { @@ -1179,14 +1181,9 @@ void pc_cpus_init(PCMachineState *pcms) * This is used for FW_CFG_MAX_CPUS. See comments on bochs_bios_init(). */ pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(max_cpus - 1) + 1; - machine->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + - sizeof(CPUArchId) * max_cpus); - for (i =3D 0; i < max_cpus; i++) { - machine->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_i= ndex(i); - machine->possible_cpus->len++; - if (i < smp_cpus) { - pc_new_cpu(typename, x86_cpu_apic_id_from_index(i), &error_fat= al); - } + possible_cpus =3D mc->possible_cpu_arch_ids(machine); + for (i =3D 0; i < smp_cpus; i++) { + pc_new_cpu(typename, possible_cpus->cpus[i].arch_id, &error_fatal); } } =20 @@ -2248,10 +2245,26 @@ static unsigned pc_cpu_index_to_socket_id(unsigned = cpu_index) return topo.pkg_id; } =20 -static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *machine) +static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *ms) { - assert(machine->possible_cpus); - return machine->possible_cpus; + int i; + + if (ms->possible_cpus) { + /* + * make sure that max_cpus hasn't changed since the first use, i.e. + * -smp hasn't been parsed after it + */ + assert(ms->possible_cpus->len =3D=3D max_cpus); + return ms->possible_cpus; + } + + ms->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + + sizeof(CPUArchId) * max_cpus); + ms->possible_cpus->len =3D max_cpus; + for (i =3D 0; i < ms->possible_cpus->len; i++) { + ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(= i); + } + return ms->possible_cpus; } =20 static HotpluggableCPUList *pc_query_hotpluggable_cpus(MachineState *machi= ne) --=20 2.7.4 From nobody Sat May 4 11:20:14 2024 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 1486638616326365.395819674995; Thu, 9 Feb 2017 03:10:16 -0800 (PST) Received: from localhost ([::1]:36996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmcA-0002S1-33 for importer@patchew.org; Thu, 09 Feb 2017 06:10:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmao-0001di-22 for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbman-00049F-3q for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbmam-00047f-S8; Thu, 09 Feb 2017 06:08:49 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A04DC05AA42; Thu, 9 Feb 2017 11:08:49 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19B8e6x022393; Thu, 9 Feb 2017 06:08:47 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 12:08:34 +0100 Message-Id: <1486638518-171446-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1486638518-171446-1-git-send-email-imammedo@redhat.com> References: <1486638518-171446-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 09 Feb 2017 11:08:49 +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] [PATCH 3/7] 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: drjones@redhat.com, ehabkost@redhat.com, Alexander Graf , qemu-ppc@nongnu.org, Bharata B Rao , Marcel Apfelbaum , 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" 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 Reviewed-by: David Gibson --- include/hw/boards.h | 2 ++ hw/i386/pc.c | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) 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 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index a6cfc97..f03a555 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2262,7 +2262,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; } @@ -2279,23 +2289,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) { --=20 2.7.4 From nobody Sat May 4 11:20:14 2024 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 148663880528748.20864404721465; Thu, 9 Feb 2017 03:13:25 -0800 (PST) Received: from localhost ([::1]:37013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmfD-000572-Vy for importer@patchew.org; Thu, 09 Feb 2017 06:13:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmaq-0001fd-8a for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbmap-0004EU-2l for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51684) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbmao-0004D3-Qi; Thu, 09 Feb 2017 06:08:51 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CE6F61B90; Thu, 9 Feb 2017 11:08:51 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19B8e70022393; Thu, 9 Feb 2017 06:08:49 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 12:08:35 +0100 Message-Id: <1486638518-171446-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1486638518-171446-1-git-send-email-imammedo@redhat.com> References: <1486638518-171446-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 09 Feb 2017 11:08:51 +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] [PATCH 4/7] pc: pass apic_id to pc_find_cpu_slot() directly so lookup could be done without CPU object 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: drjones@redhat.com, ehabkost@redhat.com, Alexander Graf , qemu-ppc@nongnu.org, Bharata B Rao , Marcel Apfelbaum , 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" Signed-off-by: Igor Mammedov Reviewed-by: David Gibson --- hw/i386/pc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f03a555..ec6dded 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1783,12 +1783,11 @@ static int pc_apic_cmp(const void *a, const void *b) * in ms->possible_cpus->cpus, if ms->possible_cpus->cpus has no * entry corresponding to CPU's apic_id returns NULL. */ -static CPUArchId *pc_find_cpu_slot(MachineState *ms, CPUState *cpu, int *i= dx) +static CPUArchId *pc_find_cpu_slot(MachineState *ms, uint32_t id, int *idx) { - CPUClass *cc =3D CPU_GET_CLASS(cpu); CPUArchId apic_id, *found_cpu; =20 - apic_id.arch_id =3D cc->get_arch_id(CPU(cpu)); + apic_id.arch_id =3D id; found_cpu =3D bsearch(&apic_id, ms->possible_cpus->cpus, ms->possible_cpus->len, sizeof(*ms->possible_cpus->cpus), pc_apic_cmp); @@ -1804,6 +1803,7 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, CPUArchId *found_cpu; HotplugHandlerClass *hhc; Error *local_err =3D NULL; + X86CPU *cpu =3D X86_CPU(dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 if (pcms->acpi_dev) { @@ -1823,7 +1823,7 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); } =20 - found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), NULL); + found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, NULL); found_cpu->cpu =3D CPU(dev); out: error_propagate(errp, local_err); @@ -1834,9 +1834,10 @@ static void pc_cpu_unplug_request_cb(HotplugHandler = *hotplug_dev, int idx =3D -1; HotplugHandlerClass *hhc; Error *local_err =3D NULL; + X86CPU *cpu =3D X86_CPU(dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 - pc_find_cpu_slot(MACHINE(pcms), CPU(dev), &idx); + pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); assert(idx !=3D -1); if (idx =3D=3D 0) { error_setg(&local_err, "Boot CPU is unpluggable"); @@ -1861,6 +1862,7 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_= dev, CPUArchId *found_cpu; HotplugHandlerClass *hhc; Error *local_err =3D NULL; + X86CPU *cpu =3D X86_CPU(dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 hhc =3D HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); @@ -1870,7 +1872,7 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_= dev, goto out; } =20 - found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), NULL); + found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, NULL); found_cpu->cpu =3D NULL; object_unparent(OBJECT(dev)); =20 @@ -1928,7 +1930,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, cpu->apic_id =3D apicid_from_topo_ids(smp_cores, smp_threads, &top= o); } =20 - cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), CPU(dev), &idx); + cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); if (!cpu_slot) { MachineState *ms =3D MACHINE(pcms); =20 --=20 2.7.4 From nobody Sat May 4 11:20:14 2024 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 1486638972548426.2524671668166; Thu, 9 Feb 2017 03:16:12 -0800 (PST) Received: from localhost ([::1]:37028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmhv-00073G-Db for importer@patchew.org; Thu, 09 Feb 2017 06:16:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmat-0001iW-Bo for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbmar-0004I9-0B for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35184) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbmaq-0004Gy-RY; Thu, 09 Feb 2017 06:08:52 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17FA7804FB; Thu, 9 Feb 2017 11:08:53 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19B8e71022393; Thu, 9 Feb 2017 06:08:51 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 12:08:36 +0100 Message-Id: <1486638518-171446-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1486638518-171446-1-git-send-email-imammedo@redhat.com> References: <1486638518-171446-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 09 Feb 2017 11:08:53 +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] [PATCH 5/7] change CPUArchId.cpu type to Object* 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: drjones@redhat.com, ehabkost@redhat.com, Alexander Graf , qemu-ppc@nongnu.org, Bharata B Rao , Marcel Apfelbaum , 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" so it could be reused for SPAPR cores as well Signed-off-by: Igor Mammedov Reviewed-by: David Gibson --- include/hw/boards.h | 2 +- hw/acpi/cpu.c | 2 +- hw/i386/pc.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 4023b38..60209df 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -51,7 +51,7 @@ void machine_register_compat_props(MachineState *machine); typedef struct { uint64_t arch_id; CpuInstanceProperties props; - struct CPUState *cpu; + Object *cpu; } CPUArchId; =20 /** diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 6017ca0..8c719d3 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -198,7 +198,7 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owne= r, state->dev_count =3D id_list->len; state->devs =3D g_new0(typeof(*state->devs), state->dev_count); for (i =3D 0; i < id_list->len; i++) { - state->devs[i].cpu =3D id_list->cpus[i].cpu; + state->devs[i].cpu =3D CPU(id_list->cpus[i].cpu); state->devs[i].arch_id =3D id_list->cpus[i].arch_id; } memory_region_init_io(&state->ctrl_reg, owner, &cpu_hotplug_ops, state, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index ec6dded..afaae15 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1824,7 +1824,7 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, } =20 found_cpu =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, NULL); - found_cpu->cpu =3D CPU(dev); + found_cpu->cpu =3D OBJECT(dev); out: error_propagate(errp, local_err); } @@ -2282,13 +2282,13 @@ static const CPUArchIdList *pc_possible_cpu_arch_id= s(MachineState *ms) static HotpluggableCPUList *pc_query_hotpluggable_cpus(MachineState *machi= ne) { int i; - CPUState *cpu; + Object *cpu; HotpluggableCPUList *head =3D NULL; const char *cpu_type; =20 cpu =3D machine->possible_cpus->cpus[0].cpu; assert(cpu); /* BSP is always present */ - cpu_type =3D object_class_get_name(OBJECT_CLASS(CPU_GET_CLASS(cpu))); + cpu_type =3D object_get_typename(cpu); =20 for (i =3D 0; i < machine->possible_cpus->len; i++) { HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); @@ -2302,7 +2302,7 @@ static HotpluggableCPUList *pc_query_hotpluggable_cpu= s(MachineState *machine) cpu =3D machine->possible_cpus->cpus[i].cpu; if (cpu) { cpu_item->has_qom_path =3D true; - cpu_item->qom_path =3D object_get_canonical_path(OBJECT(cpu)); + cpu_item->qom_path =3D object_get_canonical_path(cpu); } =20 list_item->value =3D cpu_item; --=20 2.7.4 From nobody Sat May 4 11:20:14 2024 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 1486639147864766.3947695790167; Thu, 9 Feb 2017 03:19:07 -0800 (PST) Received: from localhost ([::1]:37040 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmkk-0000uf-GY for importer@patchew.org; Thu, 09 Feb 2017 06:19:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmau-0001ju-NP for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbmas-0004KU-Uc for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbmas-0004JM-Mb; Thu, 09 Feb 2017 06:08:54 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3D3780482; Thu, 9 Feb 2017 11:08:54 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19B8e72022393; Thu, 9 Feb 2017 06:08:53 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 12:08:37 +0100 Message-Id: <1486638518-171446-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1486638518-171446-1-git-send-email-imammedo@redhat.com> References: <1486638518-171446-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 09 Feb 2017 11:08:54 +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] [PATCH 6/7] spapr: reuse machine->possible_cpus instead of cores[] 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: drjones@redhat.com, ehabkost@redhat.com, Alexander Graf , qemu-ppc@nongnu.org, Bharata B Rao , Marcel Apfelbaum , 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" Replace SPAPR specific cores[] array with generic machine->possible_cpus and store core objects there. It makes cores bookkeeping similar to x86 cpus and will allow to unify similar code. It would allow to replace cpu_index based NUMA node mapping with iproperty based one (for -device created cores) since possible_cpus carries board defined topology/layout. Signed-off-by: Igor Mammedov Acked-by: David Gibson --- include/hw/ppc/spapr.h | 1 - hw/ppc/spapr.c | 129 ++++++++++++++++++++++++++++++++++-----------= ---- 2 files changed, 90 insertions(+), 40 deletions(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index a2d8964..f9b17d8 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -94,7 +94,6 @@ struct sPAPRMachineState { /*< public >*/ char *kvm_type; MemoryHotplugState hotplug_memory; - Object **cores; }; =20 #define H_SUCCESS 0 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 37cb338..8d039ae 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1751,13 +1751,28 @@ static void spapr_validate_node_memory(MachineState= *machine, Error **errp) } } =20 +/* find cpu slot in machine->possible_cpus by core_id */ +static CPUArchId *spapr_find_cpu_slot(MachineState *ms, uint32_t id, int *= idx) +{ + int index =3D id / smp_threads; + + if (index >=3D ms->possible_cpus->len) { + return NULL; + } + if (idx) { + *idx =3D index; + } + return &ms->possible_cpus->cpus[index]; +} + static void spapr_init_cpus(sPAPRMachineState *spapr) { MachineState *machine =3D MACHINE(spapr); MachineClass *mc =3D MACHINE_GET_CLASS(machine); char *type =3D spapr_get_cpu_core_type(machine->cpu_model); int smt =3D kvmppc_smt_threads(); - int spapr_max_cores, spapr_cores; + const CPUArchIdList *possible_cpus; + int boot_cores_nr =3D smp_cpus / smp_threads;; int i; =20 if (!type) { @@ -1765,6 +1780,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) exit(1); } =20 + possible_cpus =3D mc->possible_cpu_arch_ids(machine); if (mc->query_hotpluggable_cpus) { if (smp_cpus % smp_threads) { error_report("smp_cpus (%u) must be multiple of threads (%u)", @@ -1776,21 +1792,15 @@ static void spapr_init_cpus(sPAPRMachineState *spap= r) max_cpus, smp_threads); exit(1); } - - spapr_max_cores =3D max_cpus / smp_threads; - spapr_cores =3D smp_cpus / smp_threads; } else { if (max_cpus !=3D smp_cpus) { error_report("This machine version does not support CPU hotplu= g"); exit(1); } - - spapr_max_cores =3D QEMU_ALIGN_UP(smp_cpus, smp_threads) / smp_thr= eads; - spapr_cores =3D spapr_max_cores; + boot_cores_nr =3D possible_cpus->len; } =20 - spapr->cores =3D g_new0(Object *, spapr_max_cores); - for (i =3D 0; i < spapr_max_cores; i++) { + for (i =3D 0; i < possible_cpus->len; i++) { int core_id =3D i * smp_threads; =20 if (mc->query_hotpluggable_cpus) { @@ -1802,7 +1812,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) qemu_register_reset(spapr_drc_reset, drc); } =20 - if (i < spapr_cores) { + if (i < boot_cores_nr) { Object *core =3D object_new(type); int nr_threads =3D smp_threads; =20 @@ -2491,10 +2501,11 @@ void *spapr_populate_hotplug_cpu_dt(CPUState *cs, i= nt *fdt_offset, static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *de= v, Error **errp) { - sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + MachineState *ms =3D MACHINE(qdev_get_machine()); CPUCore *cc =3D CPU_CORE(dev); + CPUArchId *core_slot =3D spapr_find_cpu_slot(ms, cc->core_id, NULL); =20 - spapr->cores[cc->core_id / smp_threads] =3D NULL; + core_slot->cpu =3D NULL; object_unparent(OBJECT(dev)); } =20 @@ -2510,19 +2521,24 @@ static void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *d= ev, Error **errp) { - CPUCore *cc =3D CPU_CORE(dev); - int smt =3D kvmppc_smt_threads(); - int index =3D cc->core_id / smp_threads; - sPAPRDRConnector *drc =3D - spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * smt); + int index; + sPAPRDRConnector *drc; sPAPRDRConnectorClass *drck; Error *local_err =3D NULL; + CPUCore *cc =3D CPU_CORE(dev); + int smt =3D kvmppc_smt_threads(); =20 + if (!spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index)) { + error_setg(errp, "Unable to find CPU core with core-id: %d", + cc->core_id); + return; + } if (index =3D=3D 0) { error_setg(errp, "Boot CPU core may not be unplugged"); return; } =20 + drc =3D spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * = smt); g_assert(drc); =20 drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); @@ -2547,11 +2563,17 @@ static void spapr_core_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, Error *local_err =3D NULL; void *fdt =3D NULL; int fdt_offset =3D 0; - int index =3D cc->core_id / smp_threads; int smt =3D kvmppc_smt_threads(); + CPUArchId *core_slot; + int index; =20 + core_slot =3D spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &= index); + if (!core_slot) { + error_setg(errp, "Unable to find CPU core with core-id: %d", + cc->core_id); + return; + } drc =3D spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * = smt); - spapr->cores[index] =3D OBJECT(dev); =20 g_assert(drc || !mc->query_hotpluggable_cpus); =20 @@ -2568,7 +2590,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, &local_e= rr); if (local_err) { g_free(fdt); - spapr->cores[index] =3D NULL; error_propagate(errp, local_err); return; } @@ -2590,6 +2611,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOL= ATED); } } + core_slot->cpu =3D OBJECT(dev); } =20 static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *= dev, @@ -2597,13 +2619,12 @@ static void spapr_core_pre_plug(HotplugHandler *hot= plug_dev, DeviceState *dev, { MachineState *machine =3D MACHINE(OBJECT(hotplug_dev)); MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); - sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); - int spapr_max_cores =3D max_cpus / smp_threads; - int index; Error *local_err =3D NULL; CPUCore *cc =3D 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 index; =20 if (dev->hotplugged && !mc->query_hotpluggable_cpus) { error_setg(&local_err, "CPU hotplug not supported for this machine= "); @@ -2620,13 +2641,13 @@ static void spapr_core_pre_plug(HotplugHandler *hot= plug_dev, DeviceState *dev, goto out; } =20 - index =3D cc->core_id / smp_threads; - if (index < 0 || index >=3D spapr_max_cores) { + core_slot =3D spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &= index); + if (!core_slot) { error_setg(&local_err, "core id %d out of range", cc->core_id); goto out; } =20 - if (spapr->cores[index]) { + if (core_slot->cpu) { error_setg(&local_err, "core %d already populated", cc->core_id); goto out; } @@ -2758,29 +2779,58 @@ static unsigned spapr_cpu_index_to_socket_id(unsign= ed cpu_index) return cpu_index / smp_threads / smp_cores; } =20 +static const CPUArchIdList *spapr_possible_cpu_arch_ids(MachineState *mach= ine) +{ + int i; + int spapr_max_cores =3D max_cpus / smp_threads; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + + if (!mc->query_hotpluggable_cpus) { + spapr_max_cores =3D QEMU_ALIGN_UP(smp_cpus, smp_threads) / smp_thr= eads; + } + if (machine->possible_cpus) { + assert(machine->possible_cpus->len =3D=3D spapr_max_cores); + return machine->possible_cpus; + } + + machine->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + + sizeof(CPUArchId) * spapr_max_cores); + machine->possible_cpus->len =3D spapr_max_cores; + for (i =3D 0; i < machine->possible_cpus->len; i++) { + int core_id =3D i * smp_threads; + + machine->possible_cpus->cpus[i].arch_id =3D core_id; + machine->possible_cpus->cpus[i].props.has_core_id =3D true; + machine->possible_cpus->cpus[i].props.core_id =3D core_id; + /* TODO: add 'has_node/node' here to describe + to which node core belongs */ + } + return machine->possible_cpus; +} + static HotpluggableCPUList *spapr_query_hotpluggable_cpus(MachineState *ma= chine) { int i; + Object *cpu; HotpluggableCPUList *head =3D NULL; - sPAPRMachineState *spapr =3D SPAPR_MACHINE(machine); - int spapr_max_cores =3D max_cpus / smp_threads; + const char *cpu_type; =20 - for (i =3D 0; i < spapr_max_cores; i++) { + cpu =3D machine->possible_cpus->cpus[0].cpu; + assert(cpu); /* Boot cpu is always present */ + cpu_type =3D object_get_typename(cpu); + for (i =3D 0; i < machine->possible_cpus->len; i++) { 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); =20 - cpu_item->type =3D spapr_get_cpu_core_type(machine->cpu_model); - cpu_item->vcpus_count =3D smp_threads; - cpu_props->has_core_id =3D true; - cpu_props->core_id =3D i * smp_threads; - /* TODO: add 'has_node/node' here to describe - to which node core belongs */ + cpu_item->type =3D g_strdup(cpu_type); + cpu_item->vcpus_count =3D smp_threads; // TODO: ??? generalize + cpu_item->props =3D g_memdup(&machine->possible_cpus->cpus[i].prop= s, + sizeof(*cpu_item->props)); =20 - cpu_item->props =3D cpu_props; - if (spapr->cores[i]) { + cpu =3D machine->possible_cpus->cpus[i].cpu; + if (cpu) { cpu_item->has_qom_path =3D true; - cpu_item->qom_path =3D object_get_canonical_path(spapr->cores[= i]); + cpu_item->qom_path =3D object_get_canonical_path(cpu); } list_item->value =3D cpu_item; list_item->next =3D head; @@ -2872,6 +2922,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) hc->plug =3D spapr_machine_device_plug; hc->unplug =3D spapr_machine_device_unplug; mc->cpu_index_to_socket_id =3D spapr_cpu_index_to_socket_id; + mc->possible_cpu_arch_ids =3D spapr_possible_cpu_arch_ids; hc->unplug_request =3D spapr_machine_device_unplug_request; =20 smc->dr_lmb_enabled =3D true; --=20 2.7.4 From nobody Sat May 4 11:20:14 2024 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 1486639146086976.912316970514; Thu, 9 Feb 2017 03:19:06 -0800 (PST) Received: from localhost ([::1]:37039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmki-0000t2-Bk for importer@patchew.org; Thu, 09 Feb 2017 06:19:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbmaw-0001m6-Qb for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:09:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbmav-0004Nx-BM for qemu-devel@nongnu.org; Thu, 09 Feb 2017 06:08:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36864) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbmau-0004MG-Kv; Thu, 09 Feb 2017 06:08:57 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEFA3C0016A9; Thu, 9 Feb 2017 11:08:56 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19B8e73022393; Thu, 9 Feb 2017 06:08:55 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 12:08:38 +0100 Message-Id: <1486638518-171446-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1486638518-171446-1-git-send-email-imammedo@redhat.com> References: <1486638518-171446-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 09 Feb 2017 11:08:56 +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] [PATCH 7/7] machine: unify [pc_|spapr_]query_hotpluggable_cpus() callbacks 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: drjones@redhat.com, ehabkost@redhat.com, Alexander Graf , qemu-ppc@nongnu.org, Bharata B Rao , Marcel Apfelbaum , 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" All callbacks FOO_query_hotpluggable_cpus() are practically the same except of setting vcpus_count to different values. Convert them to a generic machine_query_hotpluggable_cpus() callback by moving vcpus_count initialization to per machine specific callback possible_cpu_arch_ids(). Signed-off-by: Igor Mammedov Reviewed-by: David Gibson --- include/hw/boards.h | 3 +++ hw/core/machine.c | 31 +++++++++++++++++++++++++++++++ hw/i386/pc.c | 36 ++---------------------------------- hw/ppc/spapr.c | 34 ++-------------------------------- 4 files changed, 38 insertions(+), 66 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 60209df..9040dbb 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -41,15 +41,18 @@ int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); void machine_register_compat_props(MachineState *machine); +HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine= ); =20 /** * 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 + * #vcpus_count - number of threads provided by @cpu object */ typedef struct { uint64_t arch_id; + int64_t vcpus_count; CpuInstanceProperties props; Object *cpu; } CPUArchId; diff --git a/hw/core/machine.c b/hw/core/machine.c index b0fd91f..0699750 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -357,6 +357,37 @@ static void machine_init_notify(Notifier *notifier, vo= id *data) foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); } =20 +HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) +{ + int i; + Object *cpu; + HotpluggableCPUList *head =3D NULL; + const char *cpu_type; + + cpu =3D machine->possible_cpus->cpus[0].cpu; + assert(cpu); /* Boot cpu is always present */ + cpu_type =3D object_get_typename(cpu); + for (i =3D 0; i < machine->possible_cpus->len; i++) { + HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); + HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); + + cpu_item->type =3D g_strdup(cpu_type); + cpu_item->vcpus_count =3D machine->possible_cpus->cpus[i].vcpus_co= unt; + cpu_item->props =3D g_memdup(&machine->possible_cpus->cpus[i].prop= s, + sizeof(*cpu_item->props)); + + cpu =3D machine->possible_cpus->cpus[i].cpu; + if (cpu) { + cpu_item->has_qom_path =3D true; + cpu_item->qom_path =3D object_get_canonical_path(cpu); + } + list_item->value =3D cpu_item; + list_item->next =3D head; + head =3D list_item; + } + return head; +} + static void machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index afaae15..548628f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2266,6 +2266,7 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(= MachineState *ms) for (i =3D 0; i < ms->possible_cpus->len; i++) { X86CPUTopoInfo topo; =20 + ms->possible_cpus->cpus[i].vcpus_count =3D 1; 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); @@ -2279,39 +2280,6 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids= (MachineState *ms) return ms->possible_cpus; } =20 -static HotpluggableCPUList *pc_query_hotpluggable_cpus(MachineState *machi= ne) -{ - int i; - Object *cpu; - HotpluggableCPUList *head =3D NULL; - const char *cpu_type; - - cpu =3D machine->possible_cpus->cpus[0].cpu; - assert(cpu); /* BSP is always present */ - cpu_type =3D object_get_typename(cpu); - - for (i =3D 0; i < machine->possible_cpus->len; i++) { - HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); - HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); - - cpu_item->type =3D g_strdup(cpu_type); - cpu_item->vcpus_count =3D 1; - cpu_item->props =3D g_memdup(&machine->possible_cpus->cpus[i].prop= s, - sizeof(*cpu_item->props)); - - cpu =3D machine->possible_cpus->cpus[i].cpu; - if (cpu) { - cpu_item->has_qom_path =3D true; - cpu_item->qom_path =3D object_get_canonical_path(cpu); - } - - list_item->value =3D cpu_item; - list_item->next =3D head; - head =3D list_item; - } - return head; -} - static void x86_nmi(NMIState *n, int cpu_index, Error **errp) { /* cpu index isn't used */ @@ -2352,7 +2320,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) mc->get_hotplug_handler =3D pc_get_hotpug_handler; mc->cpu_index_to_socket_id =3D pc_cpu_index_to_socket_id; mc->possible_cpu_arch_ids =3D pc_possible_cpu_arch_ids; - mc->query_hotpluggable_cpus =3D pc_query_hotpluggable_cpus; + mc->query_hotpluggable_cpus =3D machine_query_hotpluggable_cpus; mc->default_boot_order =3D "cad"; mc->hot_add_cpu =3D pc_hot_add_cpu; mc->max_cpus =3D 255; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8d039ae..3c4d632 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2799,6 +2799,7 @@ static const CPUArchIdList *spapr_possible_cpu_arch_i= ds(MachineState *machine) for (i =3D 0; i < machine->possible_cpus->len; i++) { int core_id =3D i * smp_threads; =20 + machine->possible_cpus->cpus[i].vcpus_count =3D smp_threads; machine->possible_cpus->cpus[i].arch_id =3D core_id; machine->possible_cpus->cpus[i].props.has_core_id =3D true; machine->possible_cpus->cpus[i].props.core_id =3D core_id; @@ -2808,37 +2809,6 @@ static const CPUArchIdList *spapr_possible_cpu_arch_= ids(MachineState *machine) return machine->possible_cpus; } =20 -static HotpluggableCPUList *spapr_query_hotpluggable_cpus(MachineState *ma= chine) -{ - int i; - Object *cpu; - HotpluggableCPUList *head =3D NULL; - const char *cpu_type; - - cpu =3D machine->possible_cpus->cpus[0].cpu; - assert(cpu); /* Boot cpu is always present */ - cpu_type =3D object_get_typename(cpu); - for (i =3D 0; i < machine->possible_cpus->len; i++) { - HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); - HotpluggableCPU *cpu_item =3D g_new0(typeof(*cpu_item), 1); - - cpu_item->type =3D g_strdup(cpu_type); - cpu_item->vcpus_count =3D smp_threads; // TODO: ??? generalize - cpu_item->props =3D g_memdup(&machine->possible_cpus->cpus[i].prop= s, - sizeof(*cpu_item->props)); - - cpu =3D machine->possible_cpus->cpus[i].cpu; - if (cpu) { - cpu_item->has_qom_path =3D true; - cpu_item->qom_path =3D object_get_canonical_path(cpu); - } - list_item->value =3D cpu_item; - list_item->next =3D head; - head =3D list_item; - } - return head; -} - static void spapr_phb_placement(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio, hwaddr *mmio32, hwaddr *mmio64, @@ -2927,7 +2897,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) =20 smc->dr_lmb_enabled =3D true; smc->tcg_default_cpu =3D "POWER8"; - mc->query_hotpluggable_cpus =3D spapr_query_hotpluggable_cpus; + mc->query_hotpluggable_cpus =3D machine_query_hotpluggable_cpus; fwc->get_dev_path =3D spapr_get_fw_dev_path; nc->nmi_monitor_handler =3D spapr_nmi; smc->phb_placement =3D spapr_phb_placement; --=20 2.7.4 From nobody Sat May 4 11:20:14 2024 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 1486722131940925.6146719605127; Fri, 10 Feb 2017 02:22:11 -0800 (PST) Received: from localhost ([::1]:42931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc8LC-0000NV-Gc for importer@patchew.org; Fri, 10 Feb 2017 05:22:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc8K9-0008OE-DR for qemu-devel@nongnu.org; Fri, 10 Feb 2017 05:21:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cc8K5-00060G-Bk for qemu-devel@nongnu.org; Fri, 10 Feb 2017 05:21:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44028) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cc8K5-0005zp-2b; Fri, 10 Feb 2017 05:21:01 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FCCE7FB84; Fri, 10 Feb 2017 10:21:01 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1AAKxbi028682; Fri, 10 Feb 2017 05:20:59 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 10 Feb 2017 11:20:57 +0100 Message-Id: <1486722057-180456-1-git-send-email-imammedo@redhat.com> In-Reply-To: <1486638518-171446-1-git-send-email-imammedo@redhat.com> References: <1486638518-171446-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 10 Feb 2017 10:21:01 +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] [PATCH v2 8/7] machine: replace query_hotpluggable_cpus() callback with has_hotpluggable_cpus flag 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: drjones@redhat.com, ehabkost@redhat.com, Alexander Graf , qemu-ppc@nongnu.org, Bharata B Rao , Marcel Apfelbaum , 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" Generic helper machine_query_hotpluggable_cpus() replaced target specific query_hotpluggable_cpus() callbacks so there is no need in it anymore. However inon NULL callback value is used to detect/report hotpluggable cpus support, therefore it can be removed completely. Replace it with MachineClass.has_hotpluggable_cpus boolean which is sufficient for the task. Suggested-by: David Gibson Signed-off-by: Igor Mammedov --- CC: David Gibson (supporter:sPAPR) CC: Alexander Graf (supporter:sPAPR) CC: qemu-ppc@nongnu.org=20 CC: Bharata B Rao CC: ehabkost@redhat.com CC: drjones@redhat.com CC: Marcel Apfelbaum --- include/hw/boards.h | 8 +++----- hw/i386/pc.c | 4 ++-- hw/ppc/spapr.c | 20 ++++++++++---------- monitor.c | 4 ++-- vl.c | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 9040dbb..269d0ba 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -87,10 +87,8 @@ typedef struct { * Returns an array of @CPUArchId architecture-dependent CPU IDs * which includes CPU IDs for present and possible to hotplug CPUs. * Caller is responsible for freeing returned list. - * @query_hotpluggable_cpus: - * Returns a @HotpluggableCPUList, which describes CPUs objects which - * could be added with -device/device_add. - * Caller is responsible for freeing returned list. + * @has_hotpluggable_cpus: + * If true, board supports CPUs creation with -device/device_add. * @minimum_page_bits: * If non-zero, the board promises never to create a CPU with a page si= ze * smaller than this, so QEMU can use a more efficient larger page @@ -136,12 +134,12 @@ struct MachineClass { bool option_rom_has_mr; bool rom_file_has_mr; int minimum_page_bits; + bool has_hotpluggable_cpus; =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); unsigned (*cpu_index_to_socket_id)(unsigned cpu_index); const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); - HotpluggableCPUList *(*query_hotpluggable_cpus)(MachineState *machine); }; =20 /** diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 548628f..a8660d4 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1949,7 +1949,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, } =20 /* if 'address' properties socket-id/core-id/thread-id are not set, se= t them - * so that query_hotpluggable_cpus would show correct values + * so that machine_query_hotpluggable_cpus would show correct values */ /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizef= n() * once -smp refactoring is complete and there will be CPU private @@ -2320,7 +2320,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) mc->get_hotplug_handler =3D pc_get_hotpug_handler; mc->cpu_index_to_socket_id =3D pc_cpu_index_to_socket_id; mc->possible_cpu_arch_ids =3D pc_possible_cpu_arch_ids; - mc->query_hotpluggable_cpus =3D machine_query_hotpluggable_cpus; + mc->has_hotpluggable_cpus =3D true; mc->default_boot_order =3D "cad"; mc->hot_add_cpu =3D pc_hot_add_cpu; mc->max_cpus =3D 255; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 49768eb..6f37288 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -958,7 +958,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, _FDT(spapr_drc_populate_dt(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYPE_L= MB)); } =20 - if (mc->query_hotpluggable_cpus) { + if (mc->has_hotpluggable_cpus) { int offset =3D fdt_path_offset(fdt, "/cpus"); ret =3D spapr_drc_populate_dt(fdt, offset, NULL, SPAPR_DR_CONNECTOR_TYPE_CPU); @@ -1781,7 +1781,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) } =20 possible_cpus =3D mc->possible_cpu_arch_ids(machine); - if (mc->query_hotpluggable_cpus) { + if (mc->has_hotpluggable_cpus) { if (smp_cpus % smp_threads) { error_report("smp_cpus (%u) must be multiple of threads (%u)", smp_cpus, smp_threads); @@ -1803,7 +1803,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) for (i =3D 0; i < possible_cpus->len; i++) { int core_id =3D i * smp_threads; =20 - if (mc->query_hotpluggable_cpus) { + if (mc->has_hotpluggable_cpus) { sPAPRDRConnector *drc =3D spapr_dr_connector_new(OBJECT(spapr), SPAPR_DR_CONNECTOR_TYPE_CPU, @@ -2575,7 +2575,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, } drc =3D spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * = smt); =20 - g_assert(drc || !mc->query_hotpluggable_cpus); + g_assert(drc || !mc->has_hotpluggable_cpus); =20 /* * Setup CPU DT entries only for hotplugged CPUs. For boot time or @@ -2626,7 +2626,7 @@ static void spapr_core_pre_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, CPUArchId *core_slot; int index; =20 - if (dev->hotplugged && !mc->query_hotpluggable_cpus) { + if (dev->hotplugged && !mc->has_hotpluggable_cpus) { error_setg(&local_err, "CPU hotplug not supported for this machine= "); goto out; } @@ -2719,7 +2719,7 @@ static void spapr_machine_device_unplug(HotplugHandle= r *hotplug_dev, error_setg(errp, "Memory hot unplug not supported for this gue= st"); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { - if (!mc->query_hotpluggable_cpus) { + if (!mc->has_hotpluggable_cpus) { error_setg(errp, "CPU hot unplug not supported on this machine= "); return; } @@ -2746,7 +2746,7 @@ static void spapr_machine_device_unplug_request(Hotpl= ugHandler *hotplug_dev, error_setg(errp, "Memory hot unplug not supported for this gue= st"); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { - if (!mc->query_hotpluggable_cpus) { + if (!mc->has_hotpluggable_cpus) { error_setg(errp, "CPU hot unplug not supported on this machine= "); return; } @@ -2785,7 +2785,7 @@ static const CPUArchIdList *spapr_possible_cpu_arch_i= ds(MachineState *machine) int spapr_max_cores =3D max_cpus / smp_threads; MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 - if (!mc->query_hotpluggable_cpus) { + if (!mc->has_hotpluggable_cpus) { spapr_max_cores =3D QEMU_ALIGN_UP(smp_cpus, smp_threads) / smp_thr= eads; } if (machine->possible_cpus) { @@ -2897,7 +2897,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) =20 smc->dr_lmb_enabled =3D true; smc->tcg_default_cpu =3D "POWER8"; - mc->query_hotpluggable_cpus =3D machine_query_hotpluggable_cpus; + mc->has_hotpluggable_cpus =3D true; fwc->get_dev_path =3D spapr_get_fw_dev_path; nc->nmi_monitor_handler =3D spapr_nmi; smc->phb_placement =3D spapr_phb_placement; @@ -3097,7 +3097,7 @@ static void spapr_machine_2_6_instance_options(Machin= eState *machine) static void spapr_machine_2_6_class_options(MachineClass *mc) { spapr_machine_2_7_class_options(mc); - mc->query_hotpluggable_cpus =3D NULL; + mc->has_hotpluggable_cpus =3D false; SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_6); } =20 diff --git a/monitor.c b/monitor.c index 3cd72a9..18bf2f8 100644 --- a/monitor.c +++ b/monitor.c @@ -4155,10 +4155,10 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Er= ror **errp) MachineState *ms =3D MACHINE(qdev_get_machine()); MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 - if (!mc->query_hotpluggable_cpus) { + if (!mc->has_hotpluggable_cpus) { error_setg(errp, QERR_FEATURE_DISABLED, "query-hotpluggable-cpus"); return NULL; } =20 - return mc->query_hotpluggable_cpus(ms); + return machine_query_hotpluggable_cpus(ms); } diff --git a/vl.c b/vl.c index b4eaf03..93406ba 100644 --- a/vl.c +++ b/vl.c @@ -1519,7 +1519,7 @@ MachineInfoList *qmp_query_machines(Error **errp) =20 info->name =3D g_strdup(mc->name); info->cpu_max =3D !mc->max_cpus ? 1 : mc->max_cpus; - info->hotpluggable_cpus =3D !!mc->query_hotpluggable_cpus; + info->hotpluggable_cpus =3D mc->has_hotpluggable_cpus; =20 entry =3D g_malloc0(sizeof(*entry)); entry->value =3D info; --=20 2.7.4