From nobody Fri May 3 04:10:39 2024 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 1643174718444129.4468040803124; Tue, 25 Jan 2022 21:25:18 -0800 (PST) Received: from localhost ([::1]:51918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCao0-0002OH-Nz for importer@patchew.org; Wed, 26 Jan 2022 00:25:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCanD-0001Vw-Ss for qemu-devel@nongnu.org; Wed, 26 Jan 2022 00:24:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCanA-00087k-H5 for qemu-devel@nongnu.org; Wed, 26 Jan 2022 00:24:27 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-usonZEpEMQKmMFORtUz49g-1; Wed, 26 Jan 2022 00:24:18 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8C7D01853026; Wed, 26 Jan 2022 05:24:17 +0000 (UTC) Received: from gshan.redhat.com (ovpn-12-154.pek2.redhat.com [10.72.12.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6810F4E2A6; Wed, 26 Jan 2022 05:24:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643174663; 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; bh=dznFP3bgV41JRfvdifDcfP/ydWiArt86s9nanJ2wuwI=; b=avBh44iXh9drgklHLAW5TFc3Odym6mQMtRUcPSMdwbGZ5+0qU/ZgPQMrzraMVvGJ3VlLqu MOYPgMxj2stadAd0BwM5ZS0hw7jFWyJKPFIaOsUktBIePltVIg6ZWRG+IhBvI+bhl7CEZm s0HJmzDSbm1TTyaRX9x+tdPYocWwM60= X-MC-Unique: usonZEpEMQKmMFORtUz49g-1 From: Gavin Shan To: qemu-arm@nongnu.org Subject: [PATCH] hw/arm/virt: Fix CPU's default NUMA node ID Date: Wed, 26 Jan 2022 13:24:10 +0800 Message-Id: <20220126052410.36380-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=gshan@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=170.10.133.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.158, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, shan.gavin@gmail.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: 1643174719785100001 Content-Type: text/plain; charset="utf-8" The default CPU-to-NUMA association is given by mc->get_default_cpu_node_id= () when it isn't provided explicitly. However, the CPU topology isn't fully considered in the default association and it causes CPU topology broken warnings on booting Linux guest. For example, the following warning messages are observed when the Linux gue= st is booted with the following command lines. /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ -accel kvm -machine virt,gic-version=3Dhost \ -cpu host \ -smp 6,sockets=3D2,cores=3D3,threads=3D1 \ -m 1024M,slots=3D16,maxmem=3D64G \ -object memory-backend-ram,id=3Dmem0,size=3D128M \ -object memory-backend-ram,id=3Dmem1,size=3D128M \ -object memory-backend-ram,id=3Dmem2,size=3D128M \ -object memory-backend-ram,id=3Dmem3,size=3D128M \ -object memory-backend-ram,id=3Dmem4,size=3D128M \ -object memory-backend-ram,id=3Dmem4,size=3D384M \ -numa node,nodeid=3D0,memdev=3Dmem0 \ -numa node,nodeid=3D1,memdev=3Dmem1 \ -numa node,nodeid=3D2,memdev=3Dmem2 \ -numa node,nodeid=3D3,memdev=3Dmem3 \ -numa node,nodeid=3D4,memdev=3Dmem4 \ -numa node,nodeid=3D5,memdev=3Dmem5 : alternatives: patching kernel code BUG: arch topology borken the CLS domain not a subset of the MC domain BUG: arch topology borken the DIE domain not a subset of the NODE domain With current implementation of mc->get_default_cpu_node_id(), CPU#0 to CPU#5 are associated with NODE#0 to NODE#5 separately. That's incorrect because CPU#0/1/2 should be associated with same NUMA node because they're seated in same socket. This fixes the issue by considering the socket when default CPU-to-NUMA is given. With this applied, no more CPU topology broken warnings are seen from the Linux guest. The 6 CPUs are associated with NODE#0/1, but there are no CPUs associated with NODE#2/3/4/5. Signed-off-by: Gavin Shan --- hw/arm/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 141350bf21..b4a95522d3 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2499,7 +2499,7 @@ virt_cpu_index_to_props(MachineState *ms, unsigned cp= u_index) =20 static int64_t virt_get_default_cpu_node_id(const MachineState *ms, int id= x) { - return idx % ms->numa_state->num_nodes; + return idx / (ms->smp.dies * ms->smp.clusters * ms->smp.cores * ms->sm= p.threads); } =20 static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) --=20 2.23.0