All of lore.kernel.org
 help / color / mirror / Atom feed
From: "wangyanan (Y)" <wangyanan55@huawei.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel@nongnu.org, "Eduardo Habkost" <ehabkost@redhat.com>,
	"Igor Mammedov" <imammedo@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Andrew Jones" <drjones@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Pierre Morel" <pmorel@linux.ibm.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Greg Kurz" <groug@kaod.org>, "Halil Pasic" <pasic@linux.ibm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Pankaj Gupta" <pankaj.gupta.linux@gmail.com>,
	"Thomas Huth" <thuth@redhat.com>,
	wanghaibin.wang@huawei.com,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v7 05/15] machine: Improve the error reporting of smp parsing
Date: Tue, 24 Aug 2021 16:23:44 +0800	[thread overview]
Message-ID: <18959f11-f40e-9faf-bc27-425fa5090a20@huawei.com> (raw)
In-Reply-To: <a9adbc4d-c111-1280-965e-0242f9f43da8@redhat.com>


On 2021/8/24 15:29, Philippe Mathieu-Daudé wrote:
> On 8/24/21 6:51 AM, wangyanan (Y) wrote:
>> On 2021/8/23 21:17, Philippe Mathieu-Daudé wrote:
>>> 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.
>> Hi Philippe,
>>
>> The reason for introducing a generic implementation and avoiding
>> specific ones is that we thought there is little difference in parsing
>> logic between the specific parsers. Most part of the parsing is the
>> automatic calculation of missing values and the related error reporting,
>> in which the only difference between parsers is the handling of specific
>> (no matter of arch-specific or machine-specifc) parameters.
>>
>> So it may be better to keep the parsing logic unified if we can easily
>> realize that. And actually we can use compat stuff to handle specific
>> topology parameters well. See implementation in patch #10.
>>
>> There have been patches on list introducing new specific members
>> (s390 related in [1] and ARM related in [2]), and in each of them there
>> is a specific parser needed. However, based on generic one we can
>> extend without the increasing code duplication.
>>
>> There is also some discussion about generic/specific parser in [1],
>> which can be a reference.
>>
>> [1]
>> https://lore.kernel.org/qemu-devel/1626281596-31061-2-git-send-email-pmorel@linux.ibm.com/
>>
>> [2]
>> https://lore.kernel.org/qemu-devel/20210516103228.37792-1-wangyanan55@huawei.com/
> OK I read Daniel's rationale here:
> https://lore.kernel.org/qemu-devel/YPFN83pKBt7F97kW@redhat.com/
exactly. :)

Thanks,
Yanan
.
> Thanks,
>
> Phil.
>
> .



  reply	other threads:[~2021-08-24  8:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 12:27 [PATCH v7 00/15] machine: smp parsing fixes and improvement Yanan Wang
2021-08-23 12:27 ` [PATCH v7 01/15] machine: Deprecate "parameter=0" SMP configurations Yanan Wang
2021-08-23 12:27 ` [PATCH v7 02/15] machine: Minor refactor/fix for the smp parsers Yanan Wang
2021-08-23 12:27 ` [PATCH v7 03/15] machine: Uniformly use maxcpus to calculate the omitted parameters Yanan Wang
2021-08-23 12:27 ` [PATCH v7 04/15] machine: Set the value of cpus to match maxcpus if it's omitted Yanan Wang
2021-08-23 12:27 ` [PATCH v7 05/15] machine: Improve the error reporting of smp parsing Yanan Wang
2021-08-23 13:17   ` Philippe Mathieu-Daudé
2021-08-24  4:51     ` wangyanan (Y)
2021-08-24  7:29       ` Philippe Mathieu-Daudé
2021-08-24  8:23         ` wangyanan (Y) [this message]
2021-08-23 12:27 ` [PATCH v7 06/15] hw: Add compat machines for 6.2 Yanan Wang
2021-08-23 12:27 ` [PATCH v7 07/15] machine: Prefer cores over sockets in smp parsing since 6.2 Yanan Wang
2021-08-23 12:27 ` [PATCH v7 08/15] machine: Use ms instead of global current_machine in sanity-check Yanan Wang
2021-08-23 12:27 ` [PATCH v7 09/15] machine: Tweak the order of topology members in struct CpuTopology Yanan Wang
2021-08-23 12:27 ` [PATCH v7 10/15] machine: Make smp_parse generic enough for all arches Yanan Wang
2021-08-23 13:19   ` Philippe Mathieu-Daudé
2021-08-23 12:28 ` [PATCH v7 11/15] machine: Remove smp_parse callback from MachineClass Yanan Wang
2021-08-23 12:28 ` [PATCH v7 12/15] machine: Move smp_prefer_sockets to struct SMPCompatProps Yanan Wang
2021-08-23 12:28 ` [PATCH v7 13/15] machine: Put all sanity-check in the generic SMP parser Yanan Wang
2021-08-23 12:28 ` [PATCH v7 14/15] machine: Split out the smp parsing code Yanan Wang
2021-08-23 12:28 ` [PATCH v7 15/15] tests/unit: Add a unit test for smp parsing Yanan Wang

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=18959f11-f40e-9faf-bc27-425fa5090a20@huawei.com \
    --to=wangyanan55@huawei.com \
    --cc=berrange@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=drjones@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=groug@kaod.org \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pankaj.gupta.linux@gmail.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=pmorel@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    --cc=wanghaibin.wang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.