From nobody Sat May 4 13:49:41 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1578389387; cv=none; d=zohomail.com; s=zohoarc; b=dR17jnRp/o905f7/k4x6MHJQCCCVgOw9Ox3Rt1WveIHQxTq2975MveRn9t1sc5laplebRxEZIK4y/CUrAuI8iJIgXcFCgKbV58yTiFkZY3RYf0dSw/3mrmGfLWbpTxcM7PYbeLuuGjBNV+RBKL4is6BtPanZITDoXsbB4swmAw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578389387; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=uS4qR1Tw1wdi3vGqrTMWUw6YM2bvTtk3EbN0ewMEPfE=; b=TSWO9wpIt4Q8UF5fGJLt+wgKcQ413btyM/+yUVe6uMRff+3y77cVSAHQx05su4PpTWzz3D81kdxXLGN0UMcSn/S83vPHiMpOh2QHA8U2N3Ob3gIW2q88uciIIlLE6gqyZux2lAI75Kh6oUs55TlKh18JRX+1cXIJhYv3V0Vp8HI= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578389387355363.59282594546914; Tue, 7 Jan 2020 01:29:47 -0800 (PST) Received: from localhost ([::1]:45286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iolBD-0004T2-Dm for importer@patchew.org; Tue, 07 Jan 2020 04:29:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42341) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iol5C-0005Xe-9z for qemu-devel@nongnu.org; Tue, 07 Jan 2020 04:23:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iol52-00080o-Pu for qemu-devel@nongnu.org; Tue, 07 Jan 2020 04:23:19 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2229 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iol4x-0007kv-Qa; Tue, 07 Jan 2020 04:23:12 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B80F5282A2F41FAD5E84; Tue, 7 Jan 2020 17:23:03 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Tue, 7 Jan 2020 17:22:55 +0800 From: Zeng Tao To: Subject: [PATCH] hw/arm/acpi: Pack the SRAT processors structure by node_id ascending order Date: Tue, 7 Jan 2020 17:18:49 +0800 Message-ID: <1578388729-55540-1-git-send-email-prime.zeng@hisilicon.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.190 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: Peter Maydell , "Michael S. Tsirkin" , qemu-trivial@nongnu.org, Shannon Zhao , qemu-arm@nongnu.org, Zeng Tao , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When booting the guest linux with the following numa configuration: -numa node,node_id=3D1,cpus=3D0-3 -numa node,node_id=3D0,cpus=3D4-7 We can get the following numa topology in the guest system: Architecture: aarch64 Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Thread(s) per core: 1 Core(s) per socket: 8 Socket(s): 1 NUMA node(s): 2 L1d cache: unknown size L1i cache: unknown size L2 cache: unknown size NUMA node0 CPU(s): 0-3 NUMA node1 CPU(s): 4-7 The Cpus 0-3 is assigned with NUMA node 1 in QEMU while it get NUMA node 0 in the guest. In fact, In the linux kernel, numa_node_id is allocated per the ACPI SRAT processors structure order,so the cpu 0 will be the first one to allocate its NUMA node id, so it gets the NUMA node 0. To fix this issue, we pack the SRAT processors structure in numa node id order but not the default cpu number order. Signed-off-by: Zeng Tao --- hw/arm/virt-acpi-build.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index bd5f771..497192b 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -520,7 +520,8 @@ build_srat(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) AcpiSystemResourceAffinityTable *srat; AcpiSratProcessorGiccAffinity *core; AcpiSratMemoryAffinity *numamem; - int i, srat_start; + int i, j, srat_start; + uint32_t node_id; uint64_t mem_base; MachineClass *mc =3D MACHINE_GET_CLASS(vms); MachineState *ms =3D MACHINE(vms); @@ -530,13 +531,19 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) srat =3D acpi_data_push(table_data, sizeof(*srat)); srat->reserved1 =3D cpu_to_le32(1); =20 - for (i =3D 0; i < cpu_list->len; ++i) { - core =3D acpi_data_push(table_data, sizeof(*core)); - core->type =3D ACPI_SRAT_PROCESSOR_GICC; - core->length =3D sizeof(*core); - core->proximity =3D cpu_to_le32(cpu_list->cpus[i].props.node_id); - core->acpi_processor_uid =3D cpu_to_le32(i); - core->flags =3D cpu_to_le32(1); + for (i =3D 0; i < ms->numa_state->num_nodes; ++i) { + for (j =3D 0; j < cpu_list->len; ++j) { + node_id =3D cpu_to_le32(cpu_list->cpus[j].props.node_id); + if (node_id !=3D i) { + continue; + } + core =3D acpi_data_push(table_data, sizeof(*core)); + core->type =3D ACPI_SRAT_PROCESSOR_GICC; + core->length =3D sizeof(*core); + core->proximity =3D node_id; + core->acpi_processor_uid =3D cpu_to_le32(j); + core->flags =3D cpu_to_le32(1); + } } =20 mem_base =3D vms->memmap[VIRT_MEM].base; --=20 2.8.1