Received: by 2002:ac2:54ba:0:0:0:0:0 with SMTP id w26csp3112966lfk; Tue, 25 Jan 2022 21:24:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm2b7PbQHALSktXN3QdVgPwg1PRwoR6jQKf8DW2u6/ChBqw9xdXN2/7cQiDtCN1O7cxgx0 X-Received: by 2002:a05:6902:351:: with SMTP id e17mr34901895ybs.205.1643174677644; Tue, 25 Jan 2022 21:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643174677; cv=none; d=google.com; s=arc-20160816; b=UHglnXEhIJbKci5V66mQJmgjMIFJ92qlgPVjCUJatWeD6nu3Qngz90mGMoy1fuvu0D 6Mf4VwPWXX8FCGwy9s88mDqmVzP4hZlm0ZtrgiVT6H2GXEBwJLMqKr2BTEXqdLHht60e 44LiAGDHnTl3xzWV1ynJBAYfWd3WSn65j3atsbJPerj1cgyFANhEShKHkBQammrypx9i EK9py3UQs3Ox7fPrubCWGNxpZhtXcVgObHTMKpjXzf7+LDfXHYSNjfiu97zkNK36Zagx l+wRpDZf+XhGtDqvo3KUQnistz9t4kdfdES7f6CKv2Ry7VnVdAovV8BGozAGVSsRbjEC 5LXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=dznFP3bgV41JRfvdifDcfP/ydWiArt86s9nanJ2wuwI=; b=i9Wmn5Ux2sW1xNLjfEv0SqUnuVDUViL2nRYUsBA4NFBIoFgASEk9dpvDdQbNPv5SeE 8M6E9auKrf+2TE01/gTZxIq5v2EahgwpoRnH0+96Xs5E/Sh2AR7t0zq1UqHOpd4xfyEF zAS1P1P2F/hcaZ5NgP22Jh4TVdnoLOVzrv2ezHJAsC9ZwaqAiGrCKeikzinz8deZCHhr NcKm0xKuOpE4bWj4f28gRehTBOxROpKaSBIoSuOi4KQ9nZDB3zpUnnsXu3uY44EClr2m 52bXaP6yZNjUjxOmJG6zW76qVfNP5zlIvZgkCcM8vQKXOqu5SBcdqgcujZPCNloHcOTx QoGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=YdOAnOkI; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e22si20069017yba.361.2022.01.25.21.24.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jan 2022 21:24:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=YdOAnOkI; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:50624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCanN-0001WV-3C for alex.bennee@linaro.org; Wed, 26 Jan 2022 00:24:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCanD-0001Vv-Sw for qemu-arm@nongnu.org; Wed, 26 Jan 2022 00:24:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51147) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCanB-00087q-W2 for qemu-arm@nongnu.org; Wed, 26 Jan 2022 00:24:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643174665; 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=YdOAnOkIXejmTJG82l3f6Inwq3f3kGgwVPV7jmxEH/WDWkwBOuEMwDYq2IsQ4awUDhOVxr 1gJrgPk/uA/HAGbfs7naFUWfyao1G77VqXD8p7CMSLhXKbJPLwProv0aM6GvcaLtEV6LXB kKGzmlMsWrw93+0natiLar+P0rxHyxQ= 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 X-MC-Unique: usonZEpEMQKmMFORtUz49g-1 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) 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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-arm@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-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: OAydBanqWmnw 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 guest is booted with the following command lines. /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ -accel kvm -machine virt,gic-version=host \ -cpu host \ -smp 6,sockets=2,cores=3,threads=1 \ -m 1024M,slots=16,maxmem=64G \ -object memory-backend-ram,id=mem0,size=128M \ -object memory-backend-ram,id=mem1,size=128M \ -object memory-backend-ram,id=mem2,size=128M \ -object memory-backend-ram,id=mem3,size=128M \ -object memory-backend-ram,id=mem4,size=128M \ -object memory-backend-ram,id=mem4,size=384M \ -numa node,nodeid=0,memdev=mem0 \ -numa node,nodeid=1,memdev=mem1 \ -numa node,nodeid=2,memdev=mem2 \ -numa node,nodeid=3,memdev=mem3 \ -numa node,nodeid=4,memdev=mem4 \ -numa node,nodeid=5,memdev=mem5 : 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 cpu_index) static int64_t virt_get_default_cpu_node_id(const MachineState *ms, int idx) { - return idx % ms->numa_state->num_nodes; + return idx / (ms->smp.dies * ms->smp.clusters * ms->smp.cores * ms->smp.threads); } static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) -- 2.23.0