From nobody Thu Jul 23 22:29:25 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=1781680369; cv=pass; d=zohomail.com; s=zohoarc; b=RZZhJ4N/rrhNYzxBJofyeFUNk5IE4nIhNDyTlawoc+K2apfoS0hbdFPfqm5JexLwyrraYU4Njp3jwbtmsi735Z6Pi4mrPl2C7RICUnelhO7Xp6TFP1mt8f5lzoJl8blYZFcogaDBkdv1WaTxC3tdmqlF6YmWpbHurx06w1oXxAg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781680369; 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=hQNIJ3HNju6pfXeVEfP0fYa15huEhISLLoeTKWjcdXA=; b=H3JR3PEN/qe+sMIqcHWjPTYftkWGIJrdH86AP/DAt2HaxngOGLHk1bRz0m1cWxhC09SikVaNQIMvhciSuBCRWctUZE2AF6+HNXQ/mI/qmvM0AAYaqyWj7oaXjGFDHmoVhqhyEY+ZcwhaUYVq/yIcXnIE1O5abbEr0rh5SJFM+wQ= 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 1781680369092362.5460160243881; Wed, 17 Jun 2026 00:12:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1339816.1600895 (Exim 4.92) (envelope-from ) id 1wZkRh-0001xu-QH; Wed, 17 Jun 2026 07:12:21 +0000 Received: by outflank-mailman (output) from mailman id 1339816.1600895; Wed, 17 Jun 2026 07:12:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZkRh-0001x4-M5; Wed, 17 Jun 2026 07:12:21 +0000 Received: by outflank-mailman (input) for mailman id 1339816; Wed, 17 Jun 2026 07:12:20 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZkRf-0001uW-Gy for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 07:12:20 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZkRe-00CS1m-U0 for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 09:12:18 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3248ce-5cb7-0a2a0a5109dd-0a2a4507bf88-16 for ; Wed, 17 Jun 2026 09:12:18 +0200 Received: from [52.101.125.100] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a3248cd-229c-0a2a45070019-34657d648175-4 for ; Wed, 17 Jun 2026 09:12:18 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by OSCP286MB5166.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:34e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Wed, 17 Jun 2026 07:12:12 +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.0139.009; Wed, 17 Jun 2026 07:12:12 +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=CJlVI9k1zplGAEgqsyenMzkohm/Vsrbp5SxJPfA7pc/OIa/m4hkixaDANB4ccLc8D9SAHR5Q5myE2PZSaA+JqAqi45j1k4Mb4/WePjt5GHWeJCxLUROsDauJmAQ1nICj4r6otjYl+wy+jlfiyEiwkhoRbnGPOYz1cakJy1w0g0BZ20YMME3IaJgCmS2hpBkNzdJwHpP9l1gcfOdwkTi5EAhvd8ZfGp5kNYKW+Ji4IU0d/6jI7KQSIG/P81ZPbOZ88eGifiUBWPlZD7j2L3cb0zcp3Jm6qo3dlCD9sg3LOMPFPk8XqESwxc5kANv6R39NZzGHHHuxuOUHwQyVRaHu3Q== 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=hQNIJ3HNju6pfXeVEfP0fYa15huEhISLLoeTKWjcdXA=; b=SfP1DPFqUqh4JwGQhiFKS5Ml7W8Lod8wYGI8UFCQM5MgCHXi7NPPc/QnN9OyT6AhwBg3wFSUXAw7h8DtcYvCbl3eXA+dR2uo79ig34bK11ZHbeDcIz4tF9HKb09gHV3I+RSawjie2nz+JvFFzYo5m8Vvwoxhi/pFf+sx3sSEF3DrUciha/RHJ2/RyaU0jMjIKSXeRa/mNDW3Zki/XssWvqSdsmkAfVrNMiOjQJ8wNGNke8w6Ir2mOkid1zuzINknkZ9qIkP/SkZLJU+2lSbzbtOa68M2rQCdfhfCRJtgKqYCEvph2BGY6ebwHFZwOcLLMyodeKW5JyAWCtSWfJpSKA== 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=hQNIJ3HNju6pfXeVEfP0fYa15huEhISLLoeTKWjcdXA=; b=k8+yJjm88/o+FB2QEapn8I/KxZxDNjZW75tkHabYzMUv0Vqg8R/CDwFNJHEGMadRPUf6hzxgZa45dEEPQDoStr7Jt/e7+kkjsvTtRUkW5ek20rvSHC+sHdG9eijA47bC7Q9wbiFFUeoethmRcXVs8iT1XfNP1aE0j2C4zqvhhaU= 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: Mykyta_Poturai@epam.com, 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 v2 1/3] xen/device-tree: Parse 'cpu-map' node for CPU topology exploration Date: Wed, 17 Jun 2026 16:12:04 +0900 Message-ID: <20260617071206.265599-2-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260617071206.265599-1-taka@valinux.co.jp> References: <20260617071206.265599-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY6P286CA0042.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:3b7::13) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|OSCP286MB5166:EE_ X-MS-Office365-Filtering-Correlation-Id: de198d34-e5b5-4f53-1752-08decc3fc0f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|23010399003|10070799003|7416014|376014|22082099003|18002099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: BL531lkLfJ5E+XTWIdbS0A1yaSdTTpGem4pn1vq31UluWaqT8lyRb7N7AvOSbBy6Sz/GInG631GKsb5jzZZJDo61sNXuX87lS36KK+RWgbYwcKo/iBhByapVBjvjQt2uAEAhcyeazjO8KE3gAX+r0dqFhV/mAM3gx+574xE6tP5KuegtoTvowW5EMgncN3xTvQqvMV1dKKrt1m1iPoh4Uk230IeI415E6Ng/8xf1SvTgXT143/U9ALwxSDAGycczzxs/9bzeU5aNTsNYlqoF5T2SJFf5R0gr5zItZhCnpocDTORG2rsjCUOLsLh+BAb2LRl+Uj+WX0Zj2c/MCWnt3NLi0mchnReWPLoQTtwtoPMCYlZgVjZvg7jDO/ssI0tJwbHhpM5A7tEnqgx34ZJTvIlZXJvq+09xMbikpF0YmTf6HiZpJ0gNcmmJ6qLqwmF51cidt9Jo5+QsFDKD/ToZ4OxM7GRXNuPt/BnGj0zshdQ08bPv8P7ljlwqSjcbcRfGVSHEbLpkFXckilvMZBjBMjh9CzW2IQcrM/+TF8shMGVwwRAgPn0N1Y0uITb3yvIs2RXafgB8MfDF8cwHkHpIDwJRdWGOon3UbA42M6Bf63Ww1eNBGctLnhPF8BqLJp2AZlhS9DRsUgUef/tOWX6+3CcHj6rFCayXTR+mTKP57qJl5ko9qF6UA4/YqSf0/jN2 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)(366016)(1800799024)(23010399003)(10070799003)(7416014)(376014)(22082099003)(18002099003)(56012099006)(6133799003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?APh2K2mVW3ju31ZIpnnXR1sbcqlbJ9ajm4ImAMdVE/orU4pclOK+W6CoCP8n?= =?us-ascii?Q?+oWFR45hoBBrFHdLjZiul1jRPudhJ1OHDNysF+MlTjofr1Uq5xawhrC5WLA2?= =?us-ascii?Q?XllWKQRPKcHaihweGq8kECA3kdNTUiK5DQ4dUmfmLj7uGtdp6CzIyt+k09hn?= =?us-ascii?Q?schpq0T5liy1Xi9ZrGmcdrpYHXATeTFDLqDq5E0lWnWXoLKqDtqcwpUXMDpg?= =?us-ascii?Q?/zGyewRnrI5T47EJSN9ouXmzsPKUczAx/bQKRxqVWmtBX5q1Dz0/vjTvhs9h?= =?us-ascii?Q?0pv4f/jwVEpdXv1z78IE/JaWZciGlCKqkjOae6ID3Ox56PuC+/w8h2nNAf5E?= =?us-ascii?Q?o2Wa3RwmF6bw6ikDlkLQDfA8KpoGifdby/G1DzKs0hdi+bUdM11aGZ9hdNbx?= =?us-ascii?Q?+pqI6UkTSiCaG7T926jjjW3bbtB4TjM/MqUgoo5lnrGKv/w2270wNwEudsz9?= =?us-ascii?Q?LIj0th5cWxzFysK3CTvUCYBKOu5z2Y6ao8QH5xU33i3mt1Ev6BMrogw13ebq?= =?us-ascii?Q?y4UyA9txNrBro10WIYDo/Z9NTDD2INvJ+dFb16t7Ft1H3SjckKWbizdnkxOZ?= =?us-ascii?Q?X0hKt8fsRIbNrK1JUBfpoAmNA51vWcXY07WiiELeEbhb2nYKa5pRvKkaxZJR?= =?us-ascii?Q?Tqs7N+OUTM4uzXMpw1Xkt+ngD23IpUSLIJgglcnfFB5rI+Simyx95JE/yuXv?= =?us-ascii?Q?AHYufkap5b2A16xQqj/3cPWDgGNLMHcLQIxeaak3cdfiWBU33oh9+MHNhiMZ?= =?us-ascii?Q?qQwry7mEHa19gW6yCwOAaZdwjo+jF2wbNNcEnw4YBT4zDeAW2fSBv52SCU82?= =?us-ascii?Q?+PU5aytgQWm6aRIZKipd847fAZwOCL1dgTWhftBOR1BfuVIoVhc+FTYIk83O?= =?us-ascii?Q?gT9I11WPm6/CdeCqcsqRtr11hN3AiWbKZocFdxLhn//Nf3wOyKJjJfCskrW0?= =?us-ascii?Q?hTjGPuZYaEGIVro0yt6EJ7rPKX6ISgXD7i4bDNUUMZbwBR0dmcYefytU3hbI?= =?us-ascii?Q?YLY/JmU5lyptpXivDL8dAfWTIP9cyBdB6xxICojRuctH5jIMXwurZ4p74nIn?= =?us-ascii?Q?TMTxaRJr2wFPUzmHxQITBiy+4gogbocQB26TdrzWZ92r9be4D2VVH/dRFcKl?= =?us-ascii?Q?yp132hgrojU/3QjLbswUcX0lyZKi3k8plTcGjhST4TtRAbBg4/rG0HDFB9/l?= =?us-ascii?Q?sHJij4fBcPOm6XetNmh72TAmwqYWExZ1bx/hL7h/+Z1/jU9KXJYEom2lCHxp?= =?us-ascii?Q?inusErJTEiPAEomUvL6F8OGVaeT7DhxW5bsAFP79gKlI7/tB+XDc+KMvZfy1?= =?us-ascii?Q?Z7t7/C2URAlmmcEBPUaBgi0RRpmJ/to+F5KuvNazRr3GXyzK7xuGcYwBqfvB?= =?us-ascii?Q?6QBt0wkbkrTxx19Sx3KwK2TKRZTkcpkpga8uwrqvNUi6QsEPIHpzL1TaigNO?= =?us-ascii?Q?vLM/wlS2BICDnfSJ1//VXQRRVVRdpJZo8eLkRO2t9oOOP8HXWRje1Mf1Hy6E?= =?us-ascii?Q?FgRoRaX8Qmcj4F5N2hddM7rtx91lVuy5gh5M2iNgwIUSb/A4fjxoWTq9lxFt?= =?us-ascii?Q?a3kJ4lEfzqaaj/cCIqoaFY86+ceKi6TGzsYgwUMBf6xaWQVSQIHFDS8oGLCN?= =?us-ascii?Q?7LQmjH2HvFqee0u8OENbIwJZ6gayz9aZ6RnR84xMdxEnLG0/UxtYPLxQ0Vic?= =?us-ascii?Q?khZnlFr3am93+GQZWJWT8FUFJa50dlh+rpoZYogVWp4OP1cpD0ZwkepRITW5?= =?us-ascii?Q?RtMj0MAHoYOikuCYXISYmM3RwJDtffy1n51tCAkpEzYa3zKHfdAY79NinAQB?= X-MS-Exchange-AntiSpam-MessageData-1: u/CBG4NpxQ1E4A== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: de198d34-e5b5-4f53-1752-08decc3fc0f2 X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2026 07:12:12.6359 (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: mICsTuwZJBb5gpKWBHQjhJMawPDehAmaajAYj1XF6ypePPOvolsyB4hkC3dZs8ggXwbBvrzcyOqsGrO1f4o35A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSCP286MB5166 X-purgate-ID: tlsNG-ef75cf/1781680338-0AF76C48-509ED5E9/0/0 X-purgate-type: clean X-purgate-size: 19114 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1781680371186158500 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 | 11 + xen/arch/arm/smpboot.c | 5 + xen/common/Kconfig | 8 + xen/common/Makefile | 1 + xen/common/cpu-topology.c | 30 +++ xen/common/device-tree/Makefile | 1 + xen/common/device-tree/cpu-topology.c | 343 ++++++++++++++++++++++++++ xen/drivers/acpi/Kconfig | 3 + xen/drivers/acpi/Makefile | 2 + xen/drivers/acpi/topology.c | 38 +++ xen/include/xen/acpi.h | 4 + xen/include/xen/cpu-topology.h | 36 +++ xen/include/xen/dt-cpu-topology.h | 30 +++ 13 files changed, 512 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 5fa89fcb24..36574e0ce8 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -101,6 +101,17 @@ endchoice =20 source "arch/Kconfig" =20 +config ARM_CPU_TOPOLOGY + bool "CPU topology support (UNSUPPORTED)" if UNSUPPORTED + select CPU_TOPOLOGY + help + Retrieve CPU topology information from the device tree or + ACPI PPTT (Processor Properties Topology Table) to optimize + virtual CPU scheduling. + + Note: Implementation for parsing CPU topology from the ACPI PPTT + is currently missing and will be added in the future. + config ACPI bool "ACPI (Advanced Configuration and Power Interface) Support (UNSUPPOR= TED)" if UNSUPPORTED depends on ARM_64 && ARM_EFI diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 7f3cfa812e..fb2cf26424 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -242,6 +243,8 @@ static void __init dt_smp_init_cpus(void) } else tmp_map[i] =3D hwid; + + map_cpuid_to_node(i, cpu); /* pass the info to dt_init_cpu_topolog= y() */ } =20 if ( !bootcpu_valid ) @@ -279,6 +282,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 5ff71480ee..6875dd07b3 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -188,6 +188,14 @@ config VM_EVENT config NEEDS_LIBELF bool =20 +config DT_CPU_TOPOLOGY + bool + +config CPU_TOPOLOGY + bool + select DT_CPU_TOPOLOGY if DEVICE_TREE_PARSE + select ACPI_CPU_TOPOLOGY if ACPI + config NUMA bool =20 diff --git a/xen/common/Makefile b/xen/common/Makefile index 6018e25614..adb406ab5e 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_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..edf47445ac --- /dev/null +++ b/xen/common/cpu-topology.c @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include + +void __init init_cpu_topology(void) +{ + const unsigned int nr_cpus =3D cpumask_last(&cpu_possible_map) + 1U; + + cpu_topology =3D xzalloc_array(struct cpu_topology, nr_cpus); + if ( !cpu_topology ) + panic("Failed to allocate memory for cpu_topology array\n"); + + 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..38bc5d5306 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.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..af8417b478 --- /dev/null +++ b/xen/common/device-tree/cpu-topology.c @@ -0,0 +1,343 @@ +/* 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 + +struct cpu_map { + unsigned int thread_id; + unsigned int core_id; + unsigned int cluster_id; + unsigned int package_id; +}; + +struct cpu_topology *cpu_topology; +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_topo_= id, 0U} +}; +static struct dt_device_node * __initdata dt_cpu_table[NR_CPUS]; + +static void __init setup_siblings_masks(unsigned int cpuid) +{ + struct cpu_topology *cpuid_topo =3D &cpu_topology[cpuid]; + struct cpu_map *cpuid_map =3D &cpu_map[cpuid]; + unsigned int cpu; + + /* Update core and thread sibling masks */ + for_each_possible_cpu(cpu) + { + struct cpu_topology *cpu_topo =3D &cpu_topology[cpu]; + struct cpu_map *map =3D &cpu_map[cpu]; + + if ( cpuid_map->package_id !=3D map->package_id ) + continue; + + cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); + cpumask_set_cpu(cpu, &cpuid_topo->core_sibling); + + if ( cpuid_map->cluster_id !=3D map->cluster_id ) + continue; + + if ( cpuid_map->cluster_id !=3D invalid_topo_id ) + { + cpumask_set_cpu(cpu, &cpuid_topo->cluster_sibling); + cpumask_set_cpu(cpuid, &cpu_topo->cluster_sibling); + } + + if ( cpuid_map->core_id !=3D map->core_id ) + continue; + + cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling); + cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling); + } +} + +static struct dt_device_node * __init dt_find_child_node_by_name(struct dt= _device_node *from, const char *name) +{ + struct dt_device_node *np; + const struct dt_device_node *dt =3D from; + + 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_cpuid_to_node(unsigned int cpuid, struct dt_device_node *c= pu_node) +{ + if ( cpuid < NR_CPUS ) + dt_cpu_table[cpuid] =3D cpu_node; +} + +static unsigned int __init cpu_node_to_id(struct dt_device_node *cpu_node) +{ + unsigned int cpu; + bool found =3D false; + + for_each_possible_cpu(cpu) + { + found =3D (cpu_node =3D=3D dt_cpu_table[cpu]); + if ( found ) + return cpu; + } + + return invalid_topo_id; +} + +/* + * This function returns the logic cpu number of the node. + */ +static unsigned int __init get_cpu_for_node(struct dt_device_node *node) +{ + struct dt_device_node *cpu_node =3D dt_parse_phandle(node, "cpu", 0); + + if ( !cpu_node ) + return invalid_topo_id; + + return cpu_node_to_id(cpu_node); +} + +static int __init parse_core(struct dt_device_node *core, + unsigned int package_id, unsigned int cluster_id, + unsigned int core_id) +{ + char name[20]; + bool leaf =3D true; + unsigned int i =3D 0U; + unsigned int cpu; + + do { + struct dt_device_node *t; + + 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: %pOF: Can't get CPU for thread\n", 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: %pOF: Core has both threads and CPU\= n", + 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 0U; + } + else if ( leaf ) + { + printk(XENLOG_ERR "ERROR: %pOF: Can't get CPU for leaf core\n", co= re); + return -EINVAL; + } + + return 0; +} + +static int __init parse_cluster(struct dt_device_node *cluster, + unsigned int package_id, unsigned int cluster_id, + unsigned int depth) +{ + char name[20]; + bool leaf =3D true; + bool has_cores =3D false; + unsigned int core_id =3D 0U; + unsigned int i; + int ret; + + /* + * 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. + */ + i =3D 0U; + do { + struct dt_device_node *c; + + 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 + 1U); + if ( depth > 0U ) + printk(XENLOG_WARNING "WARNING: Topology for clusters of clust= ers not yet supported\n"); + if ( ret !=3D 0 ) + return ret; + i++; + } while ( true ); + + /* Now check for cores */ + i =3D 0U; + do { + struct dt_device_node *c; + + 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 0U ) + { + printk(XENLOG_ERR "ERROR: %pOF: cpu-map children should be clu= sters\n", 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: %pOF: Non-leaf cluster with core %s\= n", + cluster, name); + return -EINVAL; + } + + i++; + } while ( true ); + + if ( leaf && !has_cores ) + printk(XENLOG_WARNING "WARNING: %pOF: empty cluster\n", cluster); + + return 0; +} + +static int __init parse_socket(struct dt_device_node *socket) +{ + char name[20]; + bool has_socket =3D false; + unsigned int package_id =3D 0U; + int ret; + + do { + struct dt_device_node *c; + + 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, 0U); + if ( ret !=3D 0 ) + return ret; + + package_id++; + } while ( true ); + + if ( !has_socket ) + ret =3D parse_cluster(socket, 0U, invalid_topo_id, 0U); + + 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 0U; + unsigned int pkgid =3D 0U; + + 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 0U; + } + map->cluster_id =3D clid++; + map->core_id =3D 0U; + map->thread_id =3D 0U; + } +} + +int __init parse_dt_topology(void) +{ + struct dt_device_node *cpus; + 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(!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..2c8d64c314 100644 --- a/xen/drivers/acpi/Makefile +++ b/xen/drivers/acpi/Makefile @@ -10,3 +10,5 @@ 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.o diff --git a/xen/drivers/acpi/topology.c b/xen/drivers/acpi/topology.c new file mode 100644 index 0000000000..7a7042c84e --- /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..3aa4edd20f 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -101,6 +101,8 @@ void acpi_table_print (struct acpi_table_header *header= , unsigned long phys_addr void acpi_table_print_madt_entry (struct acpi_subtable_header *madt); void acpi_table_print_srat_entry (struct acpi_subtable_header *srat); =20 +void acpi_init_cpu_topology(void); + /* the following four functions are architecture-dependent */ void acpi_numa_slit_init (struct acpi_table_slit *slit); void acpi_numa_processor_affinity_init(const struct acpi_srat_cpu_affinity= *); @@ -133,6 +135,8 @@ static inline int acpi_boot_table_init(void) return 0; } =20 +static inline void acpi_init_cpu_topology(void) {} + #endif /*!CONFIG_ACPI*/ =20 int get_cpu_id(u32 acpi_id); diff --git a/xen/include/xen/cpu-topology.h b/xen/include/xen/cpu-topology.h new file mode 100644 index 0000000000..896eefb04f --- /dev/null +++ b/xen/include/xen/cpu-topology.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef XEN_CPU_TOPOLOGY_H +#define XEN_CPU_TOPOLOGY_H + +#include +#include + +struct cpu_topology { + cpumask_t thread_sibling; + cpumask_t core_sibling; + cpumask_t cluster_sibling; +}; + + +#ifdef CONFIG_CPU_TOPOLOGY + +extern struct cpu_topology *cpu_topology; +void init_cpu_topology(void); + +#else /* CONFIG_CPU_TOPOLOGY */ + +static inline void init_cpu_topology(void) {} + +#endif /* CONFIG_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..334a3181f9 --- /dev/null +++ b/xen/include/xen/dt-cpu-topology.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef XEN_DT_CPU_TOPOLOGY_H +#define XEN_DT_CPU_TOPOLOGY_H + +#include +#include + +#ifdef CONFIG_DT_CPU_TOPOLOGY + +void map_cpuid_to_node(unsigned int cpuid, struct dt_device_node *cpu_node= ); +void dt_init_cpu_topology(void); + +#else /* CONFIG_DT_CPU_TOPOLOGY */ + +static inline void map_cpuid_to_node(unsigned int cpuid, struct dt_device_= node *cpu_node) {} +static inline void dt_init_cpu_topology(void) {} + +#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 22:29:25 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=1781680380; cv=pass; d=zohomail.com; s=zohoarc; b=PSYJ6+EVZ6lw72uV47rrOX4qL4sgludsOsClGMY56xhGW1kn4q4orCVUUKXfs31cm+z7PkSW4VxV8t0YRaGfcNoZmFNF4W8zQWGxd1E/pf9l9IYIYq05N2jnV+BcvkOXmYDZjqr7dufQt7IIlCWMCq1eZwTLfEld/njjIu5aJa4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781680380; 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=Nh46NLdxeEeIQno5OW3KrzlC799wkphwGxCHu+nSAvI=; b=H9HjcdIbvzDQQaJsZoVQyvYTplh8NmHOGTvov+rg9ASOBSnmlEp27288aGwziSsEm0aZgnGT1OYlDZj6O6eknvd4xNe6iog3pME+pkF3ABYtxMQBJXWepX810XG1yleeuAmHKW60lbhNZjTrfl4dHQajitHxG+QYbUFvGo+vP4Y= 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 1781680379954272.8455250108798; Wed, 17 Jun 2026 00:12:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1339817.1600901 (Exim 4.92) (envelope-from ) id 1wZkRi-00023K-3Q; Wed, 17 Jun 2026 07:12:22 +0000 Received: by outflank-mailman (output) from mailman id 1339817.1600901; Wed, 17 Jun 2026 07:12:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZkRh-00022V-U8; Wed, 17 Jun 2026 07:12:21 +0000 Received: by outflank-mailman (input) for mailman id 1339817; Wed, 17 Jun 2026 07:12:20 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZkRg-0001un-Pm for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 07:12:20 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZkRg-00CS1m-6e for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 09:12:20 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3248ce-5cb7-0a2a0a5109dd-0a2a4507bf88-22 for ; Wed, 17 Jun 2026 09:12:19 +0200 Received: from [52.101.125.100] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a3248cd-229c-0a2a45070019-34657d648175-5 for ; Wed, 17 Jun 2026 09:12:19 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by OSCP286MB5166.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:34e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Wed, 17 Jun 2026 07:12:14 +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.0139.009; Wed, 17 Jun 2026 07:12:14 +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=DnzZCOrCcBq0+IO+YTqmeGEQyK6Fshh6s4g7x5+3hsYjNi3Mw8phT1kGRlNRY9FrWeEdTIT7CdJWmpGkn7M7tKaqMwGQTif/lqpyxrM1ZTNsnwqFAThTZhCjMY1CznC3mUUBiCzWrggA2UGYmVET0e/Oy4SgdegwDbQk60qOU+p0SQs7nB4fp68uNeOBpQX6pvG0H8TrLZ7B2RFdPWwPKCZ/hAD4cJWD7OORWOq6/6FmeZ47Sq/Xu8bsBHVXZMlRDJ/6iw5tV+X2uBrOKBqqPRH1bKMqBmtzk3dSPqQiQadFOeVpH+065qEMNcJJtwUwAiJkWBAZt3rW7P9NKSzNZA== 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=Nh46NLdxeEeIQno5OW3KrzlC799wkphwGxCHu+nSAvI=; b=YCZuilwtPuQ+ljdHNjjMe/q3ukWq4K1Da2okVQC6HMvX3cSUbDX9MhioIVygOwleeeL/W+9esgA7wNl1Gf53kY2mbPUDGIg1+Z1gJmon88uoR3q9bXOvW2b0I7/DhTLCK8NJunsKPBt8C2IxHipp7gAXk4gXEmKInsYXMMnu5KR97Jeif1qhpGDDW71mWff6NBG+6dEzEZGjDy0DhWRW8D5nURDF20beD+ZMtormUtmjoaliIhjzljmEcMLlpFJlFcOF33GqwTzbJ1qPDs59KUQmvFWoNmHtUSXhqp/JcTb/UeBb0UP7CzhC+0iS5ibspwkDBucEaw1wvjrNKMjzPw== 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=Nh46NLdxeEeIQno5OW3KrzlC799wkphwGxCHu+nSAvI=; b=RHg7kl3srRsBmbSGPGPvEGEmvLdJw/YVMsmGCS8kR3kX/OAGOIGhjvieEIVFfSUx3tX/edr2x/xe/XVZD6usFLipkp+SRC3+HNAlhnPguHN3kls8uDYuuDy+9xyjQbSKHqSu/2HE5SKW9WvEAxZZ2oLrG6TlmHadMH3OFrgVKf8= 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: Mykyta_Poturai@epam.com, 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?= , Dario Faggioli , Juergen Gross , George Dunlap Subject: [PATCH v2 2/3] xen/sched: Link CPU topology to scheduler Date: Wed, 17 Jun 2026 16:12:05 +0900 Message-ID: <20260617071206.265599-3-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260617071206.265599-1-taka@valinux.co.jp> References: <20260617071206.265599-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY6P286CA0032.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:3b7::16) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|OSCP286MB5166:EE_ X-MS-Office365-Filtering-Correlation-Id: 30da6583-b44f-4a05-f981-08decc3fc1fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|23010399003|10070799003|7416014|376014|22082099003|18002099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: lv608YHyvvYoxc6BQrEXsiv9qZb1f0Jr0fLAtrkUJ6Ect0jJbvfWOVQwyVc0GIqGwLhzP6N2I40kTxVcuRwuna9e0OOM8lvOZGBmiW+BHfIWcWheAP2eCNO6w3Pr4VnamlTRt9rpv2AXhtBL/F1/nLoilhBSHC5WXO11B5Oxltb/G8b0cfDi7NmcieSQ+iik4VNlVjQgW5vIWIRLeierGsl8HxtERTR7WSP/MA/6/0jaNlqa6VxyQHEB/rgfJ8kJZOEx1a4OgnEPcTlxjpG8abe3Os4+YGS/2DuIzcYY4d1mJNDfl/x9StZHQSphPDNYkuWRauyCCqBAWNEqojJ1Wu1L0p6E9gwhRaA7xBoLgtmasavPX7t1EHUxASPfbaJX1n2suXuXKaSPQs6J+/35c58gtGC+huQHIEOU9S2zMgT4DaP0uCItDOhjNZfPjaqY831hsHHPxgaNYxux46fHI2/vLE0pHmUcLUppxmfTsRdYJfLBYVWy9e3SugCrCrUVDk+GlpLcK9NtcdaFJUb/wPn58a9noGwSldZkuQU76FUN3satKcf+KJireQJk/kSQ/w4czPcIAMBch8NjXEh6FUrOdiYMBrc3cBl1E5UyRzr0f0EIm6pnTE08IFBC+8u3FIKzNQIlIlaVXK58fPQng1yXxVMAK92FxGJa9zf0jeyyOi8T/U73yCCC97njJ9mj 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)(366016)(1800799024)(23010399003)(10070799003)(7416014)(376014)(22082099003)(18002099003)(56012099006)(6133799003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sh3+M39Om+KUiTvsMQ3ercYX04+6UsResZGerIZ4fUXaDtHzETD6wyrdHMbc?= =?us-ascii?Q?qdTgaUDCBxUBqx7dXXIJTxfHkxKkl8UuxAqkXdIweTDrbBhjoLkGXaH5A1CQ?= =?us-ascii?Q?JB8/IBZxk7ZOlF8bniU5miiXroz92uapd/GGhyqtpwF91z1jBKD8qWSvn4fq?= =?us-ascii?Q?qwII/UtnNuPZLD79GxrSEO9wQPfClJhT2pvFcpynKJmX0dXlobje7lKuHsyB?= =?us-ascii?Q?RRpoNYYIZZS4341dA85orLoFxrtHn9tbVKnxQqKd5bIPgYXwoYRUyJd7XY/U?= =?us-ascii?Q?KXCsRvHwn+WVGhmC7Z6pVIT6om2jt0cc3uf4p7ONiNPw1QRzkkV1yX+tnszL?= =?us-ascii?Q?VkadcOI44hlLFk/raZFQpgLBjOhdq3JX5IzUwc8KFQNyRlWka9f1yH5/24yl?= =?us-ascii?Q?anY3KX3SdwA+UGja8sh28TuFzPl/v532agpgAHIgmloR2lTtIc2T6cHtHVD/?= =?us-ascii?Q?5koZpo2UQrSr+Xvj6kGhMF90q6QN7jrzJOlKPq7l0Lk9VY7wIQh8jFlZd2zI?= =?us-ascii?Q?hYL109DMe4PVmLIUbVbZXWp8Sl52vETMf5zzL/kFy40Qrcw7ioG0aYP9vN7X?= =?us-ascii?Q?AX5MJxbjyAthjDipI9hk2NfVQm/nFqPncefHazDMowKHWUIdAWGD0DmMPbit?= =?us-ascii?Q?zK3UTtEcfoDXSX60RJDYqIAPnMz0O320KmuY7hc/4cRnEC1X3fcH29WfVNky?= =?us-ascii?Q?iTGhEXPIOzig1wiHeS0EH9myLrHFHaErmM8SHdKQSE2JGCtzkKoSsQmgxFJ0?= =?us-ascii?Q?TS3Phpw7zOX4wJU1PCoVUYpc09IL7CzO1RpiMdtMlXj7A0W8p6EUeW0zQ44E?= =?us-ascii?Q?5mGR4kD4bgNCXOmpuT+cllXlgoibxYF2cGb79G1od3Ntr+u41u37FMUKt/bH?= =?us-ascii?Q?sKqAepTMLI525sfiIAPTkZ0vNfRZzfGAtI/qK2Nh9G4vQn0fA30z+OvRpaQF?= =?us-ascii?Q?+sziKo+swUmHD2tFf00WwtYP6Z6AmBgzzLZOO4Xl30aRHrrH3Uzoo/tFvrEv?= =?us-ascii?Q?Pxd6yuZRcuuREieftr2OLZaFvaGVqEBZEAZkRrkWADv3SIiek3/p5xnlK3np?= =?us-ascii?Q?1JWOlj69ETotuuuIxvyWL/he6YGy681x7fuXTjA9EOaUiSbOD+NbBSPwGMwk?= =?us-ascii?Q?uHFQQ1Yz9bGcpl2LBhmVS//bK5SqWbKIR+rEp+TRmDXivDff9jNtBjKKP0mv?= =?us-ascii?Q?IgVxzf5fTVLzLGugaaim1wttcSke4yWepF94Xe1GuSB4BzEmdcK8NTICzQ+G?= =?us-ascii?Q?plgML6/F44d8tvhWSWvLzse5kowmcQci7Ko/d92XzubzUmbRZGAMkksY88dZ?= =?us-ascii?Q?M7VZp0+51QP6VWEnhN8l79fTL4qP0XoLl+S8GLGJgP+e+cUGOAGP6aAr8WM9?= =?us-ascii?Q?Feb05VgV5pVSRFwv5eQa+7sG2RI495N66s6NXVC0zHXDgMARkwFbBMO30l/x?= =?us-ascii?Q?jQVStEBN2R2VFftfYSGifTUW1tLlJC85QGoPansKB/q55qQnVtbH7N87juDq?= =?us-ascii?Q?kWL6+r9b+q57zofx6p6Wm3ob1355YNPjjYhiK6ktmzD86Rr9kvVAeDPYX7P5?= =?us-ascii?Q?22hmpvAI0VYTbOSwV+5ecJ9oLVT20P4GHW+16HzgBUme/vfAQoitjQU9gJL1?= =?us-ascii?Q?bJhAcJvxlX8toX+fNbYi2ENQ6LCr4gqoMEbBQAtmN18Qq04y9s1AOBqko3dc?= =?us-ascii?Q?BcGDyyx8RQS7TlhPQ4dQup8H7F8I3+dqne/uvoNXEmfTDjS4sv+/TuQaEqzX?= =?us-ascii?Q?aVhfW/8TMWLJs3JW9z2MXt/2HHFosCDgd7UQ4jdseBf+489ONUoBbyuEq7y0?= X-MS-Exchange-AntiSpam-MessageData-1: phrGcVrkL7C0mA== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 30da6583-b44f-4a05-f981-08decc3fc1fc X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2026 07:12:14.3667 (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: 1YWd0IB9ri/J1sxlkD9zBKeMbwUENfriXRTOiJL+DWagCN5jIJnvTe4HYKkDtjdhQvhzX6SX9qVG2fInVpZLJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSCP286MB5166 X-purgate-ID: tlsNG-ef75cf/1781680339-21165C48-AAB49A88/0/0 X-purgate-type: clean X-purgate-size: 6884 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1781680380943158500 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 --- xen/arch/arm/include/asm/processor.h | 4 --- xen/arch/arm/smpboot.c | 10 ++++-- 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 | 10 ++++++ 7 files changed, 75 insertions(+), 7 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 fb2cf26424..4a3f1149f6 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -91,13 +91,17 @@ static int setup_cpu_sibling_map(int cpu) !zalloc_cpumask_var(&per_cpu(cpu_core_mask, cpu)) ) return -ENOMEM; =20 +#ifdef CONFIG_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_sibl= ing); +#else /* CONFIG_CPU_TOPOLOGY */ /* - * 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). + * If CONFIG_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); +#endif /* CONFIG_CPU_TOPOLOGY */ =20 return 0; } diff --git a/xen/common/device-tree/cpu-topology.c b/xen/common/device-tree= /cpu-topology.c index af8417b478..39c11ad5c6 100644 --- a/xen/common/device-tree/cpu-topology.c +++ b/xen/common/device-tree/cpu-topology.c @@ -319,6 +319,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 0U; + unsigned int next_cluster_id =3D 0U; + unsigned int next_socket_id =3D 0U; + + 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; @@ -330,6 +379,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 77475ee363..cd8b7212bc 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include =20 @@ -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_CPU_TOPOLOGY) + return cpu_topology[cpu].num_siblings; #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 7a7042c84e..301ee0dafa 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 1U; + 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 896eefb04f..3fdbc25e8e 100644 --- a/xen/include/xen/cpu-topology.h +++ b/xen/include/xen/cpu-topology.h @@ -10,6 +10,10 @@ struct cpu_topology { cpumask_t thread_sibling; cpumask_t core_sibling; cpumask_t cluster_sibling; + unsigned int phys_core_id; + unsigned int phys_cluster_id; + unsigned int phys_socket_id; + unsigned int num_siblings; }; =20 =20 @@ -18,10 +22,16 @@ struct cpu_topology { extern struct cpu_topology *cpu_topology; void init_cpu_topology(void); =20 +#define cpu_to_core(cpu) (cpu_topology[cpu].phys_core_id) +#define cpu_to_socket(cpu) (cpu_topology[cpu].phys_socket_id) + #else /* CONFIG_CPU_TOPOLOGY */ =20 static inline void init_cpu_topology(void) {} =20 +#define cpu_to_core(cpu) (0U) +#define cpu_to_socket(cpu) (0U) + #endif /* CONFIG_CPU_TOPOLOGY */ =20 #endif /* XEN_CPU_TOPOLOGY_H */ --=20 2.43.0 From nobody Thu Jul 23 22:29:25 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=1781680379; cv=pass; d=zohomail.com; s=zohoarc; b=hO/NkYgji9RLh1Yr+qBnTaXepupTVPYigqtI4rPEgVAakriximRxAnM3FUCXSuEY0nQ4VBdkFzIWn1zzykrPF5T7+zHDQQaX8WUj1b/IrtqAMz6unK83BhYp+eDO7Ccg5ZFvAZmBtIAAeXC8rFH5p0oheoNsDZ/IjUzWoXxYrGE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781680379; 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=k2KTn+T1/dWiIJ4PgQ6w6uI7w9H8uIIvL/CHANCwHAM=; b=IRqlAAv8mLZ3YWLjwhle+YrntfBm7xJ1O1e96dg/KvluHGzwgLlovQ3qv+rLAayyRqVHmMEMxvolTo+wN1rvrSDqhAG4lY+6+XcDeqOs+nL68Qs4N3/AhbPBbciNT5qirOFaq3PgYNk33pROqzT7arCXoh3RfdeS0IpUTSb87U0= 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 1781680379136943.7728742117102; Wed, 17 Jun 2026 00:12:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1339818.1600916 (Exim 4.92) (envelope-from ) id 1wZkRk-0002Y1-HA; Wed, 17 Jun 2026 07:12:24 +0000 Received: by outflank-mailman (output) from mailman id 1339818.1600916; Wed, 17 Jun 2026 07:12:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZkRk-0002Xu-E8; Wed, 17 Jun 2026 07:12:24 +0000 Received: by outflank-mailman (input) for mailman id 1339818; Wed, 17 Jun 2026 07:12:22 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZkRi-0002FZ-Ku for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 07:12:22 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZkRi-00CS1m-1d for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 09:12:22 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3248ce-5cb7-0a2a0a5109dd-0a2a4507bf88-26 for ; Wed, 17 Jun 2026 09:12:21 +0200 Received: from [52.101.125.100] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a3248cd-229c-0a2a45070019-34657d648175-6 for ; Wed, 17 Jun 2026 09:12:20 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by OSCP286MB5166.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:34e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.139.11; Wed, 17 Jun 2026 07:12:16 +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.0139.009; Wed, 17 Jun 2026 07:12:16 +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=c/h2+bgeqLbEgFpdnSBC/dP41RVd3zHUjGAc54s3npr69oYHhdEmsFc28yTZg48nKe9Y7bAD/AiYPk08GwtLbOxPN8O0rpZ0cwXenDUepRlRu45XQ6NBmxBIE3mG/t9bgTDfXFlWMPddKcMd3fKFgtzf3P/LAtCaB1NyZO+dPQQDoW3ArsmBgXDRtZUj3rjijCgVzRK/vkXNIBqbrO28Q0QK57Mgph18PY1mkSwDWUh4msiM4V1yXyzRCK03ho8qR/tQxh/J7w8UNXvzuMGku2tzJdhBoFrh7DnAxAFDmVY9yBB+gnXw+BeyZ/jQOltqGwjuJHhK3/wxQgGASoss5g== 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=k2KTn+T1/dWiIJ4PgQ6w6uI7w9H8uIIvL/CHANCwHAM=; b=HUpbhzcwAgFizpBVSHxA9f/pdoIvaF4BCdI3xy5pzbsqoKQMPNbGH4sIXRJFcsGci133Zk6OVHtUiqD5MYRNmDPBcgCuBOCD7nPnIK2ERSim0HvYbzLQp4q2bfJAhocJmsVc2LkE6Dg9DZF4HY1MteyhnkzfiUBQS5nqY7xgugoyEtTJOvo4dMi7a57mn1klVfvI+v4roa+WC4f6Y8mOSYCu8MXlCLQw8JQywlnrPoag/2L7wvMkLIENkNMCi0T81w5rEYaOyTWRU5rin3H1NsCRWKnH0Zf1fzGYapbyTNmoyqyuDU9m8ykaPiB4AcMPVYbLT5n0qSKcEw7hiyWcTA== 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=k2KTn+T1/dWiIJ4PgQ6w6uI7w9H8uIIvL/CHANCwHAM=; b=JBS1GEuOTsluwOO9fLpvbFO+8rAKJh7HilzGoEEaneoY33u0HYHzxFrkOrGcVfUPR+t6EeWeRqCivEiU49wNhvp64veBaSz6YyL/xDULT8E/P97ztV2lNRukXpm3Tx1VbpGAWMTY691QvJE8kLAOC7GqlyMdedQRTpYA8U3q5/k= 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: Mykyta_Poturai@epam.com, 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 v2 3/3] xen/sched: Make cpu_nr_siblings() architecture-specific Date: Wed, 17 Jun 2026 16:12:06 +0900 Message-ID: <20260617071206.265599-4-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260617071206.265599-1-taka@valinux.co.jp> References: <20260617071206.265599-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY4P286CA0008.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:26d::15) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|OSCP286MB5166:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bf16b32-487b-4d7d-fdd9-08decc3fc2ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|23010399003|10070799003|7416014|376014|22082099003|18002099003|56012099006; X-Microsoft-Antispam-Message-Info: GBxlGdtgOAFVEHmhjWaflITYFupOwLbwOnQdJf9uQLFSRuKWUjNHA1BS7RZ5CMPP9Y6PxIggG6yw690vhoTWC6/LQne8IF/sNHUOM7P2sF2RzICChMsBWMBJlEp+xfFS00Kg8iUmZwM2TEmXe5FjOdZKeu52ccPNXdcXE6tGac3Z+WDuLTMxjxatXMkuTjBdOtg0oKmEiCRuE9Pk/UUxznKPmrv5Vb/5woacqVCY2/wz2d/hOzCM/92bkgYNR+57UybBTSJL0GWLCJsUqxkxC3k3EDJRbJSRPmQl/d9jQcjbMryLgpbUTjMdpw5O0DRMmWuSXY1r3ZqF39m9w+gXzFrM3Vhb9g3pHr1yJ6sqIsVc+O6wGjF+myMiCuqjid86591+KEi6Moruj4O2Cj3S1nMjRBlCbBG/PM4xyZ+QQRJMsPZKTR0bemanngqGDlHeMkzXTByJbgWxWNESLckbOTScn9pmw3Bwqr0wlVlnFVGmrYrUpiA5ROJ5GcQFFCz1XCrPQ9/bHeAO/z9p5q7c8d/dnrXwUChoiJ3sOEesat9wTzGPqS0IMJRnwGd7RBEWNs5yQCe4Zt/MBrgMcy6uwGFY0yZDFI8gp+h+1sMBCpjSwDgYqVxj3WDULxPtzNVlb7UP1yyFJn6LyHTeHEjDrIE1ZRG1T7/qXU1dxV6cgoQ1HQ6QrdrRuM3Lj5xAeKyP 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)(366016)(1800799024)(23010399003)(10070799003)(7416014)(376014)(22082099003)(18002099003)(56012099006);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mwH1gbLRUjDdj6EkY8DRgd2GI9RJ6onISq20dtGffA3A6u2dbkR7Xr69rxno?= =?us-ascii?Q?mMX4T5gekYDEtB1JZI7Atp0q3CYH74pfJvBP+d9V5fOvuEcKwbCqjlTsnimK?= =?us-ascii?Q?RvicmFimEoJ5tuXY1kLQowzbl6kMeNw1fkVX0UPqSRpXIy2G/8aj6t37wCId?= =?us-ascii?Q?s+QIJxguDSKQg0ZPSzXeQQ1ITnv9hrBtXypHHbEzRDpAnHkcUBc7EQ8eonpU?= =?us-ascii?Q?e2udK9qiER3bHqmVgIRkAR5XZ/YbGwbxM3YnRWS32Skne3UkgqtlfkWct2eJ?= =?us-ascii?Q?reb8M2BvgcULOJv7/h9vgnNhj28Wlc6RICLyTnmrG339x5LoIt3lHncRGnqo?= =?us-ascii?Q?AkQPE3kWJwizUT9z0uyvC9TYtEiZUQDNnpSjhO5kMlmpjXxJKa0pp9j/fFcH?= =?us-ascii?Q?J7L/3t5OiNYCqc3n9GYKNRkkcFOtT4ZXXhn27JzpjsS9DHkkB00Diqcf1Uva?= =?us-ascii?Q?Xowq/AdWTOFBVoo7WWKdNAaMqaIQ4PEzYzQDtWzHpKIrBDZslYRvmfVdkGKp?= =?us-ascii?Q?uCjHM1UxiCIeVPUJHggYuM/uIh+cZQ/q9TB6szg7f0ZIRiN/WanXFkXxrmZc?= =?us-ascii?Q?AMWkuY0YCHEjuaiSwO60mh8pZnX+Bk7ufsRJakedjUgYOSQbXzusMUs4s7HF?= =?us-ascii?Q?dSO0vBL/3xv8TCUYbJaCMPjE6i3pv2rKQLacd5KQ75vX5MRgYn+87Ln/GHik?= =?us-ascii?Q?yiBLOpSUjGUW1Jcwnqiobw+uSvEh41l7//XQiIZ7zdgbutUPntWg7q1SMJK7?= =?us-ascii?Q?7ivGS7CSjkFIQzd4/2WAh90ivm8AJShfP32UKbfMEXilj/HMk3S/iP6T3FLt?= =?us-ascii?Q?G7u/jhV8Eo2KS9Cz99t21ABE/Gty5gy8mCBQhQOaX+w+M5GaDJtn3gJSIlfT?= =?us-ascii?Q?O3q8TG2CxT6RS8IpRL7wMM+loCD53wzI8nSG8h/QEoDYrIiAEFFO8OBtSZec?= =?us-ascii?Q?mwl27jUbHZIcGHo3SGw3sz7RUE2jb56vyz5qpiVFimk1ld+VhnTXh7YtrT+B?= =?us-ascii?Q?YuwfDEQidyWLVjThX/+A4KwO8m6Bf2bJjJBAFDaff2xJEoS00gJEJV66H9NU?= =?us-ascii?Q?4IP0jnBKCHL6UlDbVheOSTXGfIWBsv3aZNgIpXq2ZOxgTYPBIaqoS0HbtNEC?= =?us-ascii?Q?cOwDPF0z/3SUyOq5Y4RM6AUKP4vtl1zyqlJpbceLIFURGPrcTenKInEKYrNQ?= =?us-ascii?Q?v2Oys1PTkmYD4FJCTi80b2rQ9ohbm6sOXrd2g7VXrozw+LgJbbvzLOyOXrGx?= =?us-ascii?Q?zR02ueluItkJ4U6nU5qFFuudDFbpaRFNouvK+bWe7ilfDDY5Q1OEr0kXf04p?= =?us-ascii?Q?6MQE0nwEIhSJgUiidiCgJiNNEAiIOVwJ8m7BReT4IjobO1BklIs20CuZYKNc?= =?us-ascii?Q?omsrqWYyFXQ36Goc+9XG6/9FAIkHf/2xUwM2fuh+zxG4ZQeS1I9Rx1b/sTNs?= =?us-ascii?Q?QT12QPmuzqWNBpkdUWRiNTNIKyecXBkDS/jIO8NHOiKQOLhxKvFBQUDJMDp2?= =?us-ascii?Q?QemQ1OSKnlY/64s0Fb48Sy8fIXfvp5EIXqpv1NoiQddZUS6ZnUzGFolJxzWz?= =?us-ascii?Q?JU+o60XLf4wkWSocun/JK+TOKSF8r8cxrqdP1X2zsIbr4r1vsSfgWCEtyqvD?= =?us-ascii?Q?OUwLnDr6bSklZBBLJYJyB32GCJuiGr9iay9kcR9xcWIr3Svu2qPDWGvdCRTH?= =?us-ascii?Q?oYOKcyY++UbxhK0ZM3AYoSNwW6yiUkcb9Boutyt7SDgEqaCbdYnp6wQUf2Cj?= =?us-ascii?Q?xlfFoLrO8VX8PUgzl0STNjv15bbLszLTDz6KrIZazIl5U2xncFzMtBeKDyQE?= X-MS-Exchange-AntiSpam-MessageData-1: hQ3eQB43x2EPIA== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 9bf16b32-487b-4d7d-fdd9-08decc3fc2ed X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2026 07:12:15.9389 (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: E8HoE2elwqm7fwW+Zl8Lp9UioY6ANjBC0M2LqkicMajv5lkOD434BtBkVaQMQwoDaVeLS2yudG8TjKeH/8PezA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSCP286MB5166 X-purgate-ID: tlsNG-ef75cf/1781680341-0A971C48-C0205E46/0/0 X-purgate-type: clean X-purgate-size: 3169 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1781680380903158500 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 --- xen/arch/x86/include/asm/processor.h | 1 + xen/common/sched/credit2.c | 22 +++------------------- xen/include/xen/cpu-topology.h | 2 ++ 3 files changed, 6 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 cd8b7212bc..7623e57549 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_CPU_TOPOLOGY) - return cpu_topology[cpu].num_siblings; -#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 3fdbc25e8e..3f748f0384 100644 --- a/xen/include/xen/cpu-topology.h +++ b/xen/include/xen/cpu-topology.h @@ -24,6 +24,7 @@ void init_cpu_topology(void); =20 #define cpu_to_core(cpu) (cpu_topology[cpu].phys_core_id) #define cpu_to_socket(cpu) (cpu_topology[cpu].phys_socket_id) +#define cpu_nr_siblings(cpu) (cpu_topology[cpu].num_siblings) =20 #else /* CONFIG_CPU_TOPOLOGY */ =20 @@ -31,6 +32,7 @@ static inline void init_cpu_topology(void) {} =20 #define cpu_to_core(cpu) (0U) #define cpu_to_socket(cpu) (0U) +#define cpu_nr_siblings(cpu) (1U) =20 #endif /* CONFIG_CPU_TOPOLOGY */ =20 --=20 2.43.0