From: "wangyanan (Y)" <wangyanan55@huawei.com>
To: Andrew Jones <drjones@redhat.com>
Cc: "Barry Song" <song.bao.hua@hisilicon.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Michael S . Tsirkin" <mst@redhat.com>,
wanghaibin.wang@huawei.com, zhukeqian1@huawei.com,
qemu-devel@nongnu.org, yangyicong@huawei.com,
"Shannon Zhao" <shannon.zhaosl@gmail.com>,
qemu-arm@nongnu.org, prime.zeng@hisilicon.com,
"Paolo Bonzini" <pbonzini@redhat.com>,
yuzenghui@huawei.com, "Igor Mammedov" <imammedo@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [RFC PATCH v3 4/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse
Date: Mon, 17 May 2021 23:10:35 +0800 [thread overview]
Message-ID: <50306678-44ec-24f5-6d00-24a8f98b7d25@huawei.com> (raw)
In-Reply-To: <20210517091257.wavp74sn37fh3nxf@gator.home>
Hi Drew,
On 2021/5/17 17:12, Andrew Jones wrote:
> On Sun, May 16, 2021 at 06:32:28PM +0800, Yanan Wang wrote:
>> 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.
>>
>> Note, we will assume multi-cluster in one socket is not supported
>> and default the value of clusters to 1, if it's not explicitly
>> specified in -smp cmdline.
>>
>> 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 7de822e491..678d5ef36c 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -2642,8 +2642,8 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
>> * with the -smp cmdlines when parsing them.
>> *
>> * We require that at least one of cpus or maxcpus must be provided.
>> - * Threads will default to 1 if not provided. Sockets and cores must
>> - * be either both provided or both not.
>> + * Clusters and threads will default to 1 if they are not provided.
>> + * Sockets and cores must be either both provided or both not.
>> *
>> * Note, if neither sockets nor cores are specified, we will calculate
>> * all the missing values just like smp_parse() does, but will disable
>> @@ -2652,15 +2652,18 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
>> static void virt_smp_parse(MachineState *ms, QemuOpts *opts)
>> {
>> VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(ms);
>> + VirtMachineState *vms = VIRT_MACHINE(ms);
>>
>> if (opts) {
>> unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
>> unsigned maxcpus = qemu_opt_get_number(opts, "maxcpus", 0);
>> unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
>> + unsigned clusters = qemu_opt_get_number(opts, "clusters", 0);
>> unsigned cores = qemu_opt_get_number(opts, "cores", 0);
>> unsigned threads = qemu_opt_get_number(opts, "threads", 0);
>>
>> - /* Default threads to 1 if not provided */
>> + /* Default clusters and threads to 1 if not provided */
>> + clusters = clusters > 0 ? clusters : 1;
>> threads = threads > 0 ? threads : 1;
>>
>> if (cpus == 0 && maxcpus == 0) {
>> @@ -2676,13 +2679,13 @@ static void virt_smp_parse(MachineState *ms, QemuOpts *opts)
>> cores = 1;
>> if (cpus == 0) {
>> sockets = 1;
>> - cpus = sockets * cores * threads;
>> + cpus = sockets * clusters * cores * threads;
>> } else {
>> maxcpus = maxcpus > 0 ? maxcpus : cpus;
>> - sockets = maxcpus / (cores * threads);
>> + sockets = maxcpus / (clusters * cores * threads);
>> }
>> } else if (sockets > 0 && cores > 0) {
>> - cpus = cpus > 0 ? cpus : sockets * cores * threads;
>> + cpus = cpus > 0 ? cpus : sockets * clusters * cores * threads;
>> maxcpus = maxcpus > 0 ? maxcpus : cpus;
>> } else {
>> error_report("sockets and cores must be both provided "
>> @@ -2695,25 +2698,26 @@ static void virt_smp_parse(MachineState *ms, QemuOpts *opts)
>> exit(1);
>> }
>>
>> - if (sockets * cores * threads < cpus) {
>> + 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);
>> }
>>
>> - if (sockets * cores * threads != maxcpus) {
>> + if (sockets * clusters * cores * threads != maxcpus) {
>> error_report("cpu topology: "
>> - "sockets (%u) * cores (%u) * threads (%u) "
>> - "!= maxcpus (%u)",
>> - sockets, cores, threads, maxcpus);
>> + "sockets (%u) * clusters (%u) * cores (%u) * "
>> + "threads (%u) != maxcpus (%u)",
>> + sockets, clusters, cores, threads, maxcpus);
>> exit(1);
>> }
>>
>> ms->smp.cpus = cpus;
>> ms->smp.max_cpus = maxcpus;
>> ms->smp.sockets = sockets;
>> + vms->smp_clusters = clusters;
>> ms->smp.cores = cores;
>> ms->smp.threads = threads;
>> }
>> --
>> 2.19.1
>>
> After reworking "[RFC PATCH v3 9/9] hw/arm/virt: Add separate -smp parsing
> function for ARM machines", this should also be reworked and fully tested,
> possibly using a standalone test, as as I suggested in the other review.
Ok, I will make full test.
Thanks,
Yanan
> Thanks,
> drew
>
> .
next prev parent reply other threads:[~2021-05-17 15:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-16 10:32 [RFC PATCH v3 0/4] hw/arm/virt: Introduce cluster cpu topology support Yanan Wang
2021-05-16 10:32 ` [RFC PATCH v3 1/4] vl.c: Add -smp, clusters=* command line support for ARM cpu Yanan Wang
2021-05-17 9:07 ` Andrew Jones
2021-05-17 15:07 ` wangyanan (Y)
2021-05-16 10:32 ` [RFC PATCH v3 2/4] hw/arm/virt: Add cluster level to device tree Yanan Wang
2021-05-16 10:32 ` [RFC PATCH v3 3/4] hw/arm/virt-acpi-build: Add cluster level to PPTT table Yanan Wang
2021-05-16 10:32 ` [RFC PATCH v3 4/4] hw/arm/virt: Parse -smp cluster parameter in virt_smp_parse Yanan Wang
2021-05-17 9:12 ` Andrew Jones
2021-05-17 15:10 ` wangyanan (Y) [this message]
2021-05-17 15:17 ` Salil Mehta
2021-05-18 3:48 ` wangyanan (Y)
2021-05-18 6:52 ` Salil Mehta
2021-05-18 8:19 ` Andrew Jones
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=50306678-44ec-24f5-6d00-24a8f98b7d25@huawei.com \
--to=wangyanan55@huawei.com \
--cc=drjones@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=prime.zeng@hisilicon.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhaosl@gmail.com \
--cc=song.bao.hua@hisilicon.com \
--cc=wanghaibin.wang@huawei.com \
--cc=yangyicong@huawei.com \
--cc=yuzenghui@huawei.com \
--cc=zhukeqian1@huawei.com \
/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 NNTP newsgroup(s).