From nobody Thu May 9 08:40:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651615299; cv=none; d=zohomail.com; s=zohoarc; b=fxlfnzXHTs9CEdZjn4moM06FX/hFwEsxN4n1WmHtvhEyIBKrl1EK70SvOe0j2daAyu/Lb2xXhOEwL2/ocm7k4JgW8Kv2p+smJU6b6GIR4tEDmIG24nXb71jbcjO+/Z+0EHf2L1y/LuUqADMl/cYJQKUj6oZHV7+N1H4Ce+F+bRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651615299; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uCUtFbqM5mSd41jI/kJsuYvbaOhUPX++37Nx2wdTXOk=; b=EOKdwErLBdFya+omRPrs9cjl23UyhhbYWi/Ce+OYHM7hj7mXKsxyh6uwnOB+Xl6Ldf+MLWq7pgKJUwgM+2rAJ/dR9nF2LepnmF+GEH8g78jQ151l4EGYDuFl/+gc++fKNkApYReG66+fTnAIFqtETc7CT3TafKsOohZfik6/DCk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651615299696145.3272398543387; Tue, 3 May 2022 15:01:39 -0700 (PDT) Received: from localhost ([::1]:56670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nm0aP-0001wS-Nu for importer@patchew.org; Tue, 03 May 2022 18:01:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlzCQ-0007oG-TS for qemu-devel@nongnu.org; Tue, 03 May 2022 16:32:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44236) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlzCA-0000J5-LN for qemu-devel@nongnu.org; Tue, 03 May 2022 16:32:46 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-625-bEGqs_7qPVuw-dPATo5EJA-1; Tue, 03 May 2022 10:50:47 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 78A2E1D7F89D; Tue, 3 May 2022 14:03:27 +0000 (UTC) Received: from gshan.redhat.com (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3C4D1538411; Tue, 3 May 2022 14:03:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651609933; 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=uCUtFbqM5mSd41jI/kJsuYvbaOhUPX++37Nx2wdTXOk=; b=MCJvFnPnbrPqTDhu/tLPSS232rnkPH+3phSrVXzx2g+/FfpvvSwKSLtNkHvWhOWcL+bssh uS37pbtk6k8GNZZWIKOfOOmyWxzEMYToSsms5t9nNkz7Nq8vzM8+0CY+MAsbohQHbkZW+d RyoxpSJAqJzZMr8E3/au/4NSkWqyjHQ= X-MC-Unique: bEGqs_7qPVuw-dPATo5EJA-1 From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, peter.maydell@linaro.org, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, eblake@redhat.com, armbru@redhat.com, thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, berrange@redhat.com, Jonathan.Cameron@Huawei.com, drjones@redhat.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH v9 1/6] qapi/machine.json: Add cluster-id Date: Tue, 3 May 2022 22:02:59 +0800 Message-Id: <20220503140304.855514-2-gshan@redhat.com> In-Reply-To: <20220503140304.855514-1-gshan@redhat.com> References: <20220503140304.855514-1-gshan@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651615301455100001 Content-Type: text/plain; charset="utf-8" This adds cluster-id in CPU instance properties, which will be used by arm/virt machine. Besides, the cluster-id is also verified or dumped in various spots: * hw/core/machine.c::machine_set_cpu_numa_node() to associate CPU with its NUMA node. * hw/core/machine.c::machine_numa_finish_cpu_init() to record CPU slots with no NUMA mapping set. * hw/core/machine-hmp-cmds.c::hmp_hotpluggable_cpus() to dump cluster-id. Signed-off-by: Gavin Shan Reviewed-by: Yanan Wang Acked-by: Igor Mammedov --- hw/core/machine-hmp-cmds.c | 4 ++++ hw/core/machine.c | 16 ++++++++++++++++ qapi/machine.json | 6 ++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c index 4e2f319aeb..5cb5eecbfc 100644 --- a/hw/core/machine-hmp-cmds.c +++ b/hw/core/machine-hmp-cmds.c @@ -77,6 +77,10 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qd= ict) if (c->has_die_id) { monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id= ); } + if (c->has_cluster_id) { + monitor_printf(mon, " cluster-id: \"%" PRIu64 "\"\n", + c->cluster_id); + } if (c->has_core_id) { monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_= id); } diff --git a/hw/core/machine.c b/hw/core/machine.c index cb9bbc844d..700c1e76b8 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -682,6 +682,11 @@ void machine_set_cpu_numa_node(MachineState *machine, return; } =20 + if (props->has_cluster_id && !slot->props.has_cluster_id) { + error_setg(errp, "cluster-id is not supported"); + return; + } + if (props->has_socket_id && !slot->props.has_socket_id) { error_setg(errp, "socket-id is not supported"); return; @@ -701,6 +706,11 @@ void machine_set_cpu_numa_node(MachineState *machine, continue; } =20 + if (props->has_cluster_id && + props->cluster_id !=3D slot->props.cluster_id) { + continue; + } + if (props->has_die_id && props->die_id !=3D slot->props.die_id) { continue; } @@ -995,6 +1005,12 @@ static char *cpu_slot_to_string(const CPUArchId *cpu) } g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id); } + if (cpu->props.has_cluster_id) { + if (s->len) { + g_string_append_printf(s, ", "); + } + g_string_append_printf(s, "cluster-id: %"PRId64, cpu->props.cluste= r_id); + } if (cpu->props.has_core_id) { if (s->len) { g_string_append_printf(s, ", "); diff --git a/qapi/machine.json b/qapi/machine.json index d25a481ce4..4c417e32a5 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -868,10 +868,11 @@ # @node-id: NUMA node ID the CPU belongs to # @socket-id: socket number within node/board the CPU belongs to # @die-id: die number within socket the CPU belongs to (since 4.1) -# @core-id: core number within die the CPU belongs to +# @cluster-id: cluster number within die the CPU belongs to (since 7.1) +# @core-id: core number within cluster the CPU belongs to # @thread-id: thread number within core the CPU belongs to # -# Note: currently there are 5 properties that could be present +# Note: currently there are 6 properties that could be present # but management should be prepared to pass through other # properties with device_add command to allow for future # interface extension. This also requires the filed names to be kept= in @@ -883,6 +884,7 @@ 'data': { '*node-id': 'int', '*socket-id': 'int', '*die-id': 'int', + '*cluster-id': 'int', '*core-id': 'int', '*thread-id': 'int' } --=20 2.23.0 From nobody Thu May 9 08:40:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651607002; cv=none; d=zohomail.com; s=zohoarc; b=HTybs+QWS1a3ZgkUICIf0TXN4WnofREYrl91S4QX93xMbhrIdBNFd96EFEtPBCPCdY9qEmDMPmbXaX24EqrHCIN0Lmk+1v3mIQTijsRfHq2/WMK5j+2iC4IsHctfLcr0X5+P+bcObh1te0Tadn52LK3t+54UxiJWUuwHiwjm32o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651607002; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F2XMVZRhXOlDx/eBFdoKp2/tHA7MKrCIRZ8NQgPVxYc=; b=K6vhX7chKeEEzso5XszHrCzPy+U3ioBNMsJhUzXT/32dmdXxXUqrn68HsL9M/JxILNRffSDDV6yz9axGXwGXrtU2JDdmvmR4cDKT+6cgGwEGVFngXTKKCIQfgAMFqRHN8Zm7hq2ijur9HNA6vAwA/R4qKceHEjp7QsAJ94j6DDA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651607002053225.93052925235622; Tue, 3 May 2022 12:43:22 -0700 (PDT) Received: from localhost ([::1]:40390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlyQa-0007Wp-Hx for importer@patchew.org; Tue, 03 May 2022 15:43:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyOg-0005K1-FB for qemu-devel@nongnu.org; Tue, 03 May 2022 15:41:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyOe-0007T1-Rm for qemu-devel@nongnu.org; Tue, 03 May 2022 15:41:22 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-455-bxhqwJG8OlmLC0C_BUF4NQ-1; Tue, 03 May 2022 11:04:46 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C40B9109B93; Tue, 3 May 2022 14:03:36 +0000 (UTC) Received: from gshan.redhat.com (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A56C153841E; Tue, 3 May 2022 14:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651606749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F2XMVZRhXOlDx/eBFdoKp2/tHA7MKrCIRZ8NQgPVxYc=; b=YQpzOdHJJNE5oNz/8CnosipvB/ywzRGaC3WmsvNHPr5XVyukww1oKxEq81wb3xNovB8+rn G8GiMxK36ILg7TLOXs6+q5eP5PRa+oJB+yYd3jGfjEvmv5C+GOGANDt71ZCPr2kPT5tKzP Gpp7U86nVp+AKJS2IUJ8/WK6R+eBpC0= X-MC-Unique: bxhqwJG8OlmLC0C_BUF4NQ-1 From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, peter.maydell@linaro.org, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, eblake@redhat.com, armbru@redhat.com, thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, berrange@redhat.com, Jonathan.Cameron@Huawei.com, drjones@redhat.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH v9 2/6] qtest/numa-test: Specify CPU topology in aarch64_numa_cpu() Date: Tue, 3 May 2022 22:03:00 +0800 Message-Id: <20220503140304.855514-3-gshan@redhat.com> In-Reply-To: <20220503140304.855514-1-gshan@redhat.com> References: <20220503140304.855514-1-gshan@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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.129.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651607002559100001 The CPU topology isn't enabled on arm/virt machine yet, but we're going to do it in next patch. After the CPU topology is enabled by next patch, "thread-id=3D1" becomes invalid because the CPU core is preferred on arm/virt machine. It means these two CPUs have 0/1 as their core IDs, but their thread IDs are all 0. It will trigger test failure as the following message indicates: [14/21 qemu:qtest+qtest-aarch64 / qtest-aarch64/numa-test ERROR 1.48s killed by signal 6 SIGABRT >>> G_TEST_DBUS_DAEMON=3D/home/gavin/sandbox/qemu.main/tests/dbus-vmstate= -daemon.sh \ QTEST_QEMU_STORAGE_DAEMON_BINARY=3D./storage-daemon/qemu-storage-daem= on \ QTEST_QEMU_BINARY=3D./qemu-system-aarch64 = \ QTEST_QEMU_IMG=3D./qemu-img MALLOC_PERTURB_=3D83 = \ /home/gavin/sandbox/qemu.main/build/tests/qtest/numa-test --tap -k =E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95= =E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2= =80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80= =95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95= =E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95=E2= =80=95=E2=80=95=E2=80=95=E2=80=95=E2=80=95 stderr: qemu-system-aarch64: -numa cpu,node-id=3D0,thread-id=3D1: no match found This fixes the issue by providing comprehensive SMP configurations in aarch64_numa_cpu(). The SMP configurations aren't used before the CPU topology is enabled in next patch. Signed-off-by: Gavin Shan Reviewed-by: Yanan Wang --- tests/qtest/numa-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c index 90bf68a5b3..aeda8c774c 100644 --- a/tests/qtest/numa-test.c +++ b/tests/qtest/numa-test.c @@ -223,7 +223,8 @@ static void aarch64_numa_cpu(const void *data) QTestState *qts; g_autofree char *cli =3D NULL; =20 - cli =3D make_cli(data, "-machine smp.cpus=3D2 " + cli =3D make_cli(data, "-machine " + "smp.cpus=3D2,smp.sockets=3D1,smp.clusters=3D1,smp.cores=3D1,smp.t= hreads=3D2 " "-numa node,nodeid=3D0,memdev=3Dram -numa node,nodeid=3D1 " "-numa cpu,node-id=3D1,thread-id=3D0 " "-numa cpu,node-id=3D0,thread-id=3D1"); --=20 2.23.0 From nobody Thu May 9 08:40:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651609059; cv=none; d=zohomail.com; s=zohoarc; b=OsqgRlnK6c1KzYpkW+F3XqeiZ7ftIoEH2ixteKfDqPYDSNRzrU+gpy1iVs2P/u/drNcycS/QHZI2ADzFA+OdyEColK+3ndx+v7yKsenhQYAt2pk+HIdT2um4VrZ+73pj+fy+ZNrBafQhX7EV5zuu8JQ0REcfXVUirTyWYLnvelA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651609059; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wb+HwdpyJ9dw60dXoi/U59AE2ghgLZsYlO7tUAbe2x4=; b=GTZgaLTaJ9naaDWBWN+bsr4lLPwMSvU3tpFhDgXUrsbVo3dOZfHOt0qzWXfDqwic3v6KG0Y8D3AFDWxbPo32D7XO0Ddhz01O9B2+pjhZCfequCx1Gjl3R/Fw5W6hI4BdEwWTjbKTVdbhvKKWTE+9+AwH6pxSXE4q7foaDPgnDi4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651609059208437.16110900542196; Tue, 3 May 2022 13:17:39 -0700 (PDT) Received: from localhost ([::1]:48234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlyxm-00048N-0Q for importer@patchew.org; Tue, 03 May 2022 16:17:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyXQ-0004RC-DE for qemu-devel@nongnu.org; Tue, 03 May 2022 15:50:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46269) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyXO-0004f1-O3 for qemu-devel@nongnu.org; Tue, 03 May 2022 15:50:24 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-139-oQurqTgpNtu6-Mnd2b_Pfw-1; Tue, 03 May 2022 11:04:38 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 60F26109BB4; Tue, 3 May 2022 14:03:47 +0000 (UTC) Received: from gshan.redhat.com (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96274153AD00; Tue, 3 May 2022 14:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651607421; 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=wb+HwdpyJ9dw60dXoi/U59AE2ghgLZsYlO7tUAbe2x4=; b=ZY/BF6E/lyWxuG1EvfUioRwq+yLrx3Ed4PINdLI7VWlnbKdOpVRBno4MSdiO30pLv3V0n+ CEBskRrLcccD7CAqB/blpQ4ZsPXD7X/i95X1T/jSnwWQ5tj+xUH9jINGCI3Jo0FvusWI+b Tfp1PYRi7aQ4uHywHa1Jo53vTCwxOmQ= X-MC-Unique: oQurqTgpNtu6-Mnd2b_Pfw-1 From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, peter.maydell@linaro.org, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, eblake@redhat.com, armbru@redhat.com, thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, berrange@redhat.com, Jonathan.Cameron@Huawei.com, drjones@redhat.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH v9 3/6] hw/arm/virt: Consider SMP configuration in CPU topology Date: Tue, 3 May 2022 22:03:01 +0800 Message-Id: <20220503140304.855514-4-gshan@redhat.com> In-Reply-To: <20220503140304.855514-1-gshan@redhat.com> References: <20220503140304.855514-1-gshan@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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.129.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651609060119100001 Content-Type: text/plain; charset="utf-8" Currently, the SMP configuration isn't considered when the CPU topology is populated. In this case, it's impossible to provide the default CPU-to-NUMA mapping or association based on the socket ID of the given CPU. This takes account of SMP configuration when the CPU topology is populated. The die ID for the given CPU isn't assigned since it's not supported on arm/virt machine. Besides, the used SMP configuration in qtest/numa-test/aarch64_numa_cpu() is corrcted to avoid testing failure Signed-off-by: Gavin Shan Reviewed-by: Yanan Wang Acked-by: Igor Mammedov --- hw/arm/virt.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index f94278935f..6df3981b1e 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2560,6 +2560,7 @@ static const CPUArchIdList *virt_possible_cpu_arch_id= s(MachineState *ms) int n; unsigned int max_cpus =3D ms->smp.max_cpus; VirtMachineState *vms =3D VIRT_MACHINE(ms); + MachineClass *mc =3D MACHINE_GET_CLASS(vms); =20 if (ms->possible_cpus) { assert(ms->possible_cpus->len =3D=3D max_cpus); @@ -2573,8 +2574,20 @@ static const CPUArchIdList *virt_possible_cpu_arch_i= ds(MachineState *ms) ms->possible_cpus->cpus[n].type =3D ms->cpu_type; ms->possible_cpus->cpus[n].arch_id =3D virt_cpu_mp_affinity(vms, n); + + assert(!mc->smp_props.dies_supported); + ms->possible_cpus->cpus[n].props.has_socket_id =3D true; + ms->possible_cpus->cpus[n].props.socket_id =3D + n / (ms->smp.clusters * ms->smp.cores * ms->smp.threads); + ms->possible_cpus->cpus[n].props.has_cluster_id =3D true; + ms->possible_cpus->cpus[n].props.cluster_id =3D + (n / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters; + ms->possible_cpus->cpus[n].props.has_core_id =3D true; + ms->possible_cpus->cpus[n].props.core_id =3D + (n / ms->smp.threads) % ms->smp.cores; ms->possible_cpus->cpus[n].props.has_thread_id =3D true; - ms->possible_cpus->cpus[n].props.thread_id =3D n; + ms->possible_cpus->cpus[n].props.thread_id =3D + n % ms->smp.threads; } return ms->possible_cpus; } --=20 2.23.0 From nobody Thu May 9 08:40:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651618727; cv=none; d=zohomail.com; s=zohoarc; b=SWpGO/JV+wTO2kWpRB4QVDR4wUJDhIZMUsLZIuSh1LGYdMvWGApxdTJof4GgvFH1IN6ZhgPYZ1WOqaS6imPsUWdzuiOrLsbNMDWwViWk0Tsgq18qPRK4z6MrVIjCHZhCvLcaT5wusrGizfOuD0IQO1EkYYvGw4SUwpjbIWpDu9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651618727; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PRRBSuZMlS0NuMI/73XgyFnKvZLkb8oTAQ6CRh93DEU=; b=P9aYAisZvEafU79FNxAJRbwK1WRSnWhMyABSXRoFGI6ULAIYTUuevGadPrJdJuvNPgoT3VihLc7VpYigAt6wP9sidMNQZpVLcQ8zj8NwXpXB20nbxoygkEiGIGo7kvq/hVIpBI4luW5NXzXMELtUpfglUWOyrgE4eQr+QtWUXao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651618727031673.5959304414461; Tue, 3 May 2022 15:58:47 -0700 (PDT) Received: from localhost ([::1]:56398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nm1Th-0002QQ-Hq for importer@patchew.org; Tue, 03 May 2022 18:58:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nm0ZR-0001ie-6P for qemu-devel@nongnu.org; Tue, 03 May 2022 18:00:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nm0ZP-0003n5-EH for qemu-devel@nongnu.org; Tue, 03 May 2022 18:00:36 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-355-VAeflOJkPlS2jXJcm5AQzQ-1; Tue, 03 May 2022 10:10:40 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F367F1487994; Tue, 3 May 2022 14:03:56 +0000 (UTC) Received: from gshan.redhat.com (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29FA0153AD00; Tue, 3 May 2022 14:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651615234; 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=PRRBSuZMlS0NuMI/73XgyFnKvZLkb8oTAQ6CRh93DEU=; b=YM6bPOeUrgx9rditDNvoHLrjHGjHef6lLZIw16SFjg5S1TCds/C/TGLpElu7qJHNytiBvA eCUkf/5SlwweL/5aHKAGN0n6SnY4gtQ6MyT1X8LNO2ntmWmZZFNWIoMQC7CpM6k6xq+40S kZBaD3eGLOqg2L2uzrXRz7JdLC8YHUo= X-MC-Unique: VAeflOJkPlS2jXJcm5AQzQ-1 From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, peter.maydell@linaro.org, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, eblake@redhat.com, armbru@redhat.com, thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, berrange@redhat.com, Jonathan.Cameron@Huawei.com, drjones@redhat.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH v9 4/6] qtest/numa-test: Correct CPU and NUMA association in aarch64_numa_cpu() Date: Tue, 3 May 2022 22:03:02 +0800 Message-Id: <20220503140304.855514-5-gshan@redhat.com> In-Reply-To: <20220503140304.855514-1-gshan@redhat.com> References: <20220503140304.855514-1-gshan@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651618728998100001 Content-Type: text/plain; charset="utf-8" In aarch64_numa_cpu(), the CPU and NUMA association is something like below. Two threads in the same core/cluster/socket are associated with two individual NUMA nodes, which is unreal as Igor Mammedov mentioned. We don't expect the association to break NUMA-to-socket boundary, which matches with the real world. NUMA-node socket cluster core thread ------------------------------------------ 0 0 0 0 0 1 0 0 0 1 This corrects the topology for CPUs and their association with NUMA nodes. After this patch is applied, the CPU and NUMA association becomes something like below, which looks real. Besides, socket/cluster/core/thread IDs are all checked when the NUMA node IDs are verified. It helps to check if the CPU topology is properly populated or not. NUMA-node socket cluster core thread ------------------------------------------ 0 1 0 0 0 1 0 0 0 0 Suggested-by: Igor Mammedov Signed-off-by: Gavin Shan Acked-by: Igor Mammedov --- tests/qtest/numa-test.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c index aeda8c774c..32e35daaae 100644 --- a/tests/qtest/numa-test.c +++ b/tests/qtest/numa-test.c @@ -224,17 +224,17 @@ static void aarch64_numa_cpu(const void *data) g_autofree char *cli =3D NULL; =20 cli =3D make_cli(data, "-machine " - "smp.cpus=3D2,smp.sockets=3D1,smp.clusters=3D1,smp.cores=3D1,smp.t= hreads=3D2 " + "smp.cpus=3D2,smp.sockets=3D2,smp.clusters=3D1,smp.cores=3D1,smp.t= hreads=3D1 " "-numa node,nodeid=3D0,memdev=3Dram -numa node,nodeid=3D1 " - "-numa cpu,node-id=3D1,thread-id=3D0 " - "-numa cpu,node-id=3D0,thread-id=3D1"); + "-numa cpu,node-id=3D0,socket-id=3D1,cluster-id=3D0,core-id=3D0,th= read-id=3D0 " + "-numa cpu,node-id=3D1,socket-id=3D0,cluster-id=3D0,core-id=3D0,th= read-id=3D0"); qts =3D qtest_init(cli); cpus =3D get_cpus(qts, &resp); g_assert(cpus); =20 while ((e =3D qlist_pop(cpus))) { QDict *cpu, *props; - int64_t thread, node; + int64_t socket, cluster, core, thread, node; =20 cpu =3D qobject_to(QDict, e); g_assert(qdict_haskey(cpu, "props")); @@ -242,12 +242,18 @@ static void aarch64_numa_cpu(const void *data) =20 g_assert(qdict_haskey(props, "node-id")); node =3D qdict_get_int(props, "node-id"); + g_assert(qdict_haskey(props, "socket-id")); + socket =3D qdict_get_int(props, "socket-id"); + g_assert(qdict_haskey(props, "cluster-id")); + cluster =3D qdict_get_int(props, "cluster-id"); + g_assert(qdict_haskey(props, "core-id")); + core =3D qdict_get_int(props, "core-id"); g_assert(qdict_haskey(props, "thread-id")); thread =3D qdict_get_int(props, "thread-id"); =20 - if (thread =3D=3D 0) { + if (socket =3D=3D 0 && cluster =3D=3D 0 && core =3D=3D 0 && thread= =3D=3D 0) { g_assert_cmpint(node, =3D=3D, 1); - } else if (thread =3D=3D 1) { + } else if (socket =3D=3D 1 && cluster =3D=3D 0 && core =3D=3D 0 &&= thread =3D=3D 0) { g_assert_cmpint(node, =3D=3D, 0); } else { g_assert(false); --=20 2.23.0 From nobody Thu May 9 08:40:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651614138; cv=none; d=zohomail.com; s=zohoarc; b=gZ36bnXUSs3mRmtVYLZurbD6TnhFMKjXeO3mS0kbiYy9J2/t9Emp1xCum14LVRNQ8qCQHmq6/aWOquJtnUsDiRI11Odo1fZjfx0SXn/Z8nASgwCiHzWzmUTF2wXSCyobWlE8Miw6Nzc/dD+3nkMFc44CzU8LY8xjWzaayjyOhFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651614138; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gr6Vz9OGm9QeWjjKnSfDc7wJml3ls6mGEGPhiIEQjeo=; b=ESj7DkK7N5kcqYykavrdHbwbcs8gw0HyMA+xrsWjWwPFTA+RqGHQ4m0OGYjZJ/wgMibDk/8QZYGifXYoUgG9TrFlTecLbhMx0Bubpw+dUzUY+FAWlLtu5eXyjy5PzuMoPO4hxJxHs+32XiUX1Jm+KXvolucxFpb3NHYUyzvLsaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651614138815996.3068453743082; Tue, 3 May 2022 14:42:18 -0700 (PDT) Received: from localhost ([::1]:45356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nm0Hh-0005pN-Pr for importer@patchew.org; Tue, 03 May 2022 17:42:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlywJ-0002wo-L5 for qemu-devel@nongnu.org; Tue, 03 May 2022 16:16:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlywH-0003UO-U6 for qemu-devel@nongnu.org; Tue, 03 May 2022 16:16:07 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-543-Oa7jqMrJNGGcjRVfRr464w-1; Tue, 03 May 2022 10:42:19 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E174399C5AF; Tue, 3 May 2022 14:04:06 +0000 (UTC) Received: from gshan.redhat.com (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7755153AD00; Tue, 3 May 2022 14:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651608964; 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=Gr6Vz9OGm9QeWjjKnSfDc7wJml3ls6mGEGPhiIEQjeo=; b=VUaRb13gPg3wcA9aUGEhsyNBJ5wM4uMSDBtj5aGD6Ess3+iI8RIOmUE/Avev+gT5uwLwAM xDwc6EwuSJaReYsLtEBBb4T5BttBYE9CLmvTUS/Z8WZvrZs8iEVFb7Afg5Xgq42nOjZKX6 DjOvBQElUgerwfsR2LQO/oj4Qmbb7Bc= X-MC-Unique: Oa7jqMrJNGGcjRVfRr464w-1 From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, peter.maydell@linaro.org, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, eblake@redhat.com, armbru@redhat.com, thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, berrange@redhat.com, Jonathan.Cameron@Huawei.com, drjones@redhat.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH v9 5/6] hw/arm/virt: Fix CPU's default NUMA node ID Date: Tue, 3 May 2022 22:03:03 +0800 Message-Id: <20220503140304.855514-6-gshan@redhat.com> In-Reply-To: <20220503140304.855514-1-gshan@redhat.com> References: <20220503140304.855514-1-gshan@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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.129.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651614141770100001 Content-Type: text/plain; charset="utf-8" When CPU-to-NUMA association isn't explicitly provided by users, the default one is given by mc->get_default_cpu_node_id(). However, the CPU topology isn't fully considered in the default association and this causes CPU topology broken warnings on booting Linux guest. For example, the following warning messages are observed when the Linux guest 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 ID when the default CPU-to-NUMA association is provided in virt_possible_cpu_arch_ids(). 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 Reviewed-by: Igor Mammedov Reviewed-by: Yanan Wang --- hw/arm/virt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6df3981b1e..766c9acd7f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2552,7 +2552,9 @@ 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; + int64_t socket_id =3D ms->possible_cpus->cpus[idx].props.socket_id; + + return socket_id % ms->numa_state->num_nodes; } =20 static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) --=20 2.23.0 From nobody Thu May 9 08:40:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651613513; cv=none; d=zohomail.com; s=zohoarc; b=mYuZMxgkKXyzj1PzFaZ1XP3C1fNWaJDR1UfZ12oZT4JQirmfSCcYEdMV1ydB7/1MQvgmPAhQSEKfEdJcrQLHEG8Pg5yiTypm0xCBG9/g1lPt4UgGdyts9kcTLGO8iz4iQ2ySL2FfNqiZ9Qe5CKta4deA4CotUPPJ7xxwsTYbjOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651613513; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ij22TRKHMBWJRY8XZ1BtVkL5983598AMxqypVYRPyC0=; b=Y91JvCbNUwa1VneeuLOXzyzmHrFEdTOTf+xdC4pXTe70Qds4aTZYQx/bkFs26PcWgtTg7AVHff6/oWRKAEgUIhnIGc+R5zscvcuGbnQVu19e+X7XG8PEEKrtosHg6GSHhTNoFcaquDJil0lKXJkksq4wYRsr/MOi1hHX1QDnUzk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651613513486646.9159433194159; Tue, 3 May 2022 14:31:53 -0700 (PDT) Received: from localhost ([::1]:51220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nm07c-0006qL-5p for importer@patchew.org; Tue, 03 May 2022 17:31:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyuY-0000i4-NF for qemu-devel@nongnu.org; Tue, 03 May 2022 16:14:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41603) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyuX-0002yf-06 for qemu-devel@nongnu.org; Tue, 03 May 2022 16:14:18 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-262-JZe9ILJgO2eJmGxSMRPqwA-1; Tue, 03 May 2022 10:49:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20DB31D808EB; Tue, 3 May 2022 14:04:16 +0000 (UTC) Received: from gshan.redhat.com (ovpn-12-47.pek2.redhat.com [10.72.12.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D48A1537ED9; Tue, 3 May 2022 14:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651608856; 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=ij22TRKHMBWJRY8XZ1BtVkL5983598AMxqypVYRPyC0=; b=ZjsmBM7J3JbjhkpqHuTOsAtZNkrUMSWL36uAYvKHIrcdLh9untAQEEj6Lif+4O4Nv/GZce o+y0qp2j0j0OPxR8ywUbUZ0mEw5nrnwj4E9TLyGhdoLPLyjduq4Lb1KGgo0aS7v73Fpo+h NkAGBiqqyVL51Ytj2CwsGcQysgq0NV8= X-MC-Unique: JZe9ILJgO2eJmGxSMRPqwA-1 From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, peter.maydell@linaro.org, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, eblake@redhat.com, armbru@redhat.com, thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, berrange@redhat.com, Jonathan.Cameron@Huawei.com, drjones@redhat.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH v9 6/6] hw/acpi/aml-build: Use existing CPU topology to build PPTT table Date: Tue, 3 May 2022 22:03:04 +0800 Message-Id: <20220503140304.855514-7-gshan@redhat.com> In-Reply-To: <20220503140304.855514-1-gshan@redhat.com> References: <20220503140304.855514-1-gshan@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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.129.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651613517721100001 Content-Type: text/plain; charset="utf-8" When the PPTT table is built, the CPU topology is re-calculated, but it's unecessary because the CPU topology has been populated in virt_possible_cpu_arch_ids() on arm/virt machine. This reworks build_pptt() to avoid by reusing the existing IDs in ms->possible_cpus. Currently, the only user of build_pptt() is arm/virt machine. Signed-off-by: Gavin Shan Tested-by: Yanan Wang Reviewed-by: Yanan Wang Acked-by: Igor Mammedov --- hw/acpi/aml-build.c | 111 +++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 63 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 4086879ebf..e6bfac95c7 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -2002,86 +2002,71 @@ void build_pptt(GArray *table_data, BIOSLinker *lin= ker, MachineState *ms, const char *oem_id, const char *oem_table_id) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); - GQueue *list =3D g_queue_new(); - guint pptt_start =3D table_data->len; - guint parent_offset; - guint length, i; - int uid =3D 0; - int socket; + CPUArchIdList *cpus =3D ms->possible_cpus; + int64_t socket_id =3D -1, cluster_id =3D -1, core_id =3D -1; + uint32_t socket_offset =3D 0, cluster_offset =3D 0, core_offset =3D 0; + uint32_t pptt_start =3D table_data->len; + int n; AcpiTable table =3D { .sig =3D "PPTT", .rev =3D 2, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 acpi_table_begin(&table, table_data); =20 - for (socket =3D 0; socket < ms->smp.sockets; socket++) { - g_queue_push_tail(list, - GUINT_TO_POINTER(table_data->len - pptt_start)); - build_processor_hierarchy_node( - table_data, - /* - * Physical package - represents the boundary - * of a physical package - */ - (1 << 0), - 0, socket, NULL, 0); - } - - if (mc->smp_props.clusters_supported) { - length =3D g_queue_get_length(list); - for (i =3D 0; i < length; i++) { - int cluster; - - parent_offset =3D GPOINTER_TO_UINT(g_queue_pop_head(list)); - for (cluster =3D 0; cluster < ms->smp.clusters; cluster++) { - g_queue_push_tail(list, - GUINT_TO_POINTER(table_data->len - pptt_start)); - build_processor_hierarchy_node( - table_data, - (0 << 0), /* not a physical package */ - parent_offset, cluster, NULL, 0); - } + /* + * This works with the assumption that cpus[n].props.*_id has been + * sorted from top to down levels in mc->possible_cpu_arch_ids(). + * Otherwise, the unexpected and duplicated containers will be + * created. + */ + for (n =3D 0; n < cpus->len; n++) { + if (cpus->cpus[n].props.socket_id !=3D socket_id) { + assert(cpus->cpus[n].props.socket_id > socket_id); + socket_id =3D cpus->cpus[n].props.socket_id; + cluster_id =3D -1; + core_id =3D -1; + socket_offset =3D table_data->len - pptt_start; + build_processor_hierarchy_node(table_data, + (1 << 0), /* Physical package */ + 0, socket_id, NULL, 0); } - } =20 - length =3D g_queue_get_length(list); - for (i =3D 0; i < length; i++) { - int core; - - parent_offset =3D GPOINTER_TO_UINT(g_queue_pop_head(list)); - for (core =3D 0; core < ms->smp.cores; core++) { - if (ms->smp.threads > 1) { - g_queue_push_tail(list, - GUINT_TO_POINTER(table_data->len - pptt_start)); - build_processor_hierarchy_node( - table_data, - (0 << 0), /* not a physical package */ - parent_offset, core, NULL, 0); - } else { - build_processor_hierarchy_node( - table_data, - (1 << 1) | /* ACPI Processor ID valid */ - (1 << 3), /* Node is a Leaf */ - parent_offset, uid++, NULL, 0); + if (mc->smp_props.clusters_supported) { + if (cpus->cpus[n].props.cluster_id !=3D cluster_id) { + assert(cpus->cpus[n].props.cluster_id > cluster_id); + cluster_id =3D cpus->cpus[n].props.cluster_id; + core_id =3D -1; + cluster_offset =3D table_data->len - pptt_start; + build_processor_hierarchy_node(table_data, + (0 << 0), /* Not a physical package */ + socket_offset, cluster_id, NULL, 0); } + } else { + cluster_offset =3D socket_offset; } - } =20 - length =3D g_queue_get_length(list); - for (i =3D 0; i < length; i++) { - int thread; + if (ms->smp.threads =3D=3D 1) { + build_processor_hierarchy_node(table_data, + (1 << 1) | /* ACPI Processor ID valid */ + (1 << 3), /* Node is a Leaf */ + cluster_offset, n, NULL, 0); + } else { + if (cpus->cpus[n].props.core_id !=3D core_id) { + assert(cpus->cpus[n].props.core_id > core_id); + core_id =3D cpus->cpus[n].props.core_id; + core_offset =3D table_data->len - pptt_start; + build_processor_hierarchy_node(table_data, + (0 << 0), /* Not a physical package */ + cluster_offset, core_id, NULL, 0); + } =20 - parent_offset =3D GPOINTER_TO_UINT(g_queue_pop_head(list)); - for (thread =3D 0; thread < ms->smp.threads; thread++) { - build_processor_hierarchy_node( - table_data, + build_processor_hierarchy_node(table_data, (1 << 1) | /* ACPI Processor ID valid */ (1 << 2) | /* Processor is a Thread */ (1 << 3), /* Node is a Leaf */ - parent_offset, uid++, NULL, 0); + core_offset, n, NULL, 0); } } =20 - g_queue_free(list); acpi_table_end(linker, &table); } =20 --=20 2.23.0