qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Yanan Wang <wangyanan55@huawei.com>,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org
Cc: Eduardo Habkost <eduardo@habkost.net>,
	Peter Maydell <peter.maydell@linaro.org>,
	Andrew Jones <drjones@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	wanghaibin.wang@huawei.com, Markus Armbruster <armbru@redhat.com>,
	Shannon Zhao <shannon.zhaosl@gmail.com>,
	Igor Mammedov <imammedo@redhat.com>, Ani Sinha <ani@anisinha.ca>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Eric Blake <eblake@redhat.com>
Subject: Re: [PATCH v5 03/14] hw/core/machine: Wrap target specific parameters together
Date: Tue, 28 Dec 2021 20:23:02 +0100	[thread overview]
Message-ID: <21974630-06ee-bacd-ca83-0116f1c6d4ec@redhat.com> (raw)
In-Reply-To: <20211228092221.21068-4-wangyanan55@huawei.com>

On 12/28/21 10:22, Yanan Wang wrote:
> Wrap the CPU target specific parameters together into a single
> variable except generic sockets/cores/threads, to make related
> code lines shorter and more concise.
> 
> 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 b39ed21e65..4547d7bbdc 100644
> --- a/hw/core/machine-smp.c
> +++ b/hw/core/machine-smp.c
> @@ -79,6 +79,7 @@ void machine_parse_smp_config(MachineState *ms,
>      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,
> @@ -111,6 +112,8 @@ void machine_parse_smp_config(MachineState *ms,
>      dies = dies > 0 ? dies : 1;
>      clusters = clusters > 0 ? clusters : 1;
>  
> +    others = dies * clusters;

This doesn't seem clearer to me...

>      /* compute missing values based on the provided ones */
>      if (cpus == 0 && maxcpus == 0) {
>          sockets = sockets > 0 ? sockets : 1;
> @@ -124,30 +127,30 @@ void machine_parse_smp_config(MachineState *ms,
>              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;
> @@ -159,7 +162,7 @@ void machine_parse_smp_config(MachineState *ms,
>      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: "



  reply	other threads:[~2021-12-28 19:26 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28  9:22 [PATCH v5 00/14] ARM virt: Introduce CPU clusters topology support Yanan Wang via
2021-12-28  9:22 ` [PATCH v5 01/14] qemu-options: Improve readability of SMP related Docs Yanan Wang via
2021-12-28 19:11   ` Philippe Mathieu-Daudé
2021-12-28  9:22 ` [PATCH v5 02/14] hw/core/machine: Introduce CPU cluster topology support Yanan Wang via
2021-12-28 19:17   ` Philippe Mathieu-Daudé
2021-12-29  3:48     ` wangyanan (Y) via
2021-12-29 10:44       ` Philippe Mathieu-Daudé
2021-12-29 13:04         ` wangyanan (Y) via
2021-12-29 15:44           ` Philippe Mathieu-Daudé
2022-01-14 11:34     ` Markus Armbruster
2021-12-28  9:22 ` [PATCH v5 03/14] hw/core/machine: Wrap target specific parameters together Yanan Wang via
2021-12-28 19:23   ` Philippe Mathieu-Daudé [this message]
2021-12-29  1:40     ` wangyanan (Y) via
2021-12-28  9:22 ` [PATCH v5 04/14] tests/unit/test-smp-parse: Add testcases for CPU clusters Yanan Wang via
2021-12-28 19:26   ` Philippe Mathieu-Daudé
2021-12-28  9:22 ` [PATCH v5 05/14] tests/unit/test-smp-parse: No need to explicitly zero MachineClass members Yanan Wang via
2021-12-28 15:58   ` Philippe Mathieu-Daudé
2021-12-28  9:22 ` [PATCH v5 06/14] tests/unit/test-smp-parse: Keep default MIN/MAX CPUs in machine_base_class_init Yanan Wang via
2021-12-28 19:28   ` Philippe Mathieu-Daudé
2021-12-28  9:22 ` [PATCH v5 07/14] MAINTAINERS: Self-recommended as reviewer of "Machine core" Yanan Wang via
2021-12-28 15:58   ` Philippe Mathieu-Daudé
2021-12-28  9:22 ` [PATCH v5 08/14] hw/arm/virt: Support clusters on ARM virt machines Yanan Wang via
2021-12-28  9:22 ` [PATCH v5 09/14] hw/arm/virt: Support cluster level in DT cpu-map Yanan Wang via
2021-12-28  9:22 ` [PATCH v5 10/14] hw/acpi/aml-build: Improve scalability of PPTT generation Yanan Wang via
2021-12-28  9:22 ` [PATCH v5 11/14] hw/arm/virt-acpi-build: Make an ARM specific PPTT generator Yanan Wang via
2021-12-28  9:22 ` [PATCH v5 12/14] tests/acpi/bios-tables-test: Allow changes to virt/PPTT file Yanan Wang via
2021-12-28  9:22 ` [PATCH v5 13/14] hw/arm/virt-acpi-build: Support cluster level in PPTT generation Yanan Wang via
2021-12-28  9:22 ` [PATCH v5 14/14] tests/acpi/bios-table-test: Update expected virt/PPTT file Yanan Wang via
2021-12-31 12:05 ` [PATCH v5 00/14] ARM virt: Introduce CPU clusters topology support Philippe Mathieu-Daudé
2022-01-03  9:08 ` wangyanan (Y) via

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=21974630-06ee-bacd-ca83-0116f1c6d4ec@redhat.com \
    --to=philmd@redhat.com \
    --cc=ani@anisinha.ca \
    --cc=armbru@redhat.com \
    --cc=drjones@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shannon.zhaosl@gmail.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=wangyanan55@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).