All of lore.kernel.org
 help / color / mirror / Atom feed
From: "wangyanan (Y)" <wangyanan55@huawei.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Andrew Jones <drjones@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org, Greg Kurz <groug@kaod.org>,
	Halil Pasic <pasic@linux.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	yuzenghui@huawei.com, wanghaibin.wang@huawei.com,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH for-6.2 v2 01/11] machine: Disallow specifying topology parameters as zero
Date: Wed, 21 Jul 2021 20:35:03 +0800	[thread overview]
Message-ID: <62331552-7125-411f-8f70-1040ffad6805@huawei.com> (raw)
In-Reply-To: <YPWsThPiZa3mF+zp@redhat.com>

On 2021/7/20 0:46, Daniel P. Berrangé wrote:
> On Mon, Jul 19, 2021 at 11:20:33AM +0800, Yanan Wang wrote:
>> In the SMP configuration, we should either specify a topology
>> parameter with a reasonable value (equal to or greater than 1)
>> or just leave it omitted and QEMU will calculate its value.
>>
>> Configurations which explicitly specify the topology parameters
>> as zero like "sockets=0" are meaningless, so disallow them.
>>
>> Suggested-by: Andrew Jones <drjones@redhat.com>
>> Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
>> ---
>>   hw/core/machine.c | 31 +++++++++++++++++++++++--------
>>   hw/i386/pc.c      | 29 +++++++++++++++++++++--------
>>   qapi/machine.json |  4 ++--
>>   3 files changed, 46 insertions(+), 18 deletions(-)
>>
>> diff --git a/hw/core/machine.c b/hw/core/machine.c
>> index 775add0795..d73daa10f4 100644
>> --- a/hw/core/machine.c
>> +++ b/hw/core/machine.c
>> @@ -745,11 +745,25 @@ static void smp_parse(MachineState *ms, SMPConfiguration *config, Error **errp)
>>   {
>>       unsigned cpus    = config->has_cpus ? config->cpus : 0;
>>       unsigned sockets = config->has_sockets ? config->sockets : 0;
>> +    unsigned dies    = config->has_dies ? config->dies : 1;
> It looks odd to set dies=1 by default at initially, when everything
> else is set to 0.  I realize you're just copying existing pc_smp_parse
> code in this respect, but I feel like could benefit from a separate
> initialization with a comment to explain why we're hardcoding it
> to 1....
>
>>       unsigned cores   = config->has_cores ? config->cores : 0;
>>       unsigned threads = config->has_threads ? config->threads : 0;
>> +    unsigned maxcpus = config->has_maxcpus ? config->maxcpus : 0;
>> +
>> +    if ((config->has_cpus && config->cpus == 0) ||
>> +        (config->has_sockets && config->sockets == 0) ||
>> +        (config->has_dies && config->dies == 0) ||
>> +        (config->has_cores && config->cores == 0) ||
>> +        (config->has_threads && config->threads == 0) ||
>> +        (config->has_maxcpus && config->maxcpus == 0)) {
>> +        error_setg(errp, "parameters must be equal to or greater than one"
>> +                   "if provided");
>> +        return;
>> +    }
>>   
>> -    if (config->has_dies && config->dies != 0 && config->dies != 1) {
>> +    if (dies > 1) {
>>           error_setg(errp, "dies not supported by this machine's CPU topology");
>> +        return;
>>       }
> .... eg how about here adding
>
>       /* Never try to assign multiple dies when defaulting omitted topology */
>       if (dies == 0) {
>           dies = 1;
>       }
Yeah, I agree to default dies to 0 like the other parameters at initially
and then explicitly assign it to 1 if omitted here. But I think this 
explicit
assignment should be in pc_smp_parse, because dies is never used in
the calculation in smp_parse yet except the front sanity-check.

So I think what should be updated for this patch is:
1) default dies to 0 at initially both in smp_parse and pc_smp_parse
2) then explicitly assign dies to 1 if it's omitted in pc_smp_parse
>
>
>> diff --git a/qapi/machine.json b/qapi/machine.json
>> index c3210ee1fb..c11b2e6f73 100644
>> --- a/qapi/machine.json
>> +++ b/qapi/machine.json
>> @@ -1288,8 +1288,8 @@
>>   ##
>>   # @SMPConfiguration:
>>   #
>> -# Schema for CPU topology configuration.  "0" or a missing value lets
>> -# QEMU figure out a suitable value based on the ones that are provided.
>> +# Schema for CPU topology configuration. A missing value lets QEMU
>> +# figure out a suitable value based on the ones that are provided.
> Hmm, so we had actually documented that '0' had the same semantics
> as omitting a parameter. This was done in:
>
>    commit 1e63fe685804dfadddd643bf3860b1a59702d4bf
>    Author: Paolo Bonzini <pbonzini@redhat.com>
>    Date:   Thu Jun 17 17:53:06 2021 +0200
>
>      machine: pass QAPI struct to mc->smp_parse
>
> which hasn't been released yet.
>
> This was possible, but never documented, with the traditiaonl -smp
> impl before it was qapi-ified. I think that historical behaviour
> was simply a side effect of the QemuOpts impl rather than an
> intentional design, hence not documented.
Agreed.
> At the very least I think need to get rid of this bit of docs about
> "0" before this release, otherwise we'll have stronger need to
> consider a real deprecation process.
If the doc needs to be fixed right now, then I think we'd better resend this
single patch separately for 6.1, including the doc fix and also the related
sanity-check in the parsers. Right?

Thanks,
Yanan
.


  reply	other threads:[~2021-07-21 12:39 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19  3:20 [PATCH for-6.2 v2 00/11] machine: smp parsing fixes and improvement Yanan Wang
2021-07-19  3:20 ` [PATCH for-6.2 v2 01/11] machine: Disallow specifying topology parameters as zero Yanan Wang
2021-07-19 16:11   ` Andrew Jones
2021-07-21 12:34     ` wangyanan (Y)
2021-07-19 16:46   ` Daniel P. Berrangé
2021-07-21 12:35     ` wangyanan (Y) [this message]
2021-07-19  3:20 ` [PATCH for-6.2 v2 02/11] machine: Make smp_parse generic enough for all arches Yanan Wang
2021-07-19 16:28   ` Andrew Jones
2021-07-19 16:36     ` Daniel P. Berrangé
2021-07-19 16:48       ` Andrew Jones
2021-07-19 16:50         ` Daniel P. Berrangé
2021-07-19 16:53   ` Daniel P. Berrangé
2021-07-22  7:18     ` wangyanan (Y)
2021-07-20  6:57   ` Cornelia Huck
2021-07-22  7:12     ` wangyanan (Y)
2021-07-19  3:20 ` [PATCH for-6.2 v2 03/11] machine: Uniformly use maxcpus to calculate the omitted parameters Yanan Wang
2021-07-19 16:36   ` Andrew Jones
2021-07-22  3:00     ` wangyanan (Y)
2021-07-19  3:20 ` [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus Yanan Wang
2021-07-19 16:42   ` Andrew Jones
2021-07-22  4:42     ` wangyanan (Y)
2021-07-22 12:27       ` Andrew Jones
2021-07-22 14:59         ` wangyanan (Y)
2021-07-22 15:05           ` Andrew Jones
2021-07-22 15:45             ` wangyanan (Y)
2021-07-19  3:20 ` [PATCH for-6.2 v2 05/11] machine: Improve the error reporting of smp parsing Yanan Wang
2021-07-19 16:53   ` Andrew Jones
2021-07-22  8:10     ` wangyanan (Y)
2021-07-22 12:47       ` Andrew Jones
2021-07-19  3:20 ` [PATCH for-6.2 v2 06/11] hw: Add compat machines for 6.2 Yanan Wang
2021-07-19  3:38   ` David Gibson
2021-07-19 17:00   ` Andrew Jones
2021-07-19 17:03   ` Cornelia Huck
2021-07-19 23:45   ` Pankaj Gupta
2021-07-19  3:20 ` [PATCH for-6.2 v2 07/11] machine: Prefer cores over sockets in smp parsing since 6.2 Yanan Wang
2021-07-19  3:40   ` David Gibson
2021-07-22  5:22     ` wangyanan (Y)
2021-07-19 17:13   ` Andrew Jones
2021-07-22  5:32     ` wangyanan (Y)
2021-07-19  3:20 ` [PATCH for-6.2 v2 08/11] machine: Use ms instead of global current_machine in sanity-check Yanan Wang
2021-07-19 17:14   ` Andrew Jones
2021-07-19  3:20 ` [PATCH for-6.2 v2 09/11] machine: Tweak the order of topology members in struct CpuTopology Yanan Wang
2021-07-19  3:20 ` [PATCH for-6.2 v2 10/11] machine: Split out the smp parsing code Yanan Wang
2021-07-19 17:20   ` Andrew Jones
2021-07-22  6:24     ` wangyanan (Y)
2021-07-22 13:07       ` Andrew Jones
2021-07-22 14:29         ` wangyanan (Y)
2021-07-19  3:20 ` [PATCH for-6.2 v2 11/11] tests/unit: Add a unit test for smp parsing Yanan Wang
2021-07-19 18:57   ` Andrew Jones
2021-07-22  6:15     ` wangyanan (Y)
2021-07-22 13:12       ` Andrew Jones
2021-07-22 14:18         ` wangyanan (Y)
2021-07-19 16:57 ` [PATCH for-6.2 v2 00/11] machine: smp parsing fixes and improvement Cornelia Huck
2021-07-21 12:38   ` wangyanan (Y)
2021-07-21 13:52     ` Pankaj Gupta
2021-07-22  2:22       ` wangyanan (Y)
2021-07-22  7:51     ` Pierre Morel
2021-07-22  8:32       ` wangyanan (Y)

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=62331552-7125-411f-8f70-1040ffad6805@huawei.com \
    --to=wangyanan55@huawei.com \
    --cc=berrange@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=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=yuzenghui@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.