From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: berrange@redhat.com, armbru@redhat.com
Subject: [PATCH 06/11] machine: move dies from X86MachineState to CpuTopology
Date: Thu, 10 Jun 2021 15:35:33 +0200 [thread overview]
Message-ID: <20210610133538.608390-7-pbonzini@redhat.com> (raw)
In-Reply-To: <20210610133538.608390-1-pbonzini@redhat.com>
In order to make SMP configuration a Machine property, we need a getter as
well as a setter. To simplify the implementation put everything that the
getter needs in the CpuTopology struct.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/core/machine.c | 1 +
hw/i386/pc.c | 4 +---
hw/i386/x86.c | 15 +++++++--------
include/hw/boards.h | 1 +
include/hw/i386/pc.h | 1 -
include/hw/i386/x86.h | 1 -
6 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 55b9bc7817..d776c8cf20 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -970,6 +970,7 @@ static void machine_initfn(Object *obj)
ms->smp.cpus = mc->default_cpus;
ms->smp.max_cpus = mc->default_cpus;
ms->smp.cores = 1;
+ ms->smp.dies = 1;
ms->smp.threads = 1;
ms->smp.sockets = 1;
}
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index c6d8d0d84d..92958e9ad7 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -712,8 +712,6 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
*/
void pc_smp_parse(MachineState *ms, QemuOpts *opts)
{
- X86MachineState *x86ms = X86_MACHINE(ms);
-
if (opts) {
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
@@ -769,7 +767,7 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts)
ms->smp.cores = cores;
ms->smp.threads = threads;
ms->smp.sockets = sockets;
- x86ms->smp_dies = dies;
+ ms->smp.dies = dies;
}
if (ms->smp.cpus > 1) {
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index ed796fe6ba..2a99942016 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -64,7 +64,7 @@ inline void init_topo_info(X86CPUTopoInfo *topo_info,
{
MachineState *ms = MACHINE(x86ms);
- topo_info->dies_per_pkg = x86ms->smp_dies;
+ topo_info->dies_per_pkg = ms->smp.dies;
topo_info->cores_per_die = ms->smp.cores;
topo_info->threads_per_core = ms->smp.threads;
}
@@ -293,7 +293,7 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
init_topo_info(&topo_info, x86ms);
- env->nr_dies = x86ms->smp_dies;
+ env->nr_dies = ms->smp.dies;
/*
* If APIC ID is not set,
@@ -301,13 +301,13 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
*/
if (cpu->apic_id == UNASSIGNED_APIC_ID) {
int max_socket = (ms->smp.max_cpus - 1) /
- smp_threads / smp_cores / x86ms->smp_dies;
+ smp_threads / smp_cores / ms->smp.dies;
/*
* die-id was optional in QEMU 4.0 and older, so keep it optional
* if there's only one die per socket.
*/
- if (cpu->die_id < 0 && x86ms->smp_dies == 1) {
+ if (cpu->die_id < 0 && ms->smp.dies == 1) {
cpu->die_id = 0;
}
@@ -322,9 +322,9 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
if (cpu->die_id < 0) {
error_setg(errp, "CPU die-id is not set");
return;
- } else if (cpu->die_id > x86ms->smp_dies - 1) {
+ } else if (cpu->die_id > ms->smp.dies - 1) {
error_setg(errp, "Invalid CPU die-id: %u must be in range 0:%u",
- cpu->die_id, x86ms->smp_dies - 1);
+ cpu->die_id, ms->smp.dies - 1);
return;
}
if (cpu->core_id < 0) {
@@ -477,7 +477,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms)
&topo_info, &topo_ids);
ms->possible_cpus->cpus[i].props.has_socket_id = true;
ms->possible_cpus->cpus[i].props.socket_id = topo_ids.pkg_id;
- if (x86ms->smp_dies > 1) {
+ if (ms->smp.dies > 1) {
ms->possible_cpus->cpus[i].props.has_die_id = true;
ms->possible_cpus->cpus[i].props.die_id = topo_ids.die_id;
}
@@ -1252,7 +1252,6 @@ static void x86_machine_initfn(Object *obj)
x86ms->smm = ON_OFF_AUTO_AUTO;
x86ms->acpi = ON_OFF_AUTO_AUTO;
- x86ms->smp_dies = 1;
x86ms->pci_irq_mask = ACPI_BUILD_PCI_IRQS;
x86ms->oem_id = g_strndup(ACPI_BUILD_APPNAME6, 6);
x86ms->oem_table_id = g_strndup(ACPI_BUILD_APPNAME8, 8);
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 3d55d2bd62..87ae5cc300 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -282,6 +282,7 @@ typedef struct DeviceMemoryState {
*/
typedef struct CpuTopology {
unsigned int cpus;
+ unsigned int dies;
unsigned int cores;
unsigned int threads;
unsigned int sockets;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 1522a3359a..4c2ca6d36a 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -19,7 +19,6 @@
* PCMachineState:
* @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling
* @boot_cpus: number of present VCPUs
- * @smp_dies: number of dies per one package
*/
typedef struct PCMachineState {
/*< private >*/
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index c09b648dff..a6ffd94562 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -62,7 +62,6 @@ struct X86MachineState {
unsigned pci_irq_mask;
unsigned apic_id_limit;
uint16_t boot_cpus;
- unsigned smp_dies;
OnOffAuto smm;
OnOffAuto acpi;
--
2.31.1
next prev parent reply other threads:[~2021-06-10 13:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-10 13:35 [PATCH 00/11] vl: compound properties for machines Paolo Bonzini
2021-06-10 13:35 ` [PATCH 01/11] qom: export more functions for use with non-UserCreatable objects Paolo Bonzini
2021-06-10 13:49 ` Daniel P. Berrangé
2021-06-10 13:35 ` [PATCH 02/11] keyval: introduce keyval_merge Paolo Bonzini
2021-06-16 8:38 ` Markus Armbruster
2021-06-16 10:49 ` Paolo Bonzini
2021-06-10 13:35 ` [PATCH 03/11] keyval: introduce keyval_parse_into Paolo Bonzini
2021-06-10 13:53 ` Daniel P. Berrangé
2021-06-16 14:09 ` Markus Armbruster
2021-06-16 18:05 ` Paolo Bonzini
2021-06-10 13:35 ` [PATCH 04/11] vl: switch -M parsing to keyval Paolo Bonzini
2021-06-10 13:35 ` [PATCH 05/11] qemu-option: remove now-dead code Paolo Bonzini
2021-06-10 13:54 ` Daniel P. Berrangé
2021-06-10 13:35 ` Paolo Bonzini [this message]
2021-06-10 13:55 ` [PATCH 06/11] machine: move dies from X86MachineState to CpuTopology Daniel P. Berrangé
2021-06-10 13:35 ` [PATCH 07/11] machine: move common smp_parse code to caller Paolo Bonzini
2021-06-10 14:34 ` Daniel P. Berrangé
2021-06-10 13:35 ` [PATCH 08/11] machine: add error propagation to mc->smp_parse Paolo Bonzini
2021-06-10 14:35 ` Daniel P. Berrangé
2021-06-10 13:35 ` [PATCH 09/11] machine: pass QAPI struct " Paolo Bonzini
2021-06-10 14:37 ` Daniel P. Berrangé
2021-06-10 13:35 ` [PATCH 10/11] machine: reject -smp dies!=1 for non-PC machines Paolo Bonzini
2021-06-10 14:37 ` Daniel P. Berrangé
2021-06-10 13:35 ` [PATCH 11/11] machine: add smp compound property Paolo Bonzini
2021-06-10 14:41 ` Daniel P. Berrangé
2021-06-14 22:57 ` [PATCH 00/11] vl: compound properties for machines no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210610133538.608390-7-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).