[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 05/15] machine: Improve the error reporting of smp parsing
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v7 05/15] machine: Improve the error reporting of smp parsing |
Date: |
Mon, 23 Aug 2021 15:17:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
On 8/23/21 2:27 PM, Yanan Wang wrote:
> We have two requirements for a valid SMP configuration:
> the product of "sockets * cores * threads" must represent all the
> possible cpus, i.e., max_cpus, and then must include the initially
> present cpus, i.e., smp_cpus.
>
> So we only need to ensure 1) "sockets * cores * threads == maxcpus"
> at first and then ensure 2) "maxcpus >= cpus". With a reasonable
> order of the sanity check, we can simplify the error reporting code.
> When reporting an error message we also report the exact value of
> each topology member to make users easily see what's going on.
>
> Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
> Reviewed-by: Andrew Jones <drjones@redhat.com>
> Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com>
> ---
> hw/core/machine.c | 22 +++++++++-------------
> hw/i386/pc.c | 24 ++++++++++--------------
> 2 files changed, 19 insertions(+), 27 deletions(-)
>
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 85908abc77..093c0d382d 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -779,25 +779,21 @@ static void smp_parse(MachineState *ms,
> SMPConfiguration *config, Error **errp)
> maxcpus = maxcpus > 0 ? maxcpus : sockets * cores * threads;
> cpus = cpus > 0 ? cpus : maxcpus;
>
> - if (sockets * cores * threads < cpus) {
> - error_setg(errp, "cpu topology: "
> - "sockets (%u) * cores (%u) * threads (%u) < "
> - "smp_cpus (%u)",
> - sockets, cores, threads, cpus);
> + if (sockets * cores * threads != maxcpus) {
> + error_setg(errp, "Invalid CPU topology: "
> + "product of the hierarchy must match maxcpus: "
> + "sockets (%u) * cores (%u) * threads (%u) "
> + "!= maxcpus (%u)",
> + sockets, cores, threads, maxcpus);
> return;
> }
Thinking about scalability, MachineClass could have a
parse_cpu_topology() handler, and this would be the
generic one. Principally because architectures don't
use the same terms, and die/socket/core/thread arrangement
is machine specific (besides being arch-spec).
Not a problem as of today, but the way we try to handle
this generically seems over-engineered to me.
[unrelated to this particular patch]
[PATCH v7 04/15] machine: Set the value of cpus to match maxcpus if it's omitted, Yanan Wang, 2021/08/23
[PATCH v7 06/15] hw: Add compat machines for 6.2, Yanan Wang, 2021/08/23
[PATCH v7 09/15] machine: Tweak the order of topology members in struct CpuTopology, Yanan Wang, 2021/08/23
[PATCH v7 08/15] machine: Use ms instead of global current_machine in sanity-check, Yanan Wang, 2021/08/23
[PATCH v7 10/15] machine: Make smp_parse generic enough for all arches, Yanan Wang, 2021/08/23
[PATCH v7 12/15] machine: Move smp_prefer_sockets to struct SMPCompatProps, Yanan Wang, 2021/08/23