[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calcula
From: |
Yanan Wang |
Subject: |
[PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus |
Date: |
Mon, 19 Jul 2021 11:20:36 +0800 |
Currently we directly calculate the omitted cpus based on the already
provided parameters. This makes some cmdlines like:
-smp maxcpus=16
-smp sockets=2,maxcpus=16
-smp sockets=2,dies=2,maxcpus=16
-smp sockets=2,cores=4,maxcpus=16
not work. We should probably use the computed paramters to calculate
cpus when maxcpus is provided while cpus is omitted, which will make
above configs start to work.
Note: change in this patch won't affect any existing working cmdlines
but allows more incomplete configs to be valid.
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
---
hw/core/machine.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index c9f15b15a5..668f0a1553 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -767,26 +767,27 @@ static void smp_parse(MachineState *ms, SMPConfiguration
*config, Error **errp)
return;
}
- /* compute missing values, prefer sockets over cores over threads */
maxcpus = maxcpus > 0 ? maxcpus : cpus;
- if (cpus == 0) {
- sockets = sockets > 0 ? sockets : 1;
- cores = cores > 0 ? cores : 1;
- threads = threads > 0 ? threads : 1;
- cpus = sockets * dies * cores * threads;
- maxcpus = maxcpus > 0 ? maxcpus : cpus;
- } else if (sockets == 0) {
+ /* compute missing values, prefer sockets over cores over threads */
+ if (sockets == 0) {
cores = cores > 0 ? cores : 1;
threads = threads > 0 ? threads : 1;
sockets = maxcpus / (dies * cores * threads);
+ sockets = sockets > 0 ? sockets : 1;
} else if (cores == 0) {
threads = threads > 0 ? threads : 1;
cores = maxcpus / (sockets * dies * threads);
+ cores = cores > 0 ? cores : 1;
} else if (threads == 0) {
threads = maxcpus / (sockets * dies * cores);
+ threads = threads > 0 ? threads : 1;
}
+ /* use the computed parameters to calculate the omitted cpus */
+ cpus = cpus > 0 ? cpus : sockets * dies * cores * threads;
+ maxcpus = maxcpus > 0 ? maxcpus : cpus;
+
if (sockets * dies * cores * threads < cpus) {
g_autofree char *dies_msg = g_strdup_printf(
mc->smp_dies_supported ? " * dies (%u)" : "", dies);
--
2.19.1
- Re: [PATCH for-6.2 v2 01/11] machine: Disallow specifying topology parameters as zero, (continued)
- [PATCH for-6.2 v2 03/11] machine: Uniformly use maxcpus to calculate the omitted parameters, Yanan Wang, 2021/07/18
- [PATCH for-6.2 v2 09/11] machine: Tweak the order of topology members in struct CpuTopology, Yanan Wang, 2021/07/18
- [PATCH for-6.2 v2 06/11] hw: Add compat machines for 6.2, Yanan Wang, 2021/07/18
- [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus,
Yanan Wang <=
- Re: [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus, Andrew Jones, 2021/07/19
- Re: [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus, wangyanan (Y), 2021/07/22
- Re: [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus, Andrew Jones, 2021/07/22
- Re: [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus, wangyanan (Y), 2021/07/22
- Re: [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus, Andrew Jones, 2021/07/22
- Re: [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus, wangyanan (Y), 2021/07/22
[PATCH for-6.2 v2 07/11] machine: Prefer cores over sockets in smp parsing since 6.2, Yanan Wang, 2021/07/18