From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3C97C07E9B for ; Mon, 19 Jul 2021 16:54:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DBBE60E0C for ; Mon, 19 Jul 2021 16:54:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DBBE60E0C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5WXT-0000zA-F9 for qemu-devel@archiver.kernel.org; Mon, 19 Jul 2021 12:54:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5WWX-0007Vi-0L for qemu-devel@nongnu.org; Mon, 19 Jul 2021 12:53:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5WWV-0006IT-0q for qemu-devel@nongnu.org; Mon, 19 Jul 2021 12:53:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626713622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=p/hUNlHDQiO6q3KRC78vaBfwDAU7RFyDWCEFlWaZo90=; b=HNCuni39nyaL/ZTyl+yzYwkDvr5z2PqDEfT4ZNXtSTf11CpjMVUJdl192I+nj2nkFDoZnX PVegRj6OxBwewDhL8iYgUsg+xYtN6drH+9dfhOItDiJRsr6prLPel5jvjp5S45PKn1XQFm 6PqLds1Fy+pAG9hFyrG29VU15rgEtkE= Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-96EaJ1l-OgqvZ_jl9KyRWw-1; Mon, 19 Jul 2021 12:53:40 -0400 X-MC-Unique: 96EaJ1l-OgqvZ_jl9KyRWw-1 Received: by mail-io1-f69.google.com with SMTP id v2-20020a5d94020000b02905058dc6c376so13008100ion.6 for ; Mon, 19 Jul 2021 09:53:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=p/hUNlHDQiO6q3KRC78vaBfwDAU7RFyDWCEFlWaZo90=; b=ToSVOTVctUu6ImXF/XMApHVLE2+3yPE3WRi05Wj3Cbx0loJAwzvblEIEt2shXYveFD OXUWBt2ZPU8zZRxVNPt9tSf6xBbFl5EdKOJC+R1eDQ3FdxaVQ9xD+cMp3mLsEAs3onQe zKyrR8ZO7Atv5jIGRKmpKq/dpxqkGk0Av9fZG5C2YjyvAVLFmJ2QKj+4Qm0iH1iDdGax Zaf9FXYo9yZDEerq7Suc5bNbFRYLdzIN1MtbbxymKEBhJD0V0T/ZK2FE2oIiODRZUJvk Xx+QiOVCEUthqjunHJewrLFnmYUKSwbq7Un8u4YaZko8VY/CKt6idVp45SI0XpJJP8CR Uv9w== X-Gm-Message-State: AOAM532i8SnoqlN2UTLj3CM5Opc2MTFYhgHJtaMe5cdHZLCCrV9kHV14 7r2rmwbL8p51wQFafY6BuSb5d8Fo862SQwN5dLcTjNBMyOBNMkS8pq4Ce2YiB6mBKUc13VyBNzd oDmQpQDYqXJfqtQs= X-Received: by 2002:a05:6e02:c30:: with SMTP id q16mr14326894ilg.75.1626713620174; Mon, 19 Jul 2021 09:53:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWVXrRXS3rau9FijfCFq3/5ZyKOh3x+0PA6frUyJrbtGSLBQJOeRufSlbQo9d6ssueFqCLEw== X-Received: by 2002:a05:6e02:c30:: with SMTP id q16mr14326866ilg.75.1626713619884; Mon, 19 Jul 2021 09:53:39 -0700 (PDT) Received: from gator ([140.82.166.162]) by smtp.gmail.com with ESMTPSA id c16sm10401695ilo.72.2021.07.19.09.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 09:53:39 -0700 (PDT) Date: Mon, 19 Jul 2021 18:53:37 +0200 From: Andrew Jones To: Yanan Wang Subject: Re: [PATCH for-6.2 v2 05/11] machine: Improve the error reporting of smp parsing Message-ID: <20210719165337.goazi5iwmmtz5jpg@gator> References: <20210719032043.25416-1-wangyanan55@huawei.com> <20210719032043.25416-6-wangyanan55@huawei.com> MIME-Version: 1.0 In-Reply-To: <20210719032043.25416-6-wangyanan55@huawei.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=drjones@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.469, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Daniel P =?utf-8?B?LiBCZXJyYW5nw6k=?= , Eduardo Habkost , "Michael S . Tsirkin" , wanghaibin.wang@huawei.com, Richard Henderson , qemu-devel@nongnu.org, Greg Kurz , Halil Pasic , Igor Mammedov , yuzenghui@huawei.com, Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Mon, Jul 19, 2021 at 11:20:37AM +0800, Yanan Wang wrote: > We totally have two requirements for a valid SMP configuration: s/totally// > the sum of "sockets * dies * cores * threads" must represent all the product > the possible cpus, i.e., max_cpus, and must include the initial > present cpus, i.e., smp_cpus. > > We only need to ensure "sockets * dies * cores * threads == maxcpus" > at first and then ensure "sockets * dies * cores * threads >= cpus". Or, "maxcpus >= cpus" > With a reasonable order of the sanity-check, we can simplify the > error reporting code. > > Signed-off-by: Yanan Wang > --- > hw/core/machine.c | 25 ++++++++++--------------- > 1 file changed, 10 insertions(+), 15 deletions(-) > > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 668f0a1553..8b4d07d3fc 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -788,21 +788,6 @@ static void smp_parse(MachineState *ms, SMPConfiguration *config, Error **errp) > cpus = cpus > 0 ? cpus : sockets * dies * cores * threads; > maxcpus = maxcpus > 0 ? maxcpus : cpus; > > - if (sockets * dies * cores * threads < cpus) { > - g_autofree char *dies_msg = g_strdup_printf( > - mc->smp_dies_supported ? " * dies (%u)" : "", dies); > - error_setg(errp, "cpu topology: " > - "sockets (%u)%s * cores (%u) * threads (%u) < " > - "smp_cpus (%u)", > - sockets, dies_msg, cores, threads, cpus); > - return; > - } > - > - if (maxcpus < cpus) { > - error_setg(errp, "maxcpus must be equal to or greater than smp"); > - return; > - } This may be redundant when determining a valid config, but by checking it separately we can provide a more useful error message. > - > if (sockets * dies * cores * threads != maxcpus) { > g_autofree char *dies_msg = g_strdup_printf( > mc->smp_dies_supported ? " * dies (%u)" : "", dies); > @@ -814,6 +799,16 @@ static void smp_parse(MachineState *ms, SMPConfiguration *config, Error **errp) > return; > } > > + if (sockets * dies * cores * threads < cpus) { > + g_autofree char *dies_msg = g_strdup_printf( > + mc->smp_dies_supported ? " * dies (%u)" : "", dies); > + error_setg(errp, "Invalid CPU topology: " > + "sockets (%u)%s * cores (%u) * threads (%u) < " > + "smp_cpus (%u)", > + sockets, dies_msg, cores, threads, cpus); > + return; > + } > + > ms->smp.cpus = cpus; > ms->smp.sockets = sockets; > ms->smp.dies = dies; > -- > 2.19.1 > I'm not sure we need this patch. Thanks, drew