[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 03/10] hw/core/machine: Wrap target specific parameters togeth
From: |
Yanan Wang |
Subject: |
[PATCH v4 03/10] hw/core/machine: Wrap target specific parameters together |
Date: |
Sun, 21 Nov 2021 20:24:55 +0800 |
Wrap the CPU target specific parameters together into a single
variable, so that we don't need to update the other lines but
a single line when new topology parameters are introduced.
No functional change intended.
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
---
hw/core/machine-smp.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c
index 87ceb45470..2a3f16e52b 100644
--- a/hw/core/machine-smp.c
+++ b/hw/core/machine-smp.c
@@ -77,6 +77,7 @@ void smp_parse(MachineState *ms, SMPConfiguration *config,
Error **errp)
unsigned cores = config->has_cores ? config->cores : 0;
unsigned threads = config->has_threads ? config->threads : 0;
unsigned maxcpus = config->has_maxcpus ? config->maxcpus : 0;
+ unsigned others;
/*
* Specified CPU topology parameters must be greater than zero,
@@ -109,6 +110,8 @@ void smp_parse(MachineState *ms, SMPConfiguration *config,
Error **errp)
dies = dies > 0 ? dies : 1;
clusters = clusters > 0 ? clusters : 1;
+ others = dies * clusters;
+
/* compute missing values based on the provided ones */
if (cpus == 0 && maxcpus == 0) {
sockets = sockets > 0 ? sockets : 1;
@@ -122,30 +125,30 @@ void smp_parse(MachineState *ms, SMPConfiguration
*config, Error **errp)
if (sockets == 0) {
cores = cores > 0 ? cores : 1;
threads = threads > 0 ? threads : 1;
- sockets = maxcpus / (dies * clusters * cores * threads);
+ sockets = maxcpus / (cores * threads * others);
} else if (cores == 0) {
threads = threads > 0 ? threads : 1;
- cores = maxcpus / (sockets * dies * clusters * threads);
+ cores = maxcpus / (sockets * threads * others);
}
} else {
/* prefer cores over sockets since 6.2 */
if (cores == 0) {
sockets = sockets > 0 ? sockets : 1;
threads = threads > 0 ? threads : 1;
- cores = maxcpus / (sockets * dies * clusters * threads);
+ cores = maxcpus / (sockets * threads * others);
} else if (sockets == 0) {
threads = threads > 0 ? threads : 1;
- sockets = maxcpus / (dies * clusters * cores * threads);
+ sockets = maxcpus / (cores * threads * others);
}
}
/* try to calculate omitted threads at last */
if (threads == 0) {
- threads = maxcpus / (sockets * dies * clusters * cores);
+ threads = maxcpus / (sockets * cores * others);
}
}
- maxcpus = maxcpus > 0 ? maxcpus : sockets * dies * clusters * cores *
threads;
+ maxcpus = maxcpus > 0 ? maxcpus : sockets * cores * threads * others;
cpus = cpus > 0 ? cpus : maxcpus;
ms->smp.cpus = cpus;
@@ -157,7 +160,7 @@ void smp_parse(MachineState *ms, SMPConfiguration *config,
Error **errp)
ms->smp.max_cpus = maxcpus;
/* sanity-check of the computed topology */
- if (sockets * dies * clusters * cores * threads != maxcpus) {
+ if (sockets * cores * threads * others != maxcpus) {
g_autofree char *topo_msg = cpu_hierarchy_to_string(ms);
error_setg(errp, "Invalid CPU topology: "
"product of the hierarchy must match maxcpus: "
--
2.19.1
- [PATCH v4 00/10] ARM virt: Introduce CPU clusters topology support, Yanan Wang, 2021/11/21
- [PATCH v4 04/10] hw/arm/virt: Support clusters on ARM virt machines, Yanan Wang, 2021/11/21
- [PATCH v4 07/10] hw/arm/virt-acpi-build: Make an ARM specific PPTT generator, Yanan Wang, 2021/11/21
- [PATCH v4 06/10] hw/acpi/aml-build: Improve scalability of PPTT generation, Yanan Wang, 2021/11/21
- [PATCH v4 05/10] hw/arm/virt: Support cluster level in DT cpu-map, Yanan Wang, 2021/11/21
- [PATCH v4 02/10] hw/core/machine: Introduce CPU cluster topology support, Yanan Wang, 2021/11/21
- [PATCH v4 01/10] qemu-options: Improve readability of SMP related Docs, Yanan Wang, 2021/11/21
- [PATCH v4 10/10] tests/acpi/bios-table-test: Update expected virt/PPTT file, Yanan Wang, 2021/11/21
- [PATCH v4 03/10] hw/core/machine: Wrap target specific parameters together,
Yanan Wang <=
- [PATCH v4 08/10] tests/acpi/bios-tables-test: Allow changes to virt/PPTT file, Yanan Wang, 2021/11/21
- [PATCH v4 09/10] hw/acpi/virt-acpi-build: Support cluster level in PPTT generation, Yanan Wang, 2021/11/21