From nobody Thu Jul 23 21:17:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass(p=none dis=none) header.from=valinux.co.jp ARC-Seal: i=2; a=rsa-sha256; t=1783634818; cv=pass; d=zohomail.com; s=zohoarc; b=cRSurK8E+T3STtYKNp+FETRWWwOKnkU511buYGy54MMju2OMNbRfF/lMvVZd4je9z42SPiBp2UwBdd/b/pjO1tOjzsjnbyz65+X0fFiumyCSPoZHSV96Y/iDxoImBDr6bdrQOAjwrzTiwWTkbwAYkJ7Y97DOw/sRKa3HdiyJ8f0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783634818; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IAm3SofYOoDGfAqTUoAO7v7MjFGup7Ebi5VOAsRE4Ak=; b=aHfljXeJMX6U3lWQSiqDSjKclS7v0On8zLxkL9wfgp3pV4yj/2hTif7Uv4/NTzahtC/1UQNS0kvTl8yH/Lf2bQSF8ajdlTZGET8Gv7aiYaaEoNq7PL4wRQKNsS5ssihJsSivVmPAI5VsIbTn/Jojohzc5b42CJVA+OIcqpkgi6g= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1783634817998986.981827851559; Thu, 9 Jul 2026 15:06:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1358609.1612643 (Exim 4.92) (envelope-from ) id 1whwt1-0007IV-NV; Thu, 09 Jul 2026 22:06:27 +0000 Received: by outflank-mailman (output) from mailman id 1358609.1612643; Thu, 09 Jul 2026 22:06:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1whwt1-0007IO-Jt; Thu, 09 Jul 2026 22:06:27 +0000 Received: by outflank-mailman (input) for mailman id 1358609; Thu, 09 Jul 2026 22:06:26 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1whwt0-000756-5z for xen-devel@lists.xenproject.org; Thu, 09 Jul 2026 22:06:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1whwsz-004Qfb-J8 for xen-devel@lists.xenproject.org; Fri, 10 Jul 2026 00:06:25 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a501b59-2eae-0a2a0a5409dd-0a2a4505bdc4-22 for ; Fri, 10 Jul 2026 00:06:25 +0200 Received: from [52.101.125.137] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.2) (envelope-from ) id 6a501b59-4f1d-0a2a45050019-34657d89cdb0-5 for ; Fri, 10 Jul 2026 00:06:25 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by TYCP286MB2431.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:18f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.17; Thu, 9 Jul 2026 22:06:18 +0000 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6]) by OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6%6]) with mapi id 15.21.0181.016; Thu, 9 Jul 2026 22:06:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qVmYiHYHZVLlsHsMJx4kxixD9SigNyJG6tnfwwgvNZx5kMaZrLgKh9tLx7YOUhr/aZaV7EHY4pc3BmBGDnReKpWnZqs72NeaTgDRvPTGndpzdOjVDFPPZ7ASUeORBEthW5GKQaq3jv0dfNzJ0FAdrWRDjOAexHWYGRj+undtR2RHMbWDOnsEuxoPheDUv49+6PlceBIJv6KisP6tFdiPpm/XHIiIxMvcH4dz8hEV7k4XjY92L5NfGtIxgutGrcIQ8cOqaI2zt+GpOHTxdi048TeQXdhek45Dr3VZjUTBiH3gcrR/NbFbJySLVoCuk0ELIK90G9tB+2kG6JZhLE1bFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IAm3SofYOoDGfAqTUoAO7v7MjFGup7Ebi5VOAsRE4Ak=; b=EmSlvO4jS7NtHy3k83dAQGDN0ZhNr24T1Id80NqM+ypLLHkNzQGgCuaeTnKZ9/08ssz02/UcPQSeZJgAkqeaxKW1LSyLMQCH6xbNvHcEycjl3RsgrOJ+bMCTOMvxU9dhGg32RPD14/3VubcvBatdd+wCCrAm4AHmeZnJrmU4T9CdOA2+DhqZY1SfcNisyA40YN5fNidROvhMlNdGQ4lz6yIxraEjy7hCBWst8jSfqZqsV4CsCQ9AKwuXQFsUDE/vVBUlobvMb9rAfzX/wNAk4hBKceng24WHZ3hjGEnZbkl+tCnn7MyZqoZ2qVBfHGl0garbzsCjhdeLNE5gcGA0mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IAm3SofYOoDGfAqTUoAO7v7MjFGup7Ebi5VOAsRE4Ak=; b=oTT2dszSO9yri7vhaCV0DHu0Z88xlAH7AHX2j8HJBlDITQO6qLDLE7U3Sv6Ek4LWwi2AQEZKhmglWDUiVUPeD5g8GygFBzKNWK0NbQZ/+yM6IAbDJM6CtcxHRJ/Ky7oKiX9xDErmQtE+nVVGsC/rtkqBevrmXy7JFJO4oWtFzsc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp; From: Hirokazu Takahashi To: xen-devel@lists.xenproject.org Cc: Hirokazu Takahashi , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 1/4] xen/device-tree: Parse 'cpu-map' node for CPU topology exploration Date: Fri, 10 Jul 2026 07:05:49 +0900 Message-ID: <20260709220552.646462-2-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709220552.646462-1-taka@valinux.co.jp> References: <20260709220552.646462-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYCP301CA0007.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:386::18) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|TYCP286MB2431:EE_ X-MS-Office365-Filtering-Correlation-Id: 18652b67-2337-456c-9b89-08dede064d41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|10070799003|366016|1800799024|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: FMPVL+ieO6N+UnCS/aXln9NgV5J6sjDaP1lcLai08ObUZL5ppT8uFO8yEar8IRTOQecN/Y7OGQr/u+BFZ9oodx6zEIo9mIQUVr5y2OHZ5OC4qZviH5qkUPbAdLRTZ3X1sAp4Ks7AY5ILNUctLP9p9+mX8kWEqWlfAncq4WkovGrukSpDgOy+9mxwFsaDn6zqPDxBZ3/urJ0J4/uTDU8eEp10M67sm6J4HeEhuPqoRTtt8FCtQN9TOmDMx+x1akvkpcpXRNfaLvGjPIdX+I+/mzn/ViysLcQ21RGHk5wh/QFqZaTT44TI8AJjPcsR/J5A1akb57uTaCLSRxDhdBQ3dSerV2XLT2WsYYOWh9MmQvWzYdC0JowTDo8Mz9LxP2PJTEVt6IO6EPLyifMog5qVW/y+w/cl7+oGu2DrtwTTLgBh4AFNpOZ5WkisKrR71UWskBfbaJSXC416l6Xphdxv4C+3Yo4j/y+bKfKkc1IdLcAl8KqzbcHEAkVBMyaD68d/DsTuy7Ate4OwsMfIrifcS9zGsIcMvCDVPLhaXd/wC94ZQ/M/hIVYxhFGaBDez9kYm67xYk3XFkKr2ikldQCcLWZ5jLuRgaxaTfelIH1Mcjv3Vch8r21skUo9hkf/MXke/BSEg9y1CMGXBOS2PB367vhbXnhMzUigKWgjq1gzKFc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(10070799003)(366016)(1800799024)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?OA8E8cZca0uU2g3Y9A6WVkwaCGe4km+rukJwPgKlKmb4n1t0AnBgG8+KOMlg?= =?us-ascii?Q?3Pxi6okwsUugmUOOeqP6A4Jywzw6D7b8jBRAnP6jDINAiE9g5UTD8BZX+6HI?= =?us-ascii?Q?28RpN2XILBx+te8qUHIHatgh07HtWr/lXGJ/AXUD2juB4lTdLRcXHkOongJK?= =?us-ascii?Q?T/sGqErv6gdSxF89JLt2V5ur4kd+wrb5q05kiWgssmnPc/Y9XWQsNkfs2IqZ?= =?us-ascii?Q?TTTMysmLj/sFLJHKL0ywgtp5A2n7kbhnSUwwnSAXLn7LaFVm+l6fzLlX79mB?= =?us-ascii?Q?nIkKwmX2IDT3FrialMgON49XUY/G/warO+lxEEzfmyTAnURwEMLnmluOxR5T?= =?us-ascii?Q?NlXxvF8Xrbgb/YuhYn76rCqyCN4lYRCz3whVmlOQcLAUAYicou9bqVg5RMQn?= =?us-ascii?Q?Ph3+dpL89kruguqMhtMgeoZAW2PZKfATsthiYlGNo0ghFg2WxpatmAjkm0YY?= =?us-ascii?Q?bge5tlFG6iAcqgrNbxXA0TogDHNvu220tYNYCcr6zUlDUEOKQ0YszrF2TYJH?= =?us-ascii?Q?uzVxme29Pon8ttBZ/KIrcGI+XcGVkfkC9Nfi4ke60OKqfj3TQ5ONrMX26pgL?= =?us-ascii?Q?7J85ZWxlxbkG0xXTYaLxo4vom5U93UcCHbgk8JkV7Rod2KcJIxyDhgt6N7ez?= =?us-ascii?Q?ggdY7DRqp/0c/DIqAXx5YktXiMuA1QKzWr8xkgMjWYLsqjuMz2vYXLRIgjd0?= =?us-ascii?Q?vXQZ8eHoLF/k66X87d6aTLefh58822RCDYSSpsYHWZqYEk2X2HYNzI4X2tjp?= =?us-ascii?Q?OoLx8uRg0W6ARKrnSeAUzCUYaSGZ5QDnSEZuIlazxlrYj/6vh5S8RQhS18hY?= =?us-ascii?Q?LgoDtjvW9sNfxkoSAoT2tm1vQLIVt8yNQjpKMmxJ63VwnQfv6mZEAPtu/CNc?= =?us-ascii?Q?ml8XUMRic1L2WaS+AybN0j5ITzlbp4JDa7YXQQjFLcItOQj10b3A6Gw+lYL6?= =?us-ascii?Q?q4AaMmrWhKfZiQjxYHvJLuHhNu54D6S4FUrrmXLYs5XO8vfdsBd2N2fZ/+dG?= =?us-ascii?Q?dtKy2RVMYSTN1eFJi377dl8+0D7E8XYvE2I8a14mnddH74kxuMPXHzoHUBpa?= =?us-ascii?Q?DXR+ovw7nrW484XksJwleZLE6CNYIfBCqzMKLPOIhcyV1qU+1OUvYwb8nz20?= =?us-ascii?Q?ftsLgQBmNcftcXwZAafDffUZSxGnmkJket9OPJV8SWKfpT5x3i4YHAP0ESIp?= =?us-ascii?Q?uhs0ror7hLguVOe4vID1foh2IH5ZyNuHFoQjGYbuD8otw2OntUcmIVRvt0bl?= =?us-ascii?Q?PCOpWVz9lRM6qXjcJuUI749c4PWPX/fpiY3tM8oC06cdg0xnCdU4+MXO8Ixj?= =?us-ascii?Q?nahLoP3w24U2Pudn2CxKferrg6Aq/76uMP0DXL6RnQv48i5nvhVLR+leBIGe?= =?us-ascii?Q?nYsi4WV4iZkXBSAwRnTqlE48Uo16FrsqmP1wPClR6QBm0yggEJxeVGjQRzka?= =?us-ascii?Q?kTdadWgm8GbSzBj6DjhP9lO6qlTUMI/RU/cAwxFNQHQt6aREbY3HfIPkfwEf?= =?us-ascii?Q?g3gbyvPv5EYMZiyeygE/HzMFG3f22+7oFGRyeeoQiqOyK1lV82Gbu0zug+X+?= =?us-ascii?Q?irvgr/dIXS/UXvV1YvY+IJc9kGo7fELOncHROQaUA/TxUNVTeLOJi3NGjNEq?= =?us-ascii?Q?+HTrKLSEzBFtShig9iVnSGTTfz/BU4sD+Ag/U8Bue7StsLeh+IdGhG0g2K8m?= =?us-ascii?Q?0dGpOrfToSHHjuZG+cfpg+f8Mevjebg2yvsqnVTWrpazIuTyifPaPx1BzE/m?= =?us-ascii?Q?u3GaVhLg8WJBsRJ4J7a8/C4FatYA/FvYdi1W62J7Y+X8l9aiRMw8iGuQHCQN?= X-MS-Exchange-AntiSpam-MessageData-1: GZpJWnRoSDEsIQ== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 18652b67-2337-456c-9b89-08dede064d41 X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2026 22:06:18.1975 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7a57bee8-f73d-4c5f-a4f7-d72c91c8c111 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: A94HVEUjKyJZQpCtEcvfEv1IPkfrLzlx8qO5gVhcbGUC0Ehqjg2gXZhcu0Ore9I2NR1J96F3DvwJA16YoQuTYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCP286MB2431 X-purgate-ID: tlsNG-c201ff/1783634785-DB74D12E-7FFDD121/0/0 X-purgate-type: clean X-purgate-size: 20379 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1783634819238158500 Content-Type: text/plain; charset="utf-8" Parse the 'cpu-map' node in the Device Tree to extract CPU topology information. If the 'cpu-map' node is absent, fall back to generating the topology data from the NUMA information. This generation assumes exactly one socket per NUMA node and that SMT is unsupported. Signed-off-by: Hirokazu Takahashi --- xen/arch/arm/Kconfig | 1 + xen/arch/arm/smpboot.c | 7 + xen/common/Kconfig | 15 ++ xen/common/Makefile | 1 + xen/common/cpu-topology.c | 62 +++++ xen/common/device-tree/Makefile | 1 + xen/common/device-tree/cpu-topology.c | 355 ++++++++++++++++++++++++++ xen/drivers/acpi/Kconfig | 3 + xen/drivers/acpi/Makefile | 1 + xen/drivers/acpi/topology.c | 38 +++ xen/include/xen/acpi.h | 10 + xen/include/xen/cpu-topology.h | 35 +++ xen/include/xen/dt-cpu-topology.h | 29 +++ 13 files changed, 558 insertions(+) create mode 100644 xen/common/cpu-topology.c create mode 100644 xen/common/device-tree/cpu-topology.c create mode 100644 xen/drivers/acpi/topology.c create mode 100644 xen/include/xen/cpu-topology.h create mode 100644 xen/include/xen/dt-cpu-topology.h diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 843a43897e..26296c12c8 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -23,6 +23,7 @@ config ARM select HAS_STACK_PROTECTOR select HAS_STATIC_MEMORY select HAS_UBSAN + select HAS_GENERIC_CPU_TOPOLOGY =20 config ARCH_DEFCONFIG string diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index ba5fd2dd52..d957553a44 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -9,10 +9,12 @@ =20 #include #include +#include #include #include #include #include +#include #include #include #include @@ -244,6 +246,9 @@ static void __init dt_smp_init_cpus(void) } else tmp_map[i] =3D hwid; + + /* Pass the info to dt_init_cpu_topology() */ + map_cpu_to_dt_node(i, cpu); } =20 if ( !bootcpu_valid ) @@ -280,6 +285,8 @@ void __init smp_init_cpus(void) else acpi_smp_init_cpus(); =20 + init_cpu_topology(); + if ( opt_hmp_unsafe ) warning_add("WARNING: HMP COMPUTING HAS BEEN ENABLED.\n" "It has implications on the security and stability of = the system,\n" diff --git a/xen/common/Kconfig b/xen/common/Kconfig index da80fdba84..c4bddfd098 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -191,6 +191,21 @@ config VM_EVENT config NEEDS_LIBELF bool =20 +config HAS_GENERIC_CPU_TOPOLOGY + bool + +config DT_CPU_TOPOLOGY + bool + +config GENERIC_CPU_TOPOLOGY + bool "CPU topology support (UNSUPPORTED)" if UNSUPPORTED + depends on HAS_GENERIC_CPU_TOPOLOGY + select DT_CPU_TOPOLOGY if DEVICE_TREE_PARSE + select ACPI_CPU_TOPOLOGY if ACPI + help + Retrieve CPU topology information from the device tree or the + ACPI PPTT to optimize virtual CPU scheduling. + config NUMA bool =20 diff --git a/xen/common/Makefile b/xen/common/Makefile index 6018e25614..34b333cdb3 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_GENERIC_BUG_FRAME) +=3D bug.o obj-$(CONFIG_HYPFS_CONFIG) +=3D config_data.o obj-$(CONFIG_CORE_PARKING) +=3D core_parking.o obj-y +=3D cpu.o +obj-$(CONFIG_GENERIC_CPU_TOPOLOGY) +=3D cpu-topology.o obj-$(CONFIG_DEBUG_TRACE) +=3D debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) +=3D device.o diff --git a/xen/common/cpu-topology.c b/xen/common/cpu-topology.c new file mode 100644 index 0000000000..94cb9ba312 --- /dev/null +++ b/xen/common/cpu-topology.c @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include + +struct cpu_topology *__ro_after_init cpu_topology; + +static void __init free_topology_table(void) +{ + unsigned int cpu; + + for ( cpu =3D 0; cpu < nr_cpu_ids; cpu++ ) + { + free_cpumask_var(cpu_topology[cpu].thread_sibling); + free_cpumask_var(cpu_topology[cpu].core_sibling); + free_cpumask_var(cpu_topology[cpu].cluster_sibling); + } + + XFREE(cpu_topology); +} + +void __init init_cpu_topology(void) +{ + unsigned int cpu; + + cpu_topology =3D xzalloc_array(struct cpu_topology, nr_cpu_ids); + if ( !cpu_topology ) + { + printk(XENLOG_ERR "Failed to allocate memory for cpu_topology tabl= e\n"); + return; + } + + for ( cpu =3D 0; cpu < nr_cpu_ids; cpu++ ) + { + if ( !zalloc_cpumask_var(&cpu_topology[cpu].thread_sibling) || + !zalloc_cpumask_var(&cpu_topology[cpu].core_sibling) || + !zalloc_cpumask_var(&cpu_topology[cpu].cluster_sibling) ) + { + free_topology_table(); + printk(XENLOG_ERR "Failed to allocate memory for cpu_topology = table\n"); + return; + } + } + + if ( acpi_disabled ) + dt_init_cpu_topology(); + else + acpi_init_cpu_topology(); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/common/device-tree/Makefile b/xen/common/device-tree/Makef= ile index 9036e455d6..6ee670b5f4 100644 --- a/xen/common/device-tree/Makefile +++ b/xen/common/device-tree/Makefile @@ -1,6 +1,7 @@ obj-y +=3D bootfdt.init.o obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D bootinfo-fdt.init.o obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D bootinfo.init.o +obj-$(CONFIG_DT_CPU_TOPOLOGY) +=3D cpu-topology.init.o obj-y +=3D device-tree.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) +=3D domain-build.init.o obj-$(filter $(CONFIG_DOM0LESS_BOOT),$(CONFIG_HAS_DEVICE_TREE_DISCOVERY)) = +=3D dom0less-build.init.o diff --git a/xen/common/device-tree/cpu-topology.c b/xen/common/device-tree= /cpu-topology.c new file mode 100644 index 0000000000..b653227ef4 --- /dev/null +++ b/xen/common/device-tree/cpu-topology.c @@ -0,0 +1,355 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Derived from Linux kernel 7.0's $drivers/base/arch_topology.c + * Parse cpu topology information. + */ + +#include +#include +#include +#include +#include +#include +#include + +struct cpu_map { + unsigned int thread_id; + unsigned int core_id; + unsigned int cluster_id; + unsigned int package_id; +}; + +static const unsigned int __initdata invalid_topo_id =3D ~0U; +static struct cpu_map __initdata cpu_map[NR_CPUS] =3D { + [0 ... NR_CPUS - 1] =3D {invalid_topo_id, invalid_topo_id, invalid_top= o_id, 0} +}; +static struct dt_device_node *__initdata dt_cpu_table[NR_CPUS]; + +static void __init setup_siblings_masks(unsigned int target_cpu) +{ + const struct cpu_topology *target_topo =3D &cpu_topology[target_cpu]; + const struct cpu_map *target_map =3D &cpu_map[target_cpu]; + unsigned int cpu; + + /* Update core and thread sibling masks */ + for_each_possible_cpu(cpu) + { + const struct cpu_topology *cpu_topo =3D &cpu_topology[cpu]; + const struct cpu_map *map =3D &cpu_map[cpu]; + + if ( target_map->package_id !=3D map->package_id ) + continue; + + cpumask_set_cpu(target_cpu, cpu_topo->core_sibling); + cpumask_set_cpu(cpu, target_topo->core_sibling); + + if ( target_map->cluster_id !=3D map->cluster_id ) + continue; + + if ( target_map->cluster_id !=3D invalid_topo_id ) + { + cpumask_set_cpu(target_cpu, cpu_topo->cluster_sibling); + cpumask_set_cpu(cpu, target_topo->cluster_sibling); + } + + if ( target_map->core_id !=3D map->core_id ) + continue; + + cpumask_set_cpu(target_cpu, cpu_topo->thread_sibling); + cpumask_set_cpu(cpu, target_topo->thread_sibling); + } +} + +static struct dt_device_node *__init + dt_find_child_node_by_name(const struct dt_device_node *dt, + const char *name) +{ + struct dt_device_node *np; + + dt_for_each_child_node(dt, np) + if ( np->name && (dt_node_cmp(np->name, name) =3D=3D 0) ) + break; + + return np; +} + +void __init map_cpu_to_dt_node(unsigned int cpu, + struct dt_device_node *cpu_node) +{ + if ( cpu < ARRAY_SIZE(dt_cpu_table) ) + dt_cpu_table[cpu] =3D cpu_node; + else + printk(XENLOG_WARNING + "cpu id %u exceeds the max cores %lu\n", + cpu, ARRAY_SIZE(dt_cpu_table)); +} + +static unsigned int __init cpu_node_to_id(const struct dt_device_node *cpu= _node) +{ + unsigned int cpu; + + for_each_possible_cpu(cpu) + if ( cpu_node =3D=3D dt_cpu_table[cpu] ) + return cpu; + + return invalid_topo_id; +} + +/* + * This function returns the logical cpu number of the DT node. + */ +static unsigned int __init + get_cpu_for_node(const struct dt_device_node *dt_node) +{ + const struct dt_device_node *cpu_node =3D dt_parse_phandle(dt_node, "c= pu", 0); + + if ( !cpu_node ) + return invalid_topo_id; + + return cpu_node_to_id(cpu_node); +} + +static int __init parse_core(const struct dt_device_node *core, + unsigned int package_id, + unsigned int cluster_id, + unsigned int core_id) +{ + bool leaf =3D true; + unsigned int i =3D 0; + unsigned int cpu; + + do { + const struct dt_device_node *t; + char name[20]; + + snprintf(name, sizeof(name), "thread%u", i); + t =3D dt_find_child_node_by_name(core, name); + + if ( !t ) + break; + + leaf =3D false; + cpu =3D get_cpu_for_node(t); + if ( cpu !=3D invalid_topo_id ) + { + cpu_map[cpu].package_id =3D package_id; + cpu_map[cpu].cluster_id =3D cluster_id; + cpu_map[cpu].core_id =3D core_id; + cpu_map[cpu].thread_id =3D i; + } + else + { + printk(XENLOG_ERR + "ERROR: %s: Can't get CPU for thread\n", dt_node_name(t= )); + return -EINVAL; + } + i++; + } while ( true ); + + cpu =3D get_cpu_for_node(core); + + if ( cpu !=3D invalid_topo_id ) + { + if ( !leaf ) + { + printk(XENLOG_ERR "ERROR: %s: Core has both threads and CPU\n", + dt_node_name(core)); + return -EINVAL; + } + + cpu_map[cpu].package_id =3D package_id; + cpu_map[cpu].cluster_id =3D cluster_id; + cpu_map[cpu].core_id =3D core_id; + cpu_map[cpu].thread_id =3D 0; + } + else if ( leaf ) + { + printk(XENLOG_ERR + "ERROR: %s: Can't get CPU for leaf core\n", dt_node_name(co= re)); + return -EINVAL; + } + + return 0; +} + +static int __init parse_cluster(const struct dt_device_node *cluster, + unsigned int package_id, + unsigned int cluster_id, + unsigned int depth) +{ + bool leaf =3D true; + bool has_cores =3D false; + unsigned int core_id =3D 0; + unsigned int i =3D 0; + + /* + * First check for child clusters; we currently ignore any + * information about the nesting of clusters and present the + * scheduler with a flat list of them. + */ + do { + const struct dt_device_node *c; + char name[20]; + int ret; + + snprintf(name, sizeof(name), "cluster%u", i); + c =3D dt_find_child_node_by_name(cluster, name); + + if ( !c ) + break; + + leaf =3D false; + ret =3D parse_cluster(c, package_id, i, depth + 1); + if ( depth > 0 ) + printk(XENLOG_WARNING + "WARNING: Topology for clusters of clusters not yet sup= ported\n"); + if ( ret !=3D 0 ) + return ret; + i++; + } while ( true ); + + /* Now check for cores */ + i =3D 0; + do { + const struct dt_device_node *c; + char name[20]; + int ret; + + snprintf(name, sizeof(name), "core%u", i); + c =3D dt_find_child_node_by_name(cluster, name); + + if ( !c ) + break; + + has_cores =3D true; + + if ( depth =3D=3D 0 ) + { + printk(XENLOG_ERR + "ERROR: %s: cpu-map children should be clusters\n", + dt_node_name(c)); + return -EINVAL; + } + + if ( leaf ) + { + ret =3D parse_core(c, package_id, cluster_id, core_id++); + if ( ret !=3D 0 ) + return ret; + } + else + { + printk(XENLOG_ERR "ERROR: %s: Non-leaf cluster with core %s\n", + dt_node_name(cluster), name); + return -EINVAL; + } + + i++; + } while ( true ); + + if ( leaf && !has_cores ) + printk(XENLOG_WARNING "WARNING: %s: empty cluster\n", + dt_node_name(cluster)); + + return 0; +} + +static int __init parse_socket(const struct dt_device_node *socket) +{ + bool has_socket =3D false; + unsigned int package_id =3D 0; + int ret; + + do { + const struct dt_device_node *c; + char name[20]; + + snprintf(name, sizeof(name), "socket%u", package_id); + c =3D dt_find_child_node_by_name(socket, name); + + if ( !c ) + break; + + has_socket =3D true; + ret =3D parse_cluster(c, package_id, invalid_topo_id, 0); + if ( ret !=3D 0 ) + return ret; + + package_id++; + } while ( true ); + + if ( !has_socket ) + ret =3D parse_cluster(socket, 0, invalid_topo_id, 0); + + return ret; +} + +/* + * Generate cpu topology information when cpu-map node doesn't exist. + * It assumes that the cpu doesn't have SMT and all CPUs on a NUMA + * node belong to the same socket. + */ +static void __init fixup_topology(void) +{ + unsigned int cpu; + unsigned int clid =3D 0; + unsigned int pkgid =3D 0; + + for_each_possible_cpu(cpu) + { + struct cpu_map *map =3D &cpu_map[cpu]; + + map->package_id =3D cpu_to_node(cpu); + if ( map->package_id !=3D pkgid ) + { + pkgid =3D map->package_id; + clid =3D 0; + } + map->cluster_id =3D clid++; + map->core_id =3D 0; + map->thread_id =3D 0; + } +} + +int __init parse_dt_topology(void) +{ + const struct dt_device_node *cpus; + const struct dt_device_node *map; + + cpus =3D dt_find_node_by_path("/cpus"); + if ( !cpus ) + { + printk(XENLOG_ERR "ERROR: No CPU information found in DT\n"); + return -EINVAL; + } + + map =3D dt_find_child_node_by_name(cpus, "cpu-map"); + if ( !map ) + return -ENOENT; + + return parse_socket(map); +} + +void __init dt_init_cpu_topology(void) +{ + unsigned int cpu; + + BUG_ON(!acpi_disabled); + BUG_ON(!cpu_topology); + + if ( parse_dt_topology() ) + fixup_topology(); + + for_each_possible_cpu(cpu) + setup_siblings_masks(cpu); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/drivers/acpi/Kconfig b/xen/drivers/acpi/Kconfig index e3f3d8f4b1..5277b7bf83 100644 --- a/xen/drivers/acpi/Kconfig +++ b/xen/drivers/acpi/Kconfig @@ -8,3 +8,6 @@ config ACPI_LEGACY_TABLES_LOOKUP config ACPI_NUMA bool select NUMA + +config ACPI_CPU_TOPOLOGY + bool diff --git a/xen/drivers/acpi/Makefile b/xen/drivers/acpi/Makefile index 477408afbe..bcdb1b5e1b 100644 --- a/xen/drivers/acpi/Makefile +++ b/xen/drivers/acpi/Makefile @@ -10,3 +10,4 @@ obj-$(CONFIG_PM_OP) +=3D pm-op.o =20 obj-$(CONFIG_X86) +=3D hwregs.o obj-$(CONFIG_X86) +=3D reboot.o +obj-$(CONFIG_ACPI_CPU_TOPOLOGY) +=3D topology.init.o diff --git a/xen/drivers/acpi/topology.c b/xen/drivers/acpi/topology.c new file mode 100644 index 0000000000..6bd2d96ebb --- /dev/null +++ b/xen/drivers/acpi/topology.c @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include + +/* + * TODO: Populate the topology information by scanning the ACPI + * PPTT (Processor Properties Topology Table). + */ +void __init acpi_init_cpu_topology(void) +{ + unsigned int cpu; + + /* + * Generate temporary cpu topology information for now. + * It assumes that the cpu doesn't have SMT and all CPUs + * belong to the same socket. + */ + for_each_possible_cpu(cpu) + { + struct cpu_topology *topo =3D &cpu_topology[cpu]; + + cpumask_set_cpu(cpu, topo->thread_sibling); + cpumask_copy(topo->core_sibling, &cpu_possible_map); + } +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index 2fdf38cf74..bd982ee836 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -135,6 +135,16 @@ static inline int acpi_boot_table_init(void) =20 #endif /*!CONFIG_ACPI*/ =20 +#ifdef CONFIG_ACPI_CPU_TOPOLOGY + +void acpi_init_cpu_topology(void); + +#else /* CONFIG_ACPI_CPU_TOPOLOGY */ + +static inline void acpi_init_cpu_topology(void) {} + +#endif /* CONFIG_ACPI_CPU_TOPOLOGY */ + int get_cpu_id(u32 acpi_id); =20 unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_l= ow); diff --git a/xen/include/xen/cpu-topology.h b/xen/include/xen/cpu-topology.h new file mode 100644 index 0000000000..f64820febf --- /dev/null +++ b/xen/include/xen/cpu-topology.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef XEN_CPU_TOPOLOGY_H +#define XEN_CPU_TOPOLOGY_H + +#include + +#ifdef CONFIG_GENERIC_CPU_TOPOLOGY + +struct cpu_topology { + cpumask_var_t thread_sibling; + cpumask_var_t core_sibling; + cpumask_var_t cluster_sibling; +}; + +extern struct cpu_topology *cpu_topology; +void init_cpu_topology(void); + +#else /* CONFIG_GENERIC_CPU_TOPOLOGY */ + +#define cpu_topology ((struct cpu_topology *)NULL) +static inline void init_cpu_topology(void) {} + +#endif /* CONFIG_GENERIC_CPU_TOPOLOGY */ + +#endif /* XEN_CPU_TOPOLOGY_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/dt-cpu-topology.h b/xen/include/xen/dt-cpu-top= ology.h new file mode 100644 index 0000000000..cb8a266479 --- /dev/null +++ b/xen/include/xen/dt-cpu-topology.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef XEN_DT_CPU_TOPOLOGY_H +#define XEN_DT_CPU_TOPOLOGY_H + +struct dt_device_node; + +#ifdef CONFIG_DT_CPU_TOPOLOGY + +void map_cpu_to_dt_node(unsigned int cpu, struct dt_device_node *cpu_node); +void dt_init_cpu_topology(void); + +#else /* CONFIG_DT_CPU_TOPOLOGY */ + +static inline void map_cpu_to_dt_node(unsigned int cpu, + struct dt_device_node *cpu_node) {} + +#endif /* CONFIG_DT_CPU_TOPOLOGY */ + +#endif /* XEN_DT_CPU_TOPOLOGY_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.43.0 From nobody Thu Jul 23 21:17:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass(p=none dis=none) header.from=valinux.co.jp ARC-Seal: i=2; a=rsa-sha256; t=1783634821; cv=pass; d=zohomail.com; s=zohoarc; b=gECiloRXpGyoUAsJLE5EI+m92mIayAEA2at0btXWajOpRi/N0yleGnTije/2ALkyzZsXcEgXEIQIguxdzknFB6/+YiA0LOUPOZKdy6TXWQ94SN6+CuYqAnvW+88Qv8Fa/WJHHKlGPMgi1U9tirsVf0uEM1lQIQLlGrtQr1HLE+4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783634821; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Oglcz0WW3q4sUZQrDmPxJwR1NMDwnQUA+F3DbHSd7c4=; b=IcGPQphof6KyXtW3soOZX+kVVG6oWedLIKslbYWHhtEWOjFPbVKAplTrpdqAbZwiESwnAK8xX47qfg4qyee09+9UAvsbfbdk8JE/72cwClqtmith2BWIk13TGYOsHSN1njEfufFL5m929PDa/U6mmOOnw1YQUMkFl6hyfgjq1oQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1783634821761979.8285780723966; Thu, 9 Jul 2026 15:07:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1358608.1612634 (Exim 4.92) (envelope-from ) id 1whwt0-00075V-Cl; Thu, 09 Jul 2026 22:06:26 +0000 Received: by outflank-mailman (output) from mailman id 1358608.1612634; Thu, 09 Jul 2026 22:06:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1whwt0-00075O-9T; Thu, 09 Jul 2026 22:06:26 +0000 Received: by outflank-mailman (input) for mailman id 1358608; Thu, 09 Jul 2026 22:06:25 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1whwsy-0006sg-SL for xen-devel@lists.xenproject.org; Thu, 09 Jul 2026 22:06:25 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1whwsy-004Qfb-9J for xen-devel@lists.xenproject.org; Fri, 10 Jul 2026 00:06:24 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a501b59-2eae-0a2a0a5409dd-0a2a4505bdc4-14 for ; Fri, 10 Jul 2026 00:06:23 +0200 Received: from [52.101.125.137] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.2) (envelope-from ) id 6a501b59-4f1d-0a2a45050019-34657d89cdb0-4 for ; Fri, 10 Jul 2026 00:06:22 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by TYCP286MB2431.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:18f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.17; Thu, 9 Jul 2026 22:06:20 +0000 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6]) by OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6%6]) with mapi id 15.21.0181.016; Thu, 9 Jul 2026 22:06:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ddcylcgjJoolLwrxCyh5MvBjIttF3vjAazw9DgxD9nb6Cl4zV6ofH7B1ozpMZEicOmxKBMQZx/Iabx7q0pzXyGbJFvKYANMB77GuQ6M9DIBVNZzt6h9dO5LexwXqc+a9JM67OcR+aFqkQoE8gtO8ubECdDOYeuyFtVT32bSm6+IwILIlmd4AfNvgFGQ+8oe8S/+Amr0QKDgNMG4ND363VhI43C59PvQvmeMeC8gPZn90Rkgnkk6ZHOI+d3m6Y5/PJG8W7lhVdSxEcsYovrJDVdDVubgdy3QUPbbDZcz1VeXQEd12XBkt6hPsT69ZaMgTTeKj8H0y91dFr3YMODZScA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Oglcz0WW3q4sUZQrDmPxJwR1NMDwnQUA+F3DbHSd7c4=; b=RggNqfYRUzqKEzNFp060JwwuM9sJIgRmpdTWNCSHrrOfcdAyuQLJvxN6lVd2jeeRKxBxWGfvgGoIrkMFG8UFKotb9/015BUt0Hshh7Tk0840/QO983Ca0Zmul1wXtD1JsRFUnxog13BGnjJXNyIA3O9Q9b8M7oIAqFX+5H9q+uyb2inyEOrgM95W4gAaf5xWA7uFrze1550ufj7LTHiZP+h7b4Kak3W7qlxCQ8IJIn0u1IW65YDTHOqbNpWbvoO2Pv3ypcqM4l2dXpa5QzB+njpORdFsmiUR6ra6TjHpeUiHXBAF6cdGD7VtUmuPkEJ8rCP/2liRVwb6/tCwk29dXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Oglcz0WW3q4sUZQrDmPxJwR1NMDwnQUA+F3DbHSd7c4=; b=Ca1WBMXofbnVc8cksEKxJqmG8CvHcG0CMfBk87tCNSPPd6mECFenLunWK3j+aNJ1TOufhHe8cO9x9bOTnfVELIqQPw8Yh+vUN3AZW8KflOZ6QL1sAH/p4R2edv/YTcFMhFhJROmGqQVds7XpSiZqTfytzfqWCaMkfnHpq4fDeoY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp; From: Hirokazu Takahashi To: xen-devel@lists.xenproject.org Cc: Hirokazu Takahashi , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Timothy Pearson , Alistair Francis , Connor Davis , Oleksii Kurochko , Dario Faggioli , Juergen Gross , George Dunlap Subject: [PATCH v5 2/4] xen/sched: Link CPU topology to scheduler Date: Fri, 10 Jul 2026 07:05:50 +0900 Message-ID: <20260709220552.646462-3-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709220552.646462-1-taka@valinux.co.jp> References: <20260709220552.646462-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYCP301CA0001.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:386::19) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|TYCP286MB2431:EE_ X-MS-Office365-Filtering-Correlation-Id: 02ad1b01-c3c3-4f6b-5157-08dede064e94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|10070799003|366016|1800799024|6133799003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: fgmzJNUmnb+Xgktik33ji4Nrdk1S8YSxedVQzlKimahujFFhSWbf/hXxerbXvwLLksVIONo3LvHHxBfwBCDY15Iu28VsVHtxo377QXIWAUMOXJXmgmbbBjuBdjXCa6sLKXHd9s83nhqnSHCc2/5uwEVRLATC1YHfTm9OYDuWNQmi0pIOncIGO2mjNWB8/F/kEs7UwGLVB1AlJSu7rATUeCP8paB8uuSCszKYWbLNjQRSUq10fgZTkTz/G7krZ+t04fTaC8EhrtdARMZgo5SDBSGDib7oOD3JwDBAnE4S/KQMI4C3Ix/2fcQtjLY0hlYXuTk2PrzOFHr/Evn13nGAkTLdwAD/QW7lhQ5/mtH0nah5pQ5XXSdS7ShrOdFFU53hXPj6zoK19UgRCslZSpUxLrx2CgfvCl751dpghe5tIDgFXZpqLzI/cQlt/WwukvMG6irQxCcsZee/D3ZTRg7dcLEGEEtSIdZG+bmBjeZMs/X+Lb9Zd39P7W+z0qBNf99JIZY/6tbVrGGWmlks8Fg4eUnE/YBjh3LRwpjA3Sm5qtKEzWCFchv6xn6WqvIwTtHO9kma64FykrEvMGajA+Mpi8cb0YGk2k4F8jTQ7+b+V68YSEnJ97ci/SV8zokD4WwIv8PQJZobHGMwMEMF8D+sVfNYqZePnbyZC9C01spbvXo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(10070799003)(366016)(1800799024)(6133799003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?dpz26S4qdkHxvDgtN+5tDl/HSCu13K4QU6d8S+DG2ChsVka5ZEzTk1xpMnd3?= =?us-ascii?Q?me7d9cZs8G7rz5KL/ucQB7ZrVm9hDBN5BWywQZVJRJO3XlWq/M3ZQlD8MHT+?= =?us-ascii?Q?EPzAGDNkemNWganCGXdwQ88dbzWbhH0JrH2yO0tAT97kVdE5JEhD6bRMAGQ0?= =?us-ascii?Q?zIxERekabSEAPlMclRyfOEiCf7vFNd71D97oPV0RtcpgzAYGAS9ANHXUsSyK?= =?us-ascii?Q?Po1V4HUcR2rsIhMpzWlYrwtKBPkD/gCvxqbL9KDvETANgWX15ZR9EDh0je6a?= =?us-ascii?Q?IjAM1/hxQjqpeBVmT/FRt5k8pQLnCMoGOUoW4pgNhAp+W4NUzGWYWoINRUEX?= =?us-ascii?Q?ygvYtW/u7a8IKR+X6SmT7kkAECOSzqicfmK0c5ZCpN6CfSLPeb7cgY29uNCv?= =?us-ascii?Q?VQI3anzlqu92U6cGjt79AbvXxrzxPPBSFsE0YAbMSIZFQnnaNRKK7GcHcc4r?= =?us-ascii?Q?zaiwpN2Vbque30gyQZl/IEcdzSUc/PkJ8BL4nUR1rIQfbJOPbnOfrLDrz829?= =?us-ascii?Q?3ZzUIbUwlDNkIAevkjnugMO1OV2Po6Zdl+0fUST8zY7OBVNcJ8TX1j99HLVN?= =?us-ascii?Q?lGvdVCvdwaNmiWFlZGg9Gd9RQPGsK1nXEX407IE2ee/b+62+245DuHF9B5dH?= =?us-ascii?Q?Gx4xiLVTzw2LigYn2a1/rSh0ub85G4UI4CuZVrCNyNS3Ll/w6wjf6Gu15Y1j?= =?us-ascii?Q?6fFoqlXxDLiZJwnRZlMAohDeREnPNACr3wWXY/a6Q/1zUT4/SGeT0rMx2CGS?= =?us-ascii?Q?0nljuqox6iWUwKv22uLNmpD2rEr1m9VdNWXUdmAeveYWrSPxWO23x5KQypxH?= =?us-ascii?Q?zitrzy8zpmBa+LmfoEhBqkGMnHBBblRz9I6OO8Xbz6ROkfI6Cw5GfG1fglv3?= =?us-ascii?Q?5xmZ1Qz+ObtvVoSPw3ZrMeUrnA5sDscTK1kkRixtVuzPeYiDiStAtb1A/GBX?= =?us-ascii?Q?IdQHVMEXMlF8SOY+OMsvtxPodosnLD4Ga9878Cxjc0QHrc+GIIhSHDmpp9MF?= =?us-ascii?Q?qlf+o/wdGE2hYYUxG9FJyPIhqcxeBpWNZr2GrKTACeWWTmbIB+Ez9fvGQAXT?= =?us-ascii?Q?yF2KammW7NdbjpXgsPmVYQjnCAbsYAtmaFrQmox+LGX3ekFR0jKrc5OzlKLX?= =?us-ascii?Q?2/y9JEMXjCB4obH4DFyF/x7TVkH1bg+nLK6Rll3RdGl62P5ZI1Nlk7wNnbWv?= =?us-ascii?Q?+Mh2EUx1eSFFsWGzP2LTCEW7odIBkVKLUHoEt8BE4CVfUwkQzxxZeXbjehhp?= =?us-ascii?Q?mgUsnTV86+vlDT+8z3vqGSK16BFAkJTVCzudYuNgIFNzKZ7lFV/7tbDZ3RoN?= =?us-ascii?Q?v0J3iQsdfxkF+MApjkF1NHjducnMPcuttNjmf3pZmGwAx+jUzouh1BoiFG/I?= =?us-ascii?Q?RGWiSb+A478a401K/hcMjYqGxX1b/7nnG7wGxFNjJmAHw95VxhrG36NXrDDc?= =?us-ascii?Q?faJ/KfitLKmGH7wUVPF764JZZsJxOb1Bn8BzldCfga7M2m5XCF/CcRBMyE4P?= =?us-ascii?Q?4MUv+aG4yV2aIuoO02wLgCOdUTamCH72n3rTPlwmbSJpI/5WNvy/XQGNFaXD?= =?us-ascii?Q?u+BGcq40COMeUP7bgoD1AtjBel87VqY6PUYupIZWTiXSEESMRPKUZ0UO9N/W?= =?us-ascii?Q?XvUDk8Alph3bb9J2Uri8KD8+o30mPaTP6wrO6XebnfKVEDw52mU8Wic03ZoO?= =?us-ascii?Q?PdrlQDvyLf5/IEdnW7JetS63/HenAxPyBDxESEKhW+RI+1ajpaXjLhOuA5av?= =?us-ascii?Q?tZImScxqCgS3aVzKDzEEtTX/CGdFoObswlsG9piFtheO1G2E94LGNuD2vtt7?= X-MS-Exchange-AntiSpam-MessageData-1: 4+Zoe5w4u4Mmbg== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 02ad1b01-c3c3-4f6b-5157-08dede064e94 X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2026 22:06:20.3365 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7a57bee8-f73d-4c5f-a4f7-d72c91c8c111 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yROMzcQ7jO+njZ+pednF33VJgHw624MXKZd5hJ3ZJqxXxdp94ljCCGpbDEUi8Uu6CQ33lWxmiog2x4oYESkDKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCP286MB2431 X-purgate-ID: tlsNG-c201ff/1783634783-D855412E-D702061C/0/0 X-purgate-type: clean X-purgate-size: 9028 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1783634823027158500 Content-Type: text/plain; charset="utf-8" Make CPU topology information available to the Xen scheduler. Additionally, ensure that this topology information is displayed when executing the 'xl info -n' command. Signed-off-by: Hirokazu Takahashi --- Changes in v5: Corrected the erroneous use of CONFIG_CPU_TOPOLOGY to CONFIG_GENERIC_CPU_TOPOLOGY. xen/arch/arm/include/asm/processor.h | 4 -- xen/arch/arm/smpboot.c | 8 +--- xen/arch/ppc/include/asm/processor.h | 4 -- xen/arch/riscv/include/asm/processor.h | 4 -- xen/common/device-tree/cpu-topology.c | 51 ++++++++++++++++++++++++++ xen/common/sched/credit2.c | 3 ++ xen/common/sysctl.c | 1 + xen/drivers/acpi/topology.c | 3 ++ xen/include/xen/cpu-topology.h | 45 ++++++++++++++++++++++- 9 files changed, 103 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/include/asm/processor.h b/xen/arch/arm/include/as= m/processor.h index a3753c317f..41fa73cfc4 100644 --- a/xen/arch/arm/include/asm/processor.h +++ b/xen/arch/arm/include/asm/processor.h @@ -613,10 +613,6 @@ void show_stack(const struct cpu_user_regs *regs); =20 #define cpu_relax() barrier() /* Could yield? */ =20 -/* All a bit UP for the moment */ -#define cpu_to_core(_cpu) (0) -#define cpu_to_socket(_cpu) (0) - struct vcpu; void vcpu_regs_hyp_to_user(const struct vcpu *vcpu, struct vcpu_guest_core_regs *regs); diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index d957553a44..88b01bcfd2 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -92,13 +92,7 @@ static int setup_cpu_sibling_map(int cpu) !zalloc_cpumask_var(&per_cpu(cpu_core_mask, cpu)) ) return -ENOMEM; =20 - /* - * Currently we assume there is no multithread and NUMA, so - * a CPU is a sibling with itself, and the all possible CPUs - * are supposed to belong to the same socket (NUMA node). - */ - cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu)); - cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map); + init_cpu_sibling_map(cpu); =20 return 0; } diff --git a/xen/arch/ppc/include/asm/processor.h b/xen/arch/ppc/include/as= m/processor.h index 242346cab9..1bf6f6c66c 100644 --- a/xen/arch/ppc/include/asm/processor.h +++ b/xen/arch/ppc/include/asm/processor.h @@ -141,10 +141,6 @@ /* Macro to adjust thread priority for hardware multithreading */ #define HMT_very_low() asm volatile ( "or %r31, %r31, %r31" ) =20 -/* TODO: This isn't correct */ -#define cpu_to_core(cpu) (0) -#define cpu_to_socket(cpu) (0) - /* * User-accessible registers: most of these need to be saved/restored * for every nested Xen invocation. diff --git a/xen/arch/riscv/include/asm/processor.h b/xen/arch/riscv/includ= e/asm/processor.h index 6b89df4a2d..d478ffb76b 100644 --- a/xen/arch/riscv/include/asm/processor.h +++ b/xen/arch/riscv/include/asm/processor.h @@ -54,10 +54,6 @@ struct cpu_user_regs unsigned long pregs; }; =20 -/* TODO: need to implement */ -#define cpu_to_core(cpu) 0 -#define cpu_to_socket(cpu) 0 - static inline void cpu_relax(void) { #ifdef __riscv_zihintpause diff --git a/xen/common/device-tree/cpu-topology.c b/xen/common/device-tree= /cpu-topology.c index b653227ef4..43322a153f 100644 --- a/xen/common/device-tree/cpu-topology.c +++ b/xen/common/device-tree/cpu-topology.c @@ -330,6 +330,55 @@ int __init parse_dt_topology(void) return parse_socket(map); } =20 +static void __init setup_cpu_topology_ids(void) +{ + unsigned int cpu; + unsigned int next_core_id =3D 0; + unsigned int next_cluster_id =3D 0; + unsigned int next_socket_id =3D 0; + + for_each_possible_cpu(cpu) + { + unsigned int first_cpu; + struct cpu_topology *topo =3D &cpu_topology[cpu]; + + first_cpu =3D cpumask_first(topo->thread_sibling); + if ( first_cpu =3D=3D cpu ) + { + topo->phys_core_id =3D next_core_id; + next_core_id++; + } + else + topo->phys_core_id =3D cpu_topology[first_cpu].phys_core_id; + + /* Reuse the calculated core id if clustering is not supported */ + if ( cpumask_empty(topo->cluster_sibling) ) + topo->phys_cluster_id =3D topo->phys_core_id; + else + { + first_cpu =3D cpumask_first(topo->cluster_sibling); + if ( first_cpu =3D=3D cpu ) + { + topo->phys_cluster_id =3D next_cluster_id; + next_cluster_id++; + } + else + topo->phys_cluster_id =3D cpu_topology[first_cpu].phys_clu= ster_id; + } + + first_cpu =3D cpumask_first(topo->core_sibling); + if ( first_cpu =3D=3D cpu ) + { + topo->phys_socket_id =3D next_socket_id; + next_socket_id++; + } + else + topo->phys_socket_id =3D cpu_topology[first_cpu].phys_socket_i= d; + + topo->num_siblings =3D cpumask_weight(topo->thread_sibling); + } +} + void __init dt_init_cpu_topology(void) { unsigned int cpu; @@ -342,6 +391,8 @@ void __init dt_init_cpu_topology(void) =20 for_each_possible_cpu(cpu) setup_siblings_masks(cpu); + + setup_cpu_topology_ids(); } =20 /* diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index 95946634d1..3d4cecd5ba 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -9,6 +9,7 @@ * Based on an earlier verson by Emmanuel Ackaouy. */ =20 +#include #include #include #include @@ -37,6 +38,8 @@ static unsigned int cpu_nr_siblings(unsigned int cpu) { #ifdef CONFIG_X86 return cpu_data[cpu].x86_num_siblings; +#elif defined(CONFIG_GENERIC_CPU_TOPOLOGY) + return cpu_topology ? cpu_topology[cpu].num_siblings : 1; #else return 1; #endif diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 5207664252..81a68fe24c 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -28,6 +28,7 @@ #include #include #include +#include =20 long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) { diff --git a/xen/drivers/acpi/topology.c b/xen/drivers/acpi/topology.c index 6bd2d96ebb..9155edc0be 100644 --- a/xen/drivers/acpi/topology.c +++ b/xen/drivers/acpi/topology.c @@ -22,6 +22,9 @@ void __init acpi_init_cpu_topology(void) { struct cpu_topology *topo =3D &cpu_topology[cpu]; =20 + topo->phys_core_id =3D cpu; + topo->num_siblings =3D 1; + cpumask_set_cpu(cpu, topo->thread_sibling); cpumask_copy(topo->core_sibling, &cpu_possible_map); } diff --git a/xen/include/xen/cpu-topology.h b/xen/include/xen/cpu-topology.h index f64820febf..ee34425680 100644 --- a/xen/include/xen/cpu-topology.h +++ b/xen/include/xen/cpu-topology.h @@ -4,6 +4,9 @@ #define XEN_CPU_TOPOLOGY_H =20 #include +#include +#include +#include =20 #ifdef CONFIG_GENERIC_CPU_TOPOLOGY =20 @@ -11,16 +14,56 @@ struct cpu_topology { cpumask_var_t thread_sibling; cpumask_var_t core_sibling; cpumask_var_t cluster_sibling; + unsigned int phys_core_id; + unsigned int phys_cluster_id; + unsigned int phys_socket_id; + unsigned int num_siblings; }; =20 extern struct cpu_topology *cpu_topology; void init_cpu_topology(void); =20 +static inline void init_cpu_sibling_map(unsigned int cpu) +{ + if ( cpu_topology ) + { + cpumask_copy(per_cpu(cpu_sibling_mask, cpu), + cpu_topology[cpu].thread_sibling); + cpumask_copy(per_cpu(cpu_core_mask, cpu), + cpu_topology[cpu].core_sibling); + } + else + { + cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu)); + cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map); + } +} + +#define cpu_to_core(cpu) (cpu_topology ? cpu_topology[cpu].phys_core_id : = 0) +#define cpu_to_socket(cpu) (cpu_topology ? cpu_topology[cpu].phys_socket_i= d : 0) + #else /* CONFIG_GENERIC_CPU_TOPOLOGY */ =20 -#define cpu_topology ((struct cpu_topology *)NULL) static inline void init_cpu_topology(void) {} =20 +static inline void init_cpu_sibling_map(unsigned int cpu) +{ + /* + * If CONFIG_GENERIC_CPU_TOPOLOGY is disabled, it is assumed that + * all CPUs reside in the same socket and that SMT is not used. + */ + cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu)); + cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map); +} + +#ifndef cpu_to_core +#define cpu_to_core(cpu) (0) +#endif + +#ifndef cpu_to_socket +#define cpu_to_socket(cpu) (0) +#endif + #endif /* CONFIG_GENERIC_CPU_TOPOLOGY */ =20 #endif /* XEN_CPU_TOPOLOGY_H */ --=20 2.43.0 From nobody Thu Jul 23 21:17:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass(p=none dis=none) header.from=valinux.co.jp ARC-Seal: i=2; a=rsa-sha256; t=1783634819; cv=pass; d=zohomail.com; s=zohoarc; b=UrlhybuBeOtBXIhhN1LMKdq00ojLdICyUZ/Q0HuMANOf1jWcVx7ZLzBMCKcSWi02op0WrkIL9OWxl8Dz7WPChH4Sdh3W0fVBKNUzjmu/CrHItqktbKB+pyyHQYFbr8x12AgpFK5hx2Lc632CNne4ds2VlqjT79mt5ev/H8YhtE8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783634819; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a9DehGZNw3SYAPXXjiD6TUCW6zXpPgUeGTv4Iws9mis=; b=Cfwmw78f+YPOqLbif9N5/WJyEbMXTbbiWw9La6wc1dqElYGxHV0Hjz6cncBmLtsEVLTl0bIBvQdsm+W2HjFDqklzU8VySXNsuZNnrqtLsZAnVp1mSPGdcgfKN7W1kmFIt4AeIrtsPqlV5HgYK4g5va+WXNe+sCcS2T00WsmhLlc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1783634819412285.1797379468244; Thu, 9 Jul 2026 15:06:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1358611.1612661 (Exim 4.92) (envelope-from ) id 1whwt5-0007kP-9F; Thu, 09 Jul 2026 22:06:31 +0000 Received: by outflank-mailman (output) from mailman id 1358611.1612661; Thu, 09 Jul 2026 22:06:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1whwt5-0007kF-5u; Thu, 09 Jul 2026 22:06:31 +0000 Received: by outflank-mailman (input) for mailman id 1358611; Thu, 09 Jul 2026 22:06:30 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1whwt4-0007Z7-8x for xen-devel@lists.xenproject.org; Thu, 09 Jul 2026 22:06:30 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1whwt3-004Qfb-M3 for xen-devel@lists.xenproject.org; Fri, 10 Jul 2026 00:06:29 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a501b2a-2eae-0a2a0a5409dd-0a2a4501accc-40 for ; Fri, 10 Jul 2026 00:06:29 +0200 Received: from [52.101.125.136] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.2) (envelope-from ) id 6a501b62-3ea4-0a2a45010019-34657d888760-4 for ; Fri, 10 Jul 2026 00:06:29 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by TYCP286MB2431.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:18f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.17; Thu, 9 Jul 2026 22:06:22 +0000 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6]) by OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6%6]) with mapi id 15.21.0181.016; Thu, 9 Jul 2026 22:06:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lmwVFexMkF1ciFuAwuPkHXgHTVYkRDromlaxuHd0Go9kb12UQfedZ7opJBeWouWSwxKDsJ69ZA8uBIcWeXBnojD2xj92NhdiNO0LCmJT+2fjrvB+qHr9U7g10f5K4vQ3AM8dLdkUGceyDsQJjkF+obD6Mh2Q+VCQASwAsB9GrHN+4WMSpaVg8iKMX6cVSieYUTbBxbg+x1YcE+ljF8xWnxAHu8Vyet5zhVqDVpk07gJ/C0VmKu9OfUKdU0L4VjjsYzIcBmjOn2WdEOFXq+c7IBnw5uJdbapRd7OO+64DmjHo8xgsIQ39vNYT6T0ORjxd3TPlaUM5PTkO5Lx+Ag/0SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a9DehGZNw3SYAPXXjiD6TUCW6zXpPgUeGTv4Iws9mis=; b=dZwjJXgIeUbastWsy+h0x3rzpC2wKoS/AfMIu7KN/5HNU/p/fgyHJ35es615ADL2cYXIjtEHlGitmJX/pvbXKD4GgaCCQspWEuvmeDjUPJ+RF38kg6V45YomrslyQOw976W6p9r661kwU7w/sdglWNYyenn8fhADwXHsx/Cdnhcbe6ODXTOWTqZNhJ/UvfzLgfVEvRgzUhId5JltfgRIM7WL/bDL2yGOQa8S88MOh8qriEYvTJr6n8Ut57RWBeaTOZyeRhzxcHQywCaRLiIjZLnSpohRi1wnY5Of/E4VlbNEcv2amcTQtMPymOdOnO1s4Tx0U5OztjmeHx878Rw0LQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a9DehGZNw3SYAPXXjiD6TUCW6zXpPgUeGTv4Iws9mis=; b=vBFsrqhvesyQCATRFK2n1gETQZzVJ+5O71lY3DSFwbOR8j4DADLk030GEnOUc4KH3V8CRX7T/TGLqr2753KQe3I6JHe3ePDNazzejVoUt+aloiUUelhHXlyBtgrWuNDd4UaAj/mTPA2FHPexHYmaGwc48dX03KtVtVbDGZuNncA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp; From: Hirokazu Takahashi To: xen-devel@lists.xenproject.org Cc: Hirokazu Takahashi , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie , Anthony PERARD , Michal Orzel , Julien Grall , Stefano Stabellini , Dario Faggioli , Juergen Gross , George Dunlap Subject: [PATCH v5 3/4] xen/sched: Make cpu_nr_siblings() architecture-specific Date: Fri, 10 Jul 2026 07:05:51 +0900 Message-ID: <20260709220552.646462-4-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709220552.646462-1-taka@valinux.co.jp> References: <20260709220552.646462-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYCP301CA0007.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:386::18) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|TYCP286MB2431:EE_ X-MS-Office365-Filtering-Correlation-Id: 3649df4f-6322-4fc6-b87d-08dede064f8d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|10070799003|366016|1800799024|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: hOBtqNtNix+QxqdOedHr29AxepdLORC21VoUFPCeqkoOxKlhV6i5IvXzJNGAPoMB7Jc+UUa0ZCCwjspFU8K4QBRXxV5hjoCgCMP8O8ZzL6E0I4xA2e4G4xmdDKcsVAvUcwfPCuxjyTj+yZfFF+eUd8HD+GV8pTIt3HqbMBtqP8EaG7jKzk29EYJh/EmLal3uZHo/RGrRNFv9nE5bRwXoMct4aFhjHTHvTU+Etbc1lRejTKCY618fmfwNojeTfXpJVOjugFI/eI4oVx4oUA0gIhlbaNDnBRJs6/9DZUGbz/sfU11btT61qpn5pm/nbcFrOLPonHCFu3RVrA3lhjQCe/EF3qJEIepiBQqUtswPkN0x//0Q2N7xqc81FMAuKKCFsk73P2YAW+W8NkjEPTxlyz0/ihFEwXBAVM8Mtpc58NXGi5xY/OTn4OrnJqHG7Dm+4SX3fzJv8h3mHZre4WTN+IR06uvxrJQFL161mlr6axWm78vX9yuv3YA5/hyHBtli1SM2RCJPMai7VrGTszHcXfmZxvl1xdGlC7RcCV6seCZuOVHvjwGOFZH5oIeFMTaEFhWdO/9t51AMoSFAJFjMPMeeZ8zsOt4ZBAOeFOjWmreWb0iP9RYPlyND9SynTGZ2pYFDDairFEuCz+iMIa8DOPv6TRWficHuqLWO9XdJ7uY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(10070799003)(366016)(1800799024)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?xE9m0GpYNHIosSW3IBDoHFeWq/Pt9+CAQ6qqXc4ELJD2oRPygK8vUuK7hEoR?= =?us-ascii?Q?CN7qDV4kc5G+gOfBPBXAV7kI6IhO5KtyEfo8AwRLWuxKpDrGqqFsqbTnPtTD?= =?us-ascii?Q?vK5CkzO/rI0DaOnto3HGvrXpEXAZub5iUytyuC1D8sZKmUkHM+sT0m4c86KQ?= =?us-ascii?Q?oNE+8zhOFrfgxcHAbrKZ1HtzZ9SXcoOigioIjZVkXMPa8kzp3XVLQWURhr8g?= =?us-ascii?Q?kzojX2d8VoKqqLalOX8uZI1NQeUj+1bPxj4LoTESZO0hY3MacTeE/WGA7O2E?= =?us-ascii?Q?ZTr20xcW5A79WuSNN7+WDCUJth3pP7VIzhgwgXr6psrYf3rHablKxyN+6NTY?= =?us-ascii?Q?pNuXmBCn/z7ovwwEwu3o4U9JHy6cGAi60TnNMIQwIVKcnAydu225N09u7hBg?= =?us-ascii?Q?+4ztPdFyKpy0g+Aph65qjH8uMFV0pssqGF8s9qYD8tCTi99BHUa6z5n4x4HV?= =?us-ascii?Q?8l6lgS+uXAetTLSLHIqz3Ypm1o/g7dY5v2Mt/uVxHTAVdeNvtelOa00P7qnL?= =?us-ascii?Q?2eOvpR0mF087dP5lrlMyxIR0zTWS4z5tr2TBQsn80crHFTxBCzBgP1Ds+L8h?= =?us-ascii?Q?rOH4ptutpBUFje/n3ULQ4cg/RRpYQZLO9sKLYvipwU6itP3DNNFZssRwvZom?= =?us-ascii?Q?gS+uwkDJ4OgM6XhpXNSguzbP18SGABDB02oXwl9N5iw3HqI1KSt1vJw10noQ?= =?us-ascii?Q?i2UBnhYhF1cMLUy4gr+NkRem2maTDPwla3SwRPtifCGET08RGok3XHwizN91?= =?us-ascii?Q?+hr0sREPoilKG+Zd62rdBOMYuDKIyxNi54mz/asIiLz4RiV16laaMIIv8MBb?= =?us-ascii?Q?PCzMPduN+TvnEjaGhp0FK7aJKC5Yar5Lm30O3GtPV/CkBoaznDlZKTP+H9cJ?= =?us-ascii?Q?HwhKm979R7gvX74eLf5862UUlwsYAOmhSYGJ9PehsWdg1TAV4I88m6vPDTVQ?= =?us-ascii?Q?2RWZmzgGKoiES47GGuXR2V7YUtcqeud3hMarlG19kmm1ZBaeKL1+na1APdZE?= =?us-ascii?Q?xPw6bsb556LPsck4kU+5vMp488BmeeB/mmcjYC+CEAUTPlLdHkG5iozVGZ6X?= =?us-ascii?Q?iQ5Gpgs44hT3kubdDUAxMLKNZSH9QSfoo7oK5wJr20YKc7Bsi/6SD6g369Lq?= =?us-ascii?Q?LOScL1YNTuT41/jXGJT0tFKuBxFvaGs4H83f+yy3hKsOG9ZWh0e+kgWF20q/?= =?us-ascii?Q?QgfZoNFlkClhEOtqlidmsK5yIOb1mSj1LABEdV66Jl9O3pwK5ImQR8cee/vB?= =?us-ascii?Q?0NzzL1zTzhKs/SJmpfP1Nw8RqACTFbHRS80yEDFEsGsH3AWTNtoClRZ/l+/A?= =?us-ascii?Q?FEd3xLrQkvitUrS0HzP5dF1GWm97Erp72LWJiulNukUkzxeY28T3YtqGFyQc?= =?us-ascii?Q?xquWVh1cOAbVZA2UyNvvJAAf7sLAFP1hfkJQz2dAsvU3wKEhEV/qjdHWc9YY?= =?us-ascii?Q?f5m2YZQmPPEuz3PerCiU+9091asbnd6x0PE2qbAo8PwO1xBHA0/qzeegcB2f?= =?us-ascii?Q?QP0M33ozurkh5No5fieR1oMU6l0fi7baRc8zeRhk5sq1PGl25vVccAzeth1O?= =?us-ascii?Q?/impa8+ZkVo4+OG3/tCyKuuNfSaFl0WsTZ6LzAnbetantFExnP5Bf3+h1Nh6?= =?us-ascii?Q?CEOJCyVVli4Pq8uS+pXIF/liA440JiXbS9fNZeYE+d7ciqE8ES1yINB+rOK8?= =?us-ascii?Q?nZbX8EGj8yEsz0MUP3j0FXaWze6iG0x0rczmw1CgLT9FQ2qR5FsqKyt6R4rN?= =?us-ascii?Q?nVg9SLhFeE7nsl4LEOn7X28yZk86DjE4FJvf9Vj2Q76yT9VFneIXZ1lZRU4r?= X-MS-Exchange-AntiSpam-MessageData-1: AHNkbTAiXp3d/w== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 3649df4f-6322-4fc6-b87d-08dede064f8d X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2026 22:06:21.9714 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7a57bee8-f73d-4c5f-a4f7-d72c91c8c111 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BEizRsjyc4zFh/g/F6mvfJHiGugXpQiJ8HZ5sThWJRXhtG5BEvKEYETqygb1qCH80DI1jNUBmVf17y8E8NHixg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCP286MB2431 X-purgate-ID: tlsNG-d62444/1783634789-3EAF00A8-FEFEF841/0/0 X-purgate-type: clean X-purgate-size: 3394 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1783634820941158500 Content-Type: text/plain; charset="utf-8" Make cpu_nr_siblings() an architecture-specific function. This patch provides the implementation for x86 and a common version for Device Tree-based architectures. Signed-off-by: Hirokazu Takahashi Acked-by: Jan Beulich --- xen/arch/x86/include/asm/processor.h | 1 + xen/common/sched/credit2.c | 22 +++------------------- xen/include/xen/cpu-topology.h | 5 +++++ 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/as= m/processor.h index 8ca6799a81..9758060129 100644 --- a/xen/arch/x86/include/asm/processor.h +++ b/xen/arch/x86/include/asm/processor.h @@ -106,6 +106,7 @@ extern void intel_init_arat(void); =20 #define cpu_to_core(_cpu) (cpu_data[_cpu].cpu_core_id) #define cpu_to_socket(_cpu) (cpu_data[_cpu].phys_proc_id) +#define cpu_nr_siblings(_cpu) (cpu_data[_cpu].x86_num_siblings) =20 unsigned int apicid_to_socket(unsigned int apicid); =20 diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index 3d4cecd5ba..6c645f0e21 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -29,22 +29,6 @@ /* #define d2printk printk */ #define d2printk(x...) =20 -/* - * TODO: Abstract this properly, and figure out what Credit2 wants to do w= ith - * the fact that x86_num_siblings doesn't even have the same meaning - * between x86 vendors. - */ -static unsigned int cpu_nr_siblings(unsigned int cpu) -{ -#ifdef CONFIG_X86 - return cpu_data[cpu].x86_num_siblings; -#elif defined(CONFIG_GENERIC_CPU_TOPOLOGY) - return cpu_topology ? cpu_topology[cpu].num_siblings : 1; -#else - return 1; -#endif -} - /* * Credit2 tracing events ("only" 512 available!). Check * include/public/trace.h for more details. @@ -882,9 +866,9 @@ cpu_runqueue_match(const struct csched2_runqueue_data *= rqd, unsigned int cpu) =20 /* * Additional checks, to avoid separating siblings in different runqueues. - * This deals with both Intel's HTs and AMD's CUs. An arch that does not h= ave - * any similar concept will just have cpu_nr_siblings() always return 1, a= nd - * setup the cpu_sibling_mask-s acordingly (as currently does ARM), and th= ings + * This deals with Intel's HTs, AMD's CUs and ARM's SMT. An arch that + * does not have similar concept will just have cpu_nr_siblings() always + * return 1, and setup the cpu_sibling_mask-s accordingly, and things * will just work as well. */ static bool diff --git a/xen/include/xen/cpu-topology.h b/xen/include/xen/cpu-topology.h index ee34425680..646cd0ff04 100644 --- a/xen/include/xen/cpu-topology.h +++ b/xen/include/xen/cpu-topology.h @@ -41,6 +41,7 @@ static inline void init_cpu_sibling_map(unsigned int cpu) =20 #define cpu_to_core(cpu) (cpu_topology ? cpu_topology[cpu].phys_core_id : = 0) #define cpu_to_socket(cpu) (cpu_topology ? cpu_topology[cpu].phys_socket_i= d : 0) +#define cpu_nr_siblings(cpu) (cpu_topology ? cpu_topology[cpu].num_sibling= s : 1) =20 #else /* CONFIG_GENERIC_CPU_TOPOLOGY */ =20 @@ -64,6 +65,10 @@ static inline void init_cpu_sibling_map(unsigned int cpu) #define cpu_to_socket(cpu) (0) #endif =20 +#ifndef cpu_nr_siblings +#define cpu_nr_siblings(cpu) (1) +#endif + #endif /* CONFIG_GENERIC_CPU_TOPOLOGY */ =20 #endif /* XEN_CPU_TOPOLOGY_H */ --=20 2.43.0 From nobody Thu Jul 23 21:17:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass(p=none dis=none) header.from=valinux.co.jp ARC-Seal: i=2; a=rsa-sha256; t=1783634818; cv=pass; d=zohomail.com; s=zohoarc; b=QTR1uXdKA71UIpXziwiJOXBw5DQTwPmJDP/lvg37WjC83a2MO81215UQINv/NYZbqVaIjJFBo+cGQkK3Af3k4jmAH82vFy5E3LErnwWxzbQ6bCtmpo+KK6BTddIDjECLo9r+qV7JaMzeatT4rImmlj4fvJ0kedack9v9sWzcc2U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783634818; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hHLTHYhQn87WMtZCHSNKRQZGN/vrbyKKjK5gg/fIUwM=; b=VZuigL2X6mGkOULEBx2EJMue842M3jRKdDSZXcS3mifNp0WYxRkiS/Ksz2LpPFCkn9T7H8i7SSZ0T1E0SdqPfHVIsOerctANVPcW4kGhi0myB6D/VlHFZcvoMM2+Eu/TkwKYh8bmfvrS7LsszgvCvZ//KNYQ/fDVphEldxU64G4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=valinux.co.jp); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17836348184973.364650159088569; Thu, 9 Jul 2026 15:06:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1358610.1612652 (Exim 4.92) (envelope-from ) id 1whwt3-0007WJ-UK; Thu, 09 Jul 2026 22:06:29 +0000 Received: by outflank-mailman (output) from mailman id 1358610.1612652; Thu, 09 Jul 2026 22:06:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1whwt3-0007WA-R0; Thu, 09 Jul 2026 22:06:29 +0000 Received: by outflank-mailman (input) for mailman id 1358610; Thu, 09 Jul 2026 22:06:29 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1whwt3-0007Vh-9E for xen-devel@lists.xenproject.org; Thu, 09 Jul 2026 22:06:29 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1whwt2-004Qfb-ML for xen-devel@lists.xenproject.org; Fri, 10 Jul 2026 00:06:28 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a501b2a-2eae-0a2a0a5409dd-0a2a4501accc-38 for ; Fri, 10 Jul 2026 00:06:28 +0200 Received: from [52.101.125.136] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.2) (envelope-from ) id 6a501b62-3ea4-0a2a45010019-34657d888760-3 for ; Fri, 10 Jul 2026 00:06:28 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by TYCP286MB2431.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:18f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.17; Thu, 9 Jul 2026 22:06:24 +0000 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6]) by OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM ([fe80::c8c9:25cd:8d13:96d6%6]) with mapi id 15.21.0181.016; Thu, 9 Jul 2026 22:06:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hxdBvyqKdu3QD+lJKCFPtK7hPdssa6jgwtf/7Obes6NK5T+C8h7jBmE1H1nz+imGppnCRPhTyDsu1dyVfFxkmFQjbtqYm+DeGVzwdE2EZtjXvbfhe7D9Z+/jBYHAph6i354xOlQbMTyxbfPwFYCCwIrg1j/ap14xV9kkvDBPW4tZUtdW8c6b1ItiR6je1W/P/HFeYv/9p9MdmwtaQQK/qp6Mar49cQVslUz85NSIqF+Xzc9dcADctTQhqOQE+XQ00ncccfmiy4JmUn0tsQ0zLvr7LVW+RPqA1vio43FpKbdAkTJtYrYs4QwL3j2mTViyVw7Jp6MvkQQTDHitglds+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hHLTHYhQn87WMtZCHSNKRQZGN/vrbyKKjK5gg/fIUwM=; b=LZzMdticrHg73welDCuh5e6QS9uQ/zk3m4ztyWudKSAI8nhQbt7da3V3LC5L6fZf9eFRMUSuWlUjoLeryFj1kkxyTOglIg27h4sVRNIqw7tKGxngGLV0DzZ1vG62XaJO4z80/gVgmtXjlHBKOFsIUBrOl81wbNnkDvpTg8rmX5mgo5Vfx4/NhahuTgrdg+MPV+sdElys8O15ypftQ8R8YMYZa1T+Zl5PkWQkh3U8UwfHLBKgj0jy3xxtpycsbEFPkjxq31tB2Gx4zJirPsTZtqH6UktYV9xdksn5Q1QrZDo1p8gKLvlQpkBnjYZs8uXD94h9BnEsRGBd3ucS7boLxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hHLTHYhQn87WMtZCHSNKRQZGN/vrbyKKjK5gg/fIUwM=; b=hGotgJEeCCOqoKCal/4lbJuwG4czNQ0u5X+8D+6UiJ823rc05R78o5Nf1TovpCy8E0ZbEk/bSTdShzmDwJsON+SquxEo2KxgbM90SxM5+5Waebz5M1O2qUAu+BOCEWeH0HgShLdsaG1K3O57hXXIqPDfLdMfuRCrb6NwG8wtSW8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp; From: Hirokazu Takahashi To: xen-devel@lists.xenproject.org Cc: Hirokazu Takahashi , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 4/4] arm/acpi: Parse PPTT to initialize CPU topology Date: Fri, 10 Jul 2026 07:05:52 +0900 Message-ID: <20260709220552.646462-5-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709220552.646462-1-taka@valinux.co.jp> References: <20260709220552.646462-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYCP301CA0014.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:386::11) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|TYCP286MB2431:EE_ X-MS-Office365-Filtering-Correlation-Id: 21d8eef6-2abb-4dfc-7b55-08dede0650ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|10070799003|366016|1800799024|6133799003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 1ERX4ZWaaa+KEAZ4TH15H8FITJC/4T7WT94nFPIh+LvLSeInC8jnwmULM28m/CP4q2X08K+oWP42CgDyqrpRZPTHh1ot1AXWkzTd5q6N4bbr597layC1+U1EEMXkiopDdnw9V8hGJ3Rvg/00aWLrn5qckJ2WC9tTztWBwMNgt7m+K+rqkCyQiji2sPTkdgM+FBX8oXnsWqmptQsghFMe7rLewthnbL/sCwd8UKoCv56+WAQCv5zWsqpyO5wbz81kgVXIjIQ8O3q34TwHKX2MQ5WgwgxdxV9MEWlv2KtLao2CZ9Bf+zIeBUb70Xh8TWs2hDo5HcqWQ6sV5y7WwAFgb/PA4xB6svDiyoNvYpcDR5NwFl0Q1akFeiaVLrKJ2DslqrEd0l0JFXJWdvKRNfGGSRsTGMOVlsjQ9krZ5xwBMN64Y74k2i/5WT70q3hKfvIxyXrAwlwROoJDpCjdqzuh6kdwd2Y/dJmNJ/KOEBejjaznSguKiF3lSnq+6CfPSfnGvQrc3WWdtv7esA9QZozkr5z2OxtBJt8BqqRmB1hGa2DppkkqkZ/qcHCRYBJvGgZBEp/Cz10I2wLUEHOrilYj0ltQShl0Qo3/5RbvQgCmNDCamruRi42ct4No6GRcVADaQc31g8hiQM0cG1keK4j0RfGTMqshXDT0ez0z0Wiwetk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(10070799003)(366016)(1800799024)(6133799003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?5q5cEmRGKd8P/u0/liwr7faMN4ZLhqaCyCeU1eWuRscxphKo6f3Sx39uelBD?= =?us-ascii?Q?MjdV2VISvOlKGRwqJAGuQdlWH1+kM+lLH/zIBUzNmnV48GAHKr3DNn+18GmD?= =?us-ascii?Q?3z2ToDtdokTn3eJ5q5W7gz8ecUkEAo4y84gvIWDaOt9Jj1b02NWUu5x+Xeau?= =?us-ascii?Q?MOJIfD5+KV0wmk95qSY41Fm0LudolnhuiTmdtQlS64IjJ+CIUNxZ9BXmI1zK?= =?us-ascii?Q?/G5xSzOTk89RXERggZIld+6lzVNOtY5zPwapSK0AsVC3DvogfIfX8eWSGDBQ?= =?us-ascii?Q?Gt+nufKmfKSaXGHOrrzNE6b3cmgn4Yah39eRRUlGGERhTfICiB192MFELvuJ?= =?us-ascii?Q?dDSIOcPzCIHHG/+oMG2ILIbXfvxEFIX7UxxgL+WWEpfU2aPjdyn1DchZtV8G?= =?us-ascii?Q?gzDcA2OZwJJmK8dFAKndO6dEEVI3y0eQCo6Ivh9Lmaaq8EASM7DSR28Q9XBq?= =?us-ascii?Q?D6XuI5JTrM5YACtwcSiAym37hj4k9XdXISSbh5gE1uzAyKVKTketYgVlbQPy?= =?us-ascii?Q?ZUmJNSeWh2h64bcIVsLVE/z+4HtFq31DOEUw2q4V7EsAZbvO3NsSq2ewrOwd?= =?us-ascii?Q?DJio0L5c+tsJTeY1EfhVOhhkDal/bIsaUIeML3FjY5Pisp/PFcqsxVWDWgaZ?= =?us-ascii?Q?ae9oSUZX962mcHM10PCKD0Mz6Wc5PJjbNZ91lRKSxVTwTJdZ39bg2MXloz3R?= =?us-ascii?Q?kb0fulhoTqpvlibU91onb39QACgqxUXvhy6FZtHFZKi7MCFglgVDl9150Rdk?= =?us-ascii?Q?k3Z8DA+gg8/YLePE0XBWB8C5IP1miRJVeQ+cI5GyxxN4+ylPgJpzTW22gp/2?= =?us-ascii?Q?0R4wy0z+InDmIN1emA9VDQ82BQbfSr9+yLlbMcxIWz9bKJNDYKmN760Mr1cJ?= =?us-ascii?Q?IEadbMCrxkOY84DM8RBX8EVMIWQpW3LWwgFdvQEDNAX9K5bexRS5GYIR3kBX?= =?us-ascii?Q?+8KJVMTDDh5HFSWDiILfdd1QgVX5L0ripl45FBPmDaevAcLJJAu1Y7D0yIkX?= =?us-ascii?Q?Nu6LMCRCOVEKflmJwDdKZZc00MR9Dn2J93MYZgSxyGP9uxT5ESer1ttrQnJu?= =?us-ascii?Q?Msmhlyh55NW1Qi1KtZ0v6AJYSeWTQdTjNevPE1KEa269rbFRZDBDvB08UapY?= =?us-ascii?Q?waTVkM15uraO9F2Sj6pTRcSzG61tIXBSPEqJ85wLdLZWVqia/ReE4TzUlxfs?= =?us-ascii?Q?XYZvYO7FZneRFYA68x1sHCCJ0FgbwjFVSMU4DxY6Y4EaL1bwm5eLbrHmrbdP?= =?us-ascii?Q?9O8lvy/xsdDBUO0HEvx7D3KOjiQiOjtCElkwaVVSOvPnuqpYd2p/yNbxdOjU?= =?us-ascii?Q?X0hGIbBzfGKGISSwbcE7j0S+uCZFdlYS6J/2j5JJQBmgpLiMLjiPyW4uOIhQ?= =?us-ascii?Q?9eOvfLiZfbYUZty4bq0VNSaQpGehuT6Z1BrLKHt6LKmtQNDjG907iOPVwFKO?= =?us-ascii?Q?XFf81cMNq290jyP3yPu6zQIPpguXOR54rzyePj5otEy5za2RJPfUVk9LPj+t?= =?us-ascii?Q?gWOYt9vqEE9Kodnwu8Frh+Pk1zBv/+N7Te6gC5pbVxXvTGDKgEuhSe46odIB?= =?us-ascii?Q?nZNvMfWfQ6jfaCtKEKtrke+ncZ1rhwKfj0wfwaiMBsdKUDnWy7RudqGcCXx7?= =?us-ascii?Q?KKOzSYa3tSPq/e9rd/OrgkyJYFck0X5xJd12WSC0QVHno88tY2CM8RiPUukJ?= =?us-ascii?Q?IFRabq/vl/xwMk27Pxd2VLh8xkRJRmLnXtlkhFWQ6skQNndCxIys41UyDcp7?= =?us-ascii?Q?uy4aa56deauw4IbDWhkcGa9DCigHy4Ryxoga836MaWJDB2/lZlBLsxULzScu?= X-MS-Exchange-AntiSpam-MessageData-1: m/B7eRm3RT56Xg== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 21d8eef6-2abb-4dfc-7b55-08dede0650ba X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2026 22:06:23.9592 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7a57bee8-f73d-4c5f-a4f7-d72c91c8c111 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: COi8tdjQjOhynp7FhVeW4nqW3xto2OR/a0AVZS0W3wcLq5xXp9ttPBWQc4ae2khl55IlZYgZ3/GTpnTXxEfDXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCP286MB2431 X-purgate-ID: tlsNG-d62444/1783634788-BA4F30A8-33A417A1/0/0 X-purgate-type: clean X-purgate-size: 12306 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1783634819196158500 Content-Type: text/plain; charset="utf-8" Parse the ACPI PPTT (Processor Properties Topology Table) to initialize the CPU topology. For ACPI 6.3 and later, the ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD flag is checked to determine the presence of SMT. For ACPI 6.2 and earlier, CPUs are assumed not to support SMT. Signed-off-by: Hirokazu Takahashi --- Changes in v5: Extracted CPU topology information from the ACPI PPTT. xen/arch/arm/acpi/boot.c | 2 + xen/arch/arm/include/asm/acpi.h | 2 + xen/drivers/acpi/topology.c | 230 ++++++++++++++++++++++++++++++-- xen/include/acpi/actbl3.h | 30 +++++ xen/include/xen/acpi.h | 8 ++ 5 files changed, 264 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 4ac0fd8f51..fc7ecb5749 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -85,6 +85,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_inter= rupt *processor) return; } bootcpu_valid =3D true; + acpi_map_cpu_acpiid(0, processor->uid); return; } =20 @@ -119,6 +120,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_int= errupt *processor) =20 /* map the logical cpu id to cpu MPIDR */ cpu_logical_map(enabled_cpus) =3D mpidr; + acpi_map_cpu_acpiid(enabled_cpus, processor->uid); =20 enabled_cpus++; } diff --git a/xen/arch/arm/include/asm/acpi.h b/xen/arch/arm/include/asm/acp= i.h index 13756dd341..b2e156e131 100644 --- a/xen/arch/arm/include/asm/acpi.h +++ b/xen/arch/arm/include/asm/acpi.h @@ -61,6 +61,8 @@ paddr_t acpi_get_table_offset(struct membank tbl_add[], E= FI_MEM_RES index); (!(entry) || (unsigned long)(entry) + sizeof(*(entry)) > (end) || \ (entry)->header.length !=3D ACPI_MADT_GICC_LENGTH) =20 +#define INVALID_ACPIID (-1U) + #ifdef CONFIG_ACPI extern bool acpi_disabled; /* Basic configuration for ACPI */ diff --git a/xen/drivers/acpi/topology.c b/xen/drivers/acpi/topology.c index 9155edc0be..37e7c70625 100644 --- a/xen/drivers/acpi/topology.c +++ b/xen/drivers/acpi/topology.c @@ -5,18 +5,90 @@ #include #include =20 -/* - * TODO: Populate the topology information by scanning the ACPI - * PPTT (Processor Properties Topology Table). - */ -void __init acpi_init_cpu_topology(void) +uint32_t map_cpu_acpiid[NR_CPUS] __initdata =3D + { [0 ... NR_CPUS - 1] =3D INVALID_ACPIID }; +uint32_t socket_map[NR_CPUS] __initdata; +uint32_t cluster_map[NR_CPUS] __initdata; +uint32_t core_map[NR_CPUS] __initdata; +uint32_t thread_map[NR_CPUS] __initdata; +unsigned int __initdata num_sockets; +unsigned int __initdata num_clusters; +unsigned int __initdata num_cores; + +static unsigned int __init get_logical_id(uint32_t phys_offset, + uint32_t *map, + unsigned int *count) +{ + unsigned int id; + + for ( id =3D 0; id < *count; id++ ) + if ( map[id] =3D=3D phys_offset ) + return id; + + map[*count] =3D phys_offset; + id =3D *count; + (*count)++; + + return id; +} + +static struct acpi_pptt_processor *__init find_pptt_node( + const struct acpi_table_header *table_hdr, unsigned int acpi_id) +{ + const struct acpi_subtable_header *entry; + unsigned long table_end; + const char *ptr; + + if ( !table_hdr ) + return NULL; + + table_end =3D (unsigned long)table_hdr + table_hdr->length; + + ptr =3D (const char *)table_hdr + sizeof(struct acpi_table_pptt); + + while ( (unsigned long)ptr + sizeof(struct acpi_subtable_header) + <=3D table_end ) + { + entry =3D (const struct acpi_subtable_header *)ptr; + + if ( entry->length =3D=3D 0 ) + { + printk(XENLOG_ERR + "ACPI: PPTT has an invalid zero-length subtable.\n"); + break; + } + + if ( (unsigned long)ptr + entry->length > table_end ) + { + printk(XENLOG_ERR + "ACPI: PPTT subtable extends beyond table end.\n"); + break; + } + + if ( entry->type =3D=3D ACPI_PPTT_TYPE_PROCESSOR ) + if ( entry->length >=3D sizeof(struct acpi_pptt_processor) ) + { + struct acpi_pptt_processor *proc =3D + (struct acpi_pptt_processor *)entry; + + if ( (proc->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID) && + proc->acpi_processor_id =3D=3D acpi_id ) + return proc; + } + + ptr +=3D entry->length; + } + + return NULL; +} + +static void __init setup_fake_topology(void) { unsigned int cpu; =20 /* - * Generate temporary cpu topology information for now. - * It assumes that the cpu doesn't have SMT and all CPUs - * belong to the same socket. + * Generate temporary cpu topology information. It assumes that + * the cpu doesn't have SMT and all CPUs belong to the same socket. */ for_each_possible_cpu(cpu) { @@ -30,6 +102,148 @@ void __init acpi_init_cpu_topology(void) } } =20 +/* + * Populate the topology information by scanning the ACPI PPTT + * (Processor Properties Topology Table). + */ +void __init acpi_init_cpu_topology(void) +{ + acpi_status status; + struct acpi_table_header *header; + const struct acpi_table_pptt *pptt; + unsigned int cpu; + + status =3D acpi_get_table(ACPI_SIG_PPTT, 0, &header); + if ( ACPI_FAILURE(status) ) + { + printk(XENLOG_WARNING + "ACPI: PPTT table not found. Topology fallback will be used= .\n"); + setup_fake_topology(); + return; + } + + pptt =3D (struct acpi_table_pptt *)header; + + for_each_possible_cpu(cpu) + { + unsigned int acpi_id =3D map_cpu_acpiid[cpu]; + struct cpu_topology *topo =3D &cpu_topology[cpu]; + const struct acpi_pptt_processor *proc; + unsigned int level =3D 0; + uint32_t thread_offset =3D 0; + uint32_t core_offset =3D 0; + uint32_t cluster_offset =3D 0; + uint32_t socket_offset =3D 0; + bool threading =3D true; + + proc =3D find_pptt_node(&pptt->header, acpi_id); + if ( !proc ) + { + printk(XENLOG_WARNING + "ACPI: No PPTT leaf node for CPU %u (ACPI ID 0x%u)\n", + cpu, acpi_id); + continue; + } + + while ( proc ) + { + if ( proc->flags & ACPI_PPTT_PHYSICAL_PACKAGE ) + { + socket_offset =3D (char *)proc - (char *)pptt; + break; + } + else if ( level =3D=3D 0 ) + /* + * ACPI_PPTT_PROCESSOR_IS_THREAD is supported in PPTT + * revision 2 and later. + */ + if ( proc->flags & ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD ) + thread_offset =3D (char *)proc - (char *)pptt; + else + { + /* Assume no threading support when PPTT revision is 1= . */ + threading =3D false; + core_offset =3D (char *)proc - (char *)pptt; + } + else if ( level =3D=3D 1 ) + if ( threading ) + core_offset =3D (char *)proc - (char *)pptt; + else + cluster_offset =3D (char *)proc - (char *)pptt; + else if ( level =3D=3D 2 ) + if ( threading ) + cluster_offset =3D (char *)proc - (char *)pptt; + + if ( proc->parent ) + { + proc =3D (const struct acpi_pptt_processor *) + ((char *)pptt + proc->parent); + level++; + } + else + break; + } + + topo->phys_socket_id =3D + get_logical_id(socket_offset, socket_map, &num_sockets); + topo->phys_cluster_id =3D + get_logical_id(cluster_offset, cluster_map, &num_clusters); + topo->phys_core_id =3D + get_logical_id(core_offset, core_map, &num_cores); + + /* Fall back to socket ID if PPTT lacks cluster information. */ + if ( topo->phys_cluster_id =3D=3D 0 ) + topo->phys_cluster_id =3D topo->phys_socket_id; + } + + for_each_possible_cpu(cpu) + { + struct cpu_topology *topo =3D &cpu_topology[cpu]; + unsigned int tcpu; + + for_each_possible_cpu(tcpu) + { + struct cpu_topology *ttopo =3D &cpu_topology[tcpu]; + + if ( cpu > tcpu ) + continue; + + if ( topo->phys_core_id =3D=3D ttopo->phys_core_id ) + { + cpumask_set_cpu(tcpu, topo->thread_sibling); + cpumask_set_cpu(cpu, ttopo->thread_sibling); + } + + if ( topo->phys_cluster_id =3D=3D ttopo->phys_cluster_id ) + { + cpumask_set_cpu(tcpu, topo->cluster_sibling); + cpumask_set_cpu(cpu, ttopo->cluster_sibling); + } + + if ( topo->phys_socket_id =3D=3D ttopo->phys_socket_id ) + { + cpumask_set_cpu(tcpu, topo->core_sibling); + cpumask_set_cpu(cpu, ttopo->core_sibling); + } + } + + topo->num_siblings =3D cpumask_weight(topo->thread_sibling); + } + + for_each_possible_cpu(cpu) + { + const struct cpu_topology *topo =3D &cpu_topology[cpu]; + + printk(XENLOG_DEBUG + "ACPI: acpi_id[%u] CPU-%u Socket-%u Cluster-%u Core-%u\n", + map_cpu_acpiid[cpu], + cpu, + topo->phys_socket_id, + topo->phys_cluster_id, + topo->phys_core_id); + } +} + /* * Local variables: * mode: C diff --git a/xen/include/acpi/actbl3.h b/xen/include/acpi/actbl3.h index 636d3f5f5b..48907d0532 100644 --- a/xen/include/acpi/actbl3.h +++ b/xen/include/acpi/actbl3.h @@ -72,6 +72,7 @@ =20 #define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */ #define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */ +#define ACPI_SIG_PPTT "PPTT" /* Processor Properties Topology Ta= ble */ =20 /* Reserved table signatures */ =20 @@ -637,6 +638,35 @@ struct acpi_table_stao { u8 ignore_uart; }; =20 +/*************************************************************************= ****** + * + * PPTT - Processor Properties Topology Table - ACPI 6.3 + * Version 1 + * + *************************************************************************= *****/ +struct acpi_table_pptt { + struct acpi_table_header header; +}; + +#define ACPI_PPTT_TYPE_PROCESSOR 0 +#define ACPI_PPTT_TYPE_CACHE 1 +#define ACPI_PPTT_TYPE_ID 2 + +struct acpi_pptt_processor { + struct acpi_subtable_header header; + u16 reserved; + u32 flags; + u32 parent; + u32 acpi_processor_id; + u32 number_of_priv_resources; +}; + +#define ACPI_PPTT_PHYSICAL_PACKAGE (1) +#define ACPI_PPTT_ACPI_PROCESSOR_ID_VALID (1 << 1) +#define ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD (1 << 2) /* ACPI 6.3 */ +#define ACPI_PPTT_ACPI_LEAF_NODE (1 << 3) /* ACPI 6.3 */ +#define ACPI_PPTT_ACPI_IDENTICAL (1 << 4) /* ACPI 6.3 */ + /* Reset to default packing */ =20 #pragma pack() diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index bd982ee836..e717f36151 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -139,8 +139,16 @@ static inline int acpi_boot_table_init(void) =20 void acpi_init_cpu_topology(void); =20 +extern uint32_t map_cpu_acpiid[NR_CPUS]; + +static inline void acpi_map_cpu_acpiid(unsigned int cpu, uint32_t acpi_id) +{ + map_cpu_acpiid[cpu] =3D acpi_id; +} + #else /* CONFIG_ACPI_CPU_TOPOLOGY */ =20 +static inline void acpi_map_cpu_acpiid(unsigned int cpu, uint32_t acpi_id)= {} static inline void acpi_init_cpu_topology(void) {} =20 #endif /* CONFIG_ACPI_CPU_TOPOLOGY */ --=20 2.43.0