From nobody Mon Feb 9 06:50:54 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625665394028943.9311515000037; Wed, 7 Jul 2021 06:43:14 -0700 (PDT) Received: from localhost ([::1]:58964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m17pY-0006tU-UG for importer@patchew.org; Wed, 07 Jul 2021 09:43:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m17nO-0003PT-VH for qemu-devel@nongnu.org; Wed, 07 Jul 2021 09:40:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m17nL-0005pa-BE for qemu-devel@nongnu.org; Wed, 07 Jul 2021 09:40:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-TPo8IhRCPauN-aZGm6aMmg-1; Wed, 07 Jul 2021 09:40:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B8D618414A0; Wed, 7 Jul 2021 13:40:51 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 705405D6AB; Wed, 7 Jul 2021 13:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625665254; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JA2dEBiX752pGOKGQK1EWz6l4XO4kSrIh3rxrRRVnAI=; b=ekhHv3/x6MNcZsZ/OnsNxTp8TqbUb6wtDSv+WLAuKRoT9G/Apl5K5gMnYknX1n1tMqD9iw ZTbf7NDFiTQaNF3ntfp3UY/+SyDSVVrt6krn7YB2evCyxPaUuPnSWaUEZHT3OXa0iSMexr Sfc8f+pTYjZXqFeifF9e1FGDZc/MUyo= X-MC-Unique: TPo8IhRCPauN-aZGm6aMmg-1 From: Michal Privoznik To: qemu-devel@nongnu.org Subject: [PATCH 2/2] numa: Parse initiator= attribute before cpus= attribute Date: Wed, 7 Jul 2021 15:40:30 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mprivozn@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mprivozn@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.439, 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: imammedo@redhat.com, tao3.xu@intel.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625665396131100001 Content-Type: text/plain; charset="utf-8" When parsing cpus=3D attribute of -numa object couple of checks is performed, such as correct initiator setting (see the if() statement at the end of for() loop in machine_set_cpu_numa_node()). However, with the current code cpus=3D attribute is parsed before initiator=3D attribute and thus the check may fail even though it is not obvious why. But since parsing the initiator=3D attribute does not depend on the cpus=3D attribute we can swap the order of the two. It's fairly easy to reproduce with the following command line (snippet of an actual cmd line): -smp 4,sockets=3D4,cores=3D1,threads=3D1 \ -object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":2147483= 648}' \ -numa node,nodeid=3D0,cpus=3D0-1,initiator=3D0,memdev=3Dram-node0 \ -object '{"qom-type":"memory-backend-ram","id":"ram-node1","size":2147483= 648}' \ -numa node,nodeid=3D1,cpus=3D2-3,initiator=3D1,memdev=3Dram-node1 \ -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacc= ess-latency,latency=3D5 \ -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dfirst-level,data-type= =3Daccess-latency,latency=3D10 \ -numa hmat-lb,initiator=3D1,target=3D1,hierarchy=3Dmemory,data-type=3Dacc= ess-latency,latency=3D5 \ -numa hmat-lb,initiator=3D1,target=3D1,hierarchy=3Dfirst-level,data-type= =3Daccess-latency,latency=3D10 \ -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacc= ess-bandwidth,bandwidth=3D204800K \ -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dfirst-level,data-type= =3Daccess-bandwidth,bandwidth=3D208896K \ -numa hmat-lb,initiator=3D1,target=3D1,hierarchy=3Dmemory,data-type=3Dacc= ess-bandwidth,bandwidth=3D204800K \ -numa hmat-lb,initiator=3D1,target=3D1,hierarchy=3Dfirst-level,data-type= =3Daccess-bandwidth,bandwidth=3D208896K \ -numa hmat-cache,node-id=3D0,size=3D10K,level=3D1,associativity=3Ddirect,= policy=3Dwrite-back,line=3D8 \ -numa hmat-cache,node-id=3D1,size=3D10K,level=3D1,associativity=3Ddirect,= policy=3Dwrite-back,line=3D8 \ Signed-off-by: Michal Privoznik Reviewed-by: Igor Mammedov --- hw/core/numa.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/hw/core/numa.c b/hw/core/numa.c index 1058d3697b..510d096a88 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -88,6 +88,29 @@ static void parse_numa_node(MachineState *ms, NumaNodeOp= tions *node, return; } =20 + /* + * If not set the initiator, set it to MAX_NODES. And if + * HMAT is enabled and this node has no cpus, QEMU will raise error. + */ + numa_info[nodenr].initiator =3D MAX_NODES; + if (node->has_initiator) { + if (!ms->numa_state->hmat_enabled) { + error_setg(errp, "ACPI Heterogeneous Memory Attribute Table " + "(HMAT) is disabled, enable it with -machine hmat= =3Don " + "before using any of hmat specific options"); + return; + } + + if (node->initiator >=3D MAX_NODES) { + error_report("The initiator id %" PRIu16 " expects an integer " + "between 0 and %d", node->initiator, + MAX_NODES - 1); + return; + } + + numa_info[nodenr].initiator =3D node->initiator; + } + for (cpus =3D node->cpus; cpus; cpus =3D cpus->next) { CpuInstanceProperties props; if (cpus->value >=3D max_cpus) { @@ -142,28 +165,6 @@ static void parse_numa_node(MachineState *ms, NumaNode= Options *node, numa_info[nodenr].node_memdev =3D MEMORY_BACKEND(o); } =20 - /* - * If not set the initiator, set it to MAX_NODES. And if - * HMAT is enabled and this node has no cpus, QEMU will raise error. - */ - numa_info[nodenr].initiator =3D MAX_NODES; - if (node->has_initiator) { - if (!ms->numa_state->hmat_enabled) { - error_setg(errp, "ACPI Heterogeneous Memory Attribute Table " - "(HMAT) is disabled, enable it with -machine hmat= =3Don " - "before using any of hmat specific options"); - return; - } - - if (node->initiator >=3D MAX_NODES) { - error_report("The initiator id %" PRIu16 " expects an integer " - "between 0 and %d", node->initiator, - MAX_NODES - 1); - return; - } - - numa_info[nodenr].initiator =3D node->initiator; - } numa_info[nodenr].present =3D true; max_numa_nodeid =3D MAX(max_numa_nodeid, nodenr + 1); ms->numa_state->num_nodes++; --=20 2.31.1