Received: by 2002:a19:e348:0:0:0:0:0 with SMTP id c8csp1429109lfk; Sun, 17 Apr 2022 19:11:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5u1PybrSbzFeOx4FRNFOUHsfhyV4XTY+5LWBQydeUQKtAULxVhPIOziUxc7e5AS4iNRIL X-Received: by 2002:a05:620a:30a:b0:69c:10ef:c87f with SMTP id s10-20020a05620a030a00b0069c10efc87fmr5289182qkm.634.1650247898789; Sun, 17 Apr 2022 19:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650247898; cv=none; d=google.com; s=arc-20160816; b=g9r4K0riLyu76oo0nKNND1f/OaYRMZAtFPqfgGUJpS8WGb+94KRzeG6U2Ew7dslVKN rDPdQomTgzcHkEj5oJfuSuqKnoYHuJUboKLgtb04ENdnI/11gORsPAGNUE7rlKpWOCf8 4PTlhNatgMq8ZZpGqHD6EYRXgpGQ/r5q0PJalTpVoYenGWVBHuiAVopgQBjUVlT/99xZ FpRzR1io+PbIyvURDgksT4BcaK7EYseDhBzMWOMIov48wcTiZ7EEZKF+PF4b32AFYCZ2 ukGEt3tmGMtUHmCbzc1pz9MFMAEmrk64ehx5mkqL8SU75hfBEsRjyyzDxdOcZGA2aJS2 07Pw== 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:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qfJEE3/IG/WPlZJ9pG2XcS77Ozmlz/hB9OcChPelWtg=; b=HHP74e8GQmDHc8pMfrRj+IGRWJqLGfA01B3lMxdm2nwjZ+331bslH8Kzmh3SvsbIE5 542YYm0iMBlUGYXq4C4rqMDf3witg44CJ0axYogcdAkgUthKEMgXD9r09qeZ4zvZHnJ9 FtF0QvRCduRvUQZ9NJHSQwUlVkc5ZIJN03dN0DQ/R08f/R6au5fbMiD2AX0HRd7GIhvz 9Vra7RLAstmcz4B2lvRlowVpH0ru+LVBVITc8OJ/DWpzbf8K/mPxERDhYWNn5Z76w9C8 x1OaLDfgiTzZcKfzode6lca3rskIY7bx7zht2VVZrRhXGIEa7pv4dHmJWVe+QAjTUGm9 QYTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=GDmaZJ3c; 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 gf12-20020a056214250c00b004413dfec33csi2541566qvb.308.2022.04.17.19.11.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Apr 2022 19:11:38 -0700 (PDT) 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=GDmaZJ3c; 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]:52328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngGra-0004Q9-8l for alex.bennee@linaro.org; Sun, 17 Apr 2022 22:11:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngGrN-0004My-VE for qemu-arm@nongnu.org; Sun, 17 Apr 2022 22:11:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngGrM-00014h-BC for qemu-arm@nongnu.org; Sun, 17 Apr 2022 22:11:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650247882; 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=qfJEE3/IG/WPlZJ9pG2XcS77Ozmlz/hB9OcChPelWtg=; b=GDmaZJ3cqjmGXvM0Z6g22GYrZAQ9aFhyVmtDYa/WttlL4Ti1WMhdLJvbh/Yym1ESnTpKxm INBz0fq4J65cFu9TxgrqnJoiY6bwmvZzvRQmb+geQIUtdbq0LSIfWaw40UTdFJY/F+fDPA S2Lmc+MU9X3CuWx7JJXCZaHiCivwBXQ= 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-1-QDJOkKjHN3azBLWrDFuRGg-1; Sun, 17 Apr 2022 22:11:19 -0400 X-MC-Unique: QDJOkKjHN3azBLWrDFuRGg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A0C721C05EA4; Mon, 18 Apr 2022 02:11:18 +0000 (UTC) Received: from gshan.redhat.com (ovpn-13-171.pek2.redhat.com [10.72.13.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 202D11121333; Mon, 18 Apr 2022 02:11:03 +0000 (UTC) From: Gavin Shan To: qemu-arm@nongnu.org Subject: [PATCH v6 3/4] hw/arm/virt: Fix CPU's default NUMA node ID Date: Mon, 18 Apr 2022 10:09:19 +0800 Message-Id: <20220418020920.144263-4-gshan@redhat.com> In-Reply-To: <20220418020920.144263-1-gshan@redhat.com> References: <20220418020920.144263-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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.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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eduardo@habkost.net, peter.maydell@linaro.org, drjones@redhat.com, shan.gavin@gmail.com, mst@redhat.com, thuth@redhat.com, armbru@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, f4bug@amsat.org, wangyanan55@huawei.com, pbonzini@redhat.com, marcel.apfelbaum@gmail.com, Jonathan.Cameron@Huawei.com, ani@anisinha.ca, imammedo@redhat.com, lvivier@redhat.com, eblake@redhat.com Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: KIn9cfMrMoyN 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=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 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 5443ecae92..c3477a8a17 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2497,7 +2497,9 @@ 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; + int64_t socket_id = ms->possible_cpus->cpus[idx].props.socket_id; + + return socket_id % ms->numa_state->num_nodes; } static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) -- 2.23.0