[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp
From: |
Yanan Wang |
Subject: |
[RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse |
Date: |
Tue, 13 Apr 2021 16:31:45 +0800 |
There is a separate function virt_smp_parse() in hw/virt/arm.c used
to parse cpu topology for the ARM machines. So add parsing of -smp
cluster parameter in it, then total number of logical cpus will be
calculated like: max_cpus = sockets * clusters * cores * threads.
In virt_smp_parse(), the computing logic of missing values prefers
cores over sockets over threads. And for compatibility, the value
of clusters will be set as default 1 if not explicitly specified.
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
---
hw/arm/virt.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 57ef961cb5..51797628db 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2639,35 +2639,38 @@ static void virt_smp_parse(MachineState *ms, QemuOpts
*opts)
if (opts) {
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
+ unsigned clusters = qemu_opt_get_number(opts, "clusters", 1);
unsigned cores = qemu_opt_get_number(opts, "cores", 0);
unsigned threads = qemu_opt_get_number(opts, "threads", 0);
+ VirtMachineState *vms = VIRT_MACHINE(ms);
/*
- * Compute missing values; prefer cores over sockets and
- * sockets over threads.
+ * Compute missing values; prefer cores over sockets and sockets
+ * over threads. For compatibility, value of clusters will have
+ * been set as default 1 if not explicitly specified.
*/
if (cpus == 0 || cores == 0) {
sockets = sockets > 0 ? sockets : 1;
threads = threads > 0 ? threads : 1;
if (cpus == 0) {
cores = cores > 0 ? cores : 1;
- cpus = cores * threads * sockets;
+ cpus = sockets * clusters * cores * threads;
} else {
ms->smp.max_cpus = qemu_opt_get_number(opts, "maxcpus", cpus);
- cores = ms->smp.max_cpus / (sockets * threads);
+ cores = ms->smp.max_cpus / (sockets * clusters * threads);
}
} else if (sockets == 0) {
threads = threads > 0 ? threads : 1;
- sockets = cpus / (cores * threads);
+ sockets = cpus / (clusters * cores * threads);
sockets = sockets > 0 ? sockets : 1;
} else if (threads == 0) {
- threads = cpus / (cores * sockets);
+ threads = cpus / (sockets * clusters * cores);
threads = threads > 0 ? threads : 1;
- } else if (sockets * cores * threads < cpus) {
+ } else if (sockets * clusters * cores * threads < cpus) {
error_report("cpu topology: "
- "sockets (%u) * cores (%u) * threads (%u) < "
- "smp_cpus (%u)",
- sockets, cores, threads, cpus);
+ "sockets (%u) * clusters (%u) * cores (%u) * "
+ "threads (%u) < smp_cpus (%u)",
+ sockets, clusters, cores, threads, cpus);
exit(1);
}
@@ -2678,11 +2681,11 @@ static void virt_smp_parse(MachineState *ms, QemuOpts
*opts)
exit(1);
}
- if (sockets * cores * threads != ms->smp.max_cpus) {
+ if (sockets * clusters * cores * threads != ms->smp.max_cpus) {
error_report("cpu topology: "
- "sockets (%u) * cores (%u) * threads (%u)"
- "!= maxcpus (%u)",
- sockets, cores, threads,
+ "sockets (%u) * clusters (%u) * cores (%u) * "
+ "threads (%u) != maxcpus (%u)",
+ sockets, clusters, cores, threads,
ms->smp.max_cpus);
exit(1);
}
@@ -2691,6 +2694,7 @@ static void virt_smp_parse(MachineState *ms, QemuOpts
*opts)
ms->smp.cores = cores;
ms->smp.threads = threads;
ms->smp.sockets = sockets;
+ vms->smp_clusters = clusters;
}
if (ms->smp.cpus > 1) {
--
2.19.1
- [RFC PATCH v2 0/4] hw/arm/virt: Introduce cluster cpu topology support, Yanan Wang, 2021/04/13
- [RFC PATCH v2 4/4] hw/arm/virt: Add cluster level for device tree, Yanan Wang, 2021/04/13
- [RFC PATCH v2 3/4] hw/arm/virt-acpi-build: Add cluster level for PPTT table, Yanan Wang, 2021/04/13
- [RFC PATCH v2 1/4] vl.c: Add -smp, clusters=* command line support for ARM cpu, Yanan Wang, 2021/04/13
- [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse,
Yanan Wang <=
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, Andrew Jones, 2021/04/28
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, wangyanan (Y), 2021/04/28
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, Andrew Jones, 2021/04/29
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, wangyanan (Y), 2021/04/29
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, Andrew Jones, 2021/04/29
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, wangyanan (Y), 2021/04/30
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, Andrew Jones, 2021/04/30
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, Andrew Jones, 2021/04/30
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, wangyanan (Y), 2021/04/30
- Re: [RFC PATCH v2 2/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse, Andrew Jones, 2021/04/30