From nobody Thu Jul 23 21:17:01 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=1784025961; cv=pass; d=zohomail.com; s=zohoarc; b=Tdyw3TLFK7As2Qe4/wKJgF3UFnJ8677678uLtz1L9t90EQ7vG6KyOE95eHgoTyEuOk1ycPpE14jvFSWCaTx6OKf8d/1fzAJF8CyJ5mgp9rToKL3F2v9/xEWMTEBMgu5NhcHRpKOkNO2YnlHs+NYl+9g6TKqHIiTRPYS7zHAGlVY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784025961; 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=NvwQZehxXB09vIZoJkUcftBlcMfxyVb3a3R+w/6waGc=; b=RecNpfcdkJ+hWG5zGhIdQwDL1BDa4duSzP3Y0PSWey3zfzofAVLwPo43y3mLiNhzt5RJgw8JFpWLWQNd0w0Bv5EzqaQFOreHzplw6nzQWV4C9G6Tw6278cOOhTVwgHNTBJgVRD3TpZzFFAdZZRxaclYEwumgGlRxh/5Q3pKU+WA= 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 1784025961546541.6074554386756; Tue, 14 Jul 2026 03:46:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1362129.1614043 (Exim 4.92) (envelope-from ) id 1wjae1-0005mw-G5; Tue, 14 Jul 2026 10:45:45 +0000 Received: by outflank-mailman (output) from mailman id 1362129.1614043; Tue, 14 Jul 2026 10:45:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjae1-0005mp-BI; Tue, 14 Jul 2026 10:45:45 +0000 Received: by outflank-mailman (input) for mailman id 1362129; Tue, 14 Jul 2026 10:45:43 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjadz-0005mR-Hm for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 10:45:43 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wjady-00HHZm-Up for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 12:45:42 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a561351-2eae-0a2a0a5409dd-0a2a4509a954-6 for ; Tue, 14 Jul 2026 12:45:39 +0200 Received: from [52.101.125.100] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a561350-be1a-0a2a45090019-34657d6404e0-3 for ; Tue, 14 Jul 2026 12:45:38 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by TY6P286MB7347.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:361::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.20; Tue, 14 Jul 2026 10:45:34 +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.0202.014; Tue, 14 Jul 2026 10:45:34 +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=xJTr6O8u3zxBDmTr3h6rx2n/qXpqyoBQOYvPdSmWMZ3OJjT7Lvc1e6aKrX0M1J6Bpb2ZgIDLrFWsETR0uvcir5IChFk1ePcgM2rOvmAiySnrIO9tmCI+ic32B0JRvPClZ4KWAPoaQkf6nO3SA4IXny8hWj6h9dGIZWAVcPHc3K/wGPncA6ZCvKlthLDnAUglM8YpnqYZ2FaoyyrZ5oApyyqoxnyMowlAaKrf6bLKt8RNKx0Q5TRAAIwyaNxlv02K2vNjX3LT8qvu8VHhT9qpOHwlyFjLhKxdTmnatAax7lURDRiGUqqhDTfylzHAKdrDhW7gKjF8k5pA2W9fGtvjZw== 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=NvwQZehxXB09vIZoJkUcftBlcMfxyVb3a3R+w/6waGc=; b=pL9v6RT8hXfsZBXCwnFQ/vAA6z/wL3q+4Oi7vKJhZd+c+mhuAqoMaB9lXSof2zrtSF/EUhGYv/dPW8i5aHf67Ot3MSaN8S363WkRa6XzqqGWJ1b/seRpiSKBFTArH/lRaTqGh0flsiqgJhkQRnUA1fFyEp/WePvU1SYvgY79v/2326wnXSkZSJJsAJmIeQ4yK9YCc+LRewCqOSIu4SB5IBVgV5c3W57geekEs8/GRhTSs3VPD0wm6u4baz07DElYbdMLhfH4mBmOGgdSYWBnGcQfiuQRmv9s+i/mCG2CVRTt0MAlYMREXpKhwS81epD8JF7lwapboUI++S+rhoKxdA== 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=NvwQZehxXB09vIZoJkUcftBlcMfxyVb3a3R+w/6waGc=; b=G2pToSkmTgLr3HbeoLD1sDIZyBdyimawIHMpthn75mZfZpWrAbWfCyYvPak0DIO37VQhd7tMWZLjppcVE0yQViTnJx7ofEjAN19AFYPMejA+OSr50J50Fc9vc+o+BH5XuiPnCrMR8ZNYcGto1Tgphbnf0fIGJ80TfL4ykOIA+MI= 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 v6 1/5] xen/device-tree: Parse 'cpu-map' node for CPU topology exploration Date: Tue, 14 Jul 2026 19:44:41 +0900 Message-ID: <20260714104445.919830-2-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260714104445.919830-1-taka@valinux.co.jp> References: <20260714104445.919830-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY4P301CA0073.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:36f::7) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|TY6P286MB7347:EE_ X-MS-Office365-Filtering-Correlation-Id: df01bb8f-2de9-46cf-e343-08dee195085c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|376014|7416014|10070799003|18002099003|22082099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: QrgFVUVgxwSTLvb7y6tFWyNSVev1DKg9VP3adNJbmg8VL0CdZ00nnvRln+Vv8WGVE3IZ3wqQMViaBdr/yyLh+uzKIqBttJEw0woFt0qOgFq0HKOPBL0nLXfeFqVR7/Gnlrgpu1Y3WDB32TBZdzHN2dZkU0IMtPFly4vSMlTpXWNPOjzHEeE1ZUVm9CaFi7/CMmZz0sKR0fQYCobqWJy/0xWz3EvXjgdMP6Qd6SAPimDazf+m4xG22GRtQ5V9bUOrz4nriAXtOgby0qAcoDz8iahfetWCH2ZiJ2nZWmbOwOoP1Xk3rClsjmUeZG4a/sWYXqc5QzWnhfGRsMvXEqWqPmZ4VzESWEONcoU8V14g6nrgNjeKFHVzgAn0laQe43ewxN1DyWmJB+RoZTEkjnuCR73Zx65egdJQb+Tbi7JpXVoZrUkkbL3R10dWAoh8oYudgvw4sgWlmDuNdsFroy18O6QxsyszRGFMhLILMjpx47Zp1BuvWjGjL3Ka54E+57fYSaFxgrMa+xtdq5DTr8waLjV0e9/ah3xc4as4tXGQEd7bHfeR17q13kY2DEP+gWUXBf68Mh7MXR8oSOGlTMFxrB8mCui1V3tL4iJCGEwlH1SqcJBPdn3+s5tA0rDr3It5dzVYGeu8ZSQhjSfQRMrPx8fFWI83wxxf3LUf4CvW9tk= 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)(23010399003)(1800799024)(376014)(7416014)(10070799003)(18002099003)(22082099003)(56012099006)(6133799003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?HGBYhjz1qFA4B+Fi4ockFMrHmN8pmtdWOKjRqnExMYrGjrpJJ9dLRlHvyQ04?= =?us-ascii?Q?J31PNEXFCT/hj9X+MeqW7Fzqy+MbNvTMu/3q9v25oe0eU3oO5WECRx+Az9Q7?= =?us-ascii?Q?NAsvjdZZm+ajaNQM7qAxnz3aXl3bXARtRDFTWxzEzu8N37EpyCHlxFA3ujE0?= =?us-ascii?Q?vhlw2VmX5OsbvrNs5uinRYj8M9IyKtWj9VvQoX+GCKqib4WioAUAMBCar4TR?= =?us-ascii?Q?lolukV4yP+7JHIXkj9c53De/AsljwLdwh3MDDJjE3aqTaBxk6GQm2u01o0xM?= =?us-ascii?Q?IPgeORqFt5eTX/0rLs4f2J9Ns8aN2rIUBoEKlSgBMM3Iv+EaHhck7JDPp9eW?= =?us-ascii?Q?1x3ujksdzU/vvsYcFSREO3MXi5r59RNwIp+luGYs+xQ0GOmqQ1u4NWstQSs/?= =?us-ascii?Q?jdDtX7V4RINeZ+VMmblFlunjYxS5GxyXw7Udu3JjzFNqI+Crs6dnp6XfKbw/?= =?us-ascii?Q?hUVb4WNFwm/PGvZ2vBRnh90W/aN3c5uQ6wCT0Y4Su11cVAGTPAIcUSmlapDY?= =?us-ascii?Q?crfOYdzCT1zdlmTzuj9uFuIOha5XYiDFmbT557fjF4vzPvbsc9/MjsFi7ATl?= =?us-ascii?Q?sE6HEucqhasWOPb8V57LBPIkeDrqOfLBJhq4qUHBaTfit/+NF1f9xINzyQgz?= =?us-ascii?Q?k0r2FDk4+dWRg/dAZsTNs8TZL5SCmYkk6zH1P/vblFYbOgeqiJDaCZKg5hH7?= =?us-ascii?Q?Sqc59gEF5PBijFX25/X7wOrJOMn68UTv3jty8oEpgEojxdW+idzwqkO1KuCd?= =?us-ascii?Q?but4tQYhmmc6D2V1hxQ5NgNIoMtJ5QqliytLVWrFm2rQlxrHub3IU+nhMj1A?= =?us-ascii?Q?mfPpGEy54CA6el5l6lKyC/CzfHCeXhYQnpMtvv0P1NeZt4hM9mQ1UIvQ87gO?= =?us-ascii?Q?2SwmKZ0Z4jfuXZ02njg5jvTB24NUh26x9GIBtVFPRrpR0tEwUG5qHDGiUm9h?= =?us-ascii?Q?iFnAtU2nmG9OCq9p31VHJG/paOFtG0WKpnWk+odcEaorjc1o5HiPJTub+y1w?= =?us-ascii?Q?pSUAsvaY9MsIqtZQSCazFcwthkDwZWXrSEStFPzAxxN3Bs988ixS7tWfj7iz?= =?us-ascii?Q?lTcpNueHpXmxvQcMpTrU8+EAh4SLRWn5GwWK/R4gIfkE+lfngLdpXDfvH2Ih?= =?us-ascii?Q?1h6ILzYoWuIFrdg9rByjkYkh7+PUeBieJHlFcC/rikD0Xs4qRY2/pzoEiC3f?= =?us-ascii?Q?h3JpkLbIcvnHlvfQjNfh3BTUB7xRVom0Nt2SHFgnNwwEwcxTANu6VoU+oPJn?= =?us-ascii?Q?L9hsd2vqYMUi4GKUy490mhmnon0iluH55hL/qLBI19ra3xNoVTS+4vcUjL3+?= =?us-ascii?Q?3nqzuGlUtJFCmLR+lebjLtPUHwHazVuxD52oHIwqDnhhl8WtiPuEE7EhWdKm?= =?us-ascii?Q?hoBTwOFjj3O54xFfeTFjQqpCeuezNwxaW4ptaqtKI/QqgIZkI5JK9O/8G6Md?= =?us-ascii?Q?mOxYMwYt0scd8Pss0uUszW+G5tFCZReFf0evW90bmKuzFRU6yI6bzdgptI9f?= =?us-ascii?Q?ZicrzY/dR/hXCbsC/YbRpJxGAQnXlqHtF+gLS0bbEtlEardBDDeEpgeyZzhZ?= =?us-ascii?Q?sUU4KDcrCbmP6prQyJBXSQJQw3sAu5zis1HQc1UDZHujSEgm+l5zk3pHeIK6?= =?us-ascii?Q?eu0kOneNvjPnkd9+PZJs+a5H6DkGD7tP4/+Ozr1cY3trphUGBmycfZlB7Zrh?= =?us-ascii?Q?hBFti14nvdu6eGcvPlUxVDlJVkiCjx10BldP5ZlzWOwKlgesuzbPfHbqdfi1?= =?us-ascii?Q?8sjGJNw7Q3MGQm/BM+9S3ePoZYdS8vfARCF53VDmQzbI2Zqi4eE3iSSykE2Y?= X-MS-Exchange-AntiSpam-MessageData-1: XfooPvzFYSocoQ== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: df01bb8f-2de9-46cf-e343-08dee195085c X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2026 10:45:34.0612 (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: 7FlmHVx3mFyDb9AsfW9AKTWc/dYb9ZURQG9wGMAD7P+t1H4a9Ok5TpaL0toEKoDdWj/dG18z8j6azXKs/jV8Dw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY6P286MB7347 X-purgate-ID: tlsNG-bad1c0/1784025939-BC2F4034-866769C7/0/0 X-purgate-type: clean X-purgate-size: 22679 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784025963701158501 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 --- Changes in v6: * Updated Kconfig to make both DT_CPU_TOPOLOGY and ACPI_CPU_TOPOLOGY select GENERIC_CPU_TOPOLOGY. * Ensured that if topology parsing from either DT or ACPI PPTT fails, the CPU topology table is freed to fall back to the non-topology behavior. * Moved the `cpu_topology` definition to `cpu.c` so that variables and functions in `cpu-topology.c` can be completely freed after Xen init. * Avoided assuming `np` becomes NULL after exiting `dt_for_each_child_node()`; explicitly return NULL instead. * Optimized `setup_siblings_masks()` to eliminate redundant loop iterati= ons. * Replaced the `invalid_topo_id` constant with the `INVALID_TOPO_ID` mac= ro. * Initialized all members of the `cpu_map` array with `INVALID_TOPO_ID`. * Applied the `static` specifier to file-local data structures and funct= ions. * Renamed local variables to more intuitive names. xen/arch/arm/Kconfig | 1 + xen/arch/arm/smpboot.c | 7 + xen/common/Kconfig | 22 ++ xen/common/Makefile | 1 + xen/common/cpu-topology.c | 65 +++++ xen/common/cpu.c | 5 + xen/common/device-tree/Makefile | 1 + xen/common/device-tree/cpu-topology.c | 343 ++++++++++++++++++++++++++ xen/drivers/acpi/Kconfig | 3 + xen/drivers/acpi/Makefile | 1 + xen/drivers/acpi/topology.c | 41 +++ xen/include/xen/acpi.h | 13 + xen/include/xen/cpu-topology.h | 34 +++ xen/include/xen/dt-cpu-topology.h | 35 +++ 14 files changed, 572 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..1e0fd4957e 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -19,6 +19,7 @@ config ARM select HAS_ALTERNATIVE if HAS_VMAP select HAS_DEVICE_TREE_DISCOVERY select HAS_DOM0LESS + select HAS_GENERIC_CPU_TOPOLOGY select HAS_GRANT_CACHE_FLUSH if GRANT_TABLE select HAS_STACK_PROTECTOR select HAS_STATIC_MEMORY 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..8e64b58739 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -140,6 +140,9 @@ config HAS_EX_TABLE config HAS_FAST_MULTIPLY bool =20 +config HAS_GENERIC_CPU_TOPOLOGY + bool + config HAS_IOPORTS bool =20 @@ -191,6 +194,25 @@ config VM_EVENT config NEEDS_LIBELF bool =20 +config GENERIC_CPU_TOPOLOGY + bool + +config DT_CPU_TOPOLOGY + bool "Device tree based CPU topology support (UNSUPPORTED)" if UNSUPPO= RTED + depends on HAS_GENERIC_CPU_TOPOLOGY && DEVICE_TREE_PARSE + select GENERIC_CPU_TOPOLOGY + help + Retrieve CPU topology information from the device tree to optimize + virtual CPU scheduling. + +config ACPI_CPU_TOPOLOGY + bool "ACPI based CPU topology support (UNSUPPORTED)" if UNSUPPORTED + depends on HAS_GENERIC_CPU_TOPOLOGY && ACPI + select GENERIC_CPU_TOPOLOGY + help + Retrieve CPU topology information from the ACPI PPTT to optimize + virtual CPU scheduling. + config NUMA bool =20 diff --git a/xen/common/Makefile b/xen/common/Makefile index 6018e25614..901bb37925 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.init.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..374b3fce1b --- /dev/null +++ b/xen/common/cpu-topology.c @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include + +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; + int ret; + + 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 ) + ret =3D dt_init_cpu_topology(); + else + ret =3D acpi_init_cpu_topology(); + + /* Free the CPU topology table if initialization fails. */ + if ( ret !=3D 0 ) + free_topology_table(); +} + +/* + * 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/cpu.c b/xen/common/cpu.c index f09af0444b..3242adb6f0 100644 --- a/xen/common/cpu.c +++ b/xen/common/cpu.c @@ -46,6 +46,11 @@ const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS= _TO_LONGS(NR_CPUS)] =3D { #undef MASK_DECLARE_2 #undef MASK_DECLARE_1 =20 +#ifdef CONFIG_GENERIC_CPU_TOPOLOGY +struct cpu_topology; +struct cpu_topology *__ro_after_init cpu_topology; +#endif /* CONFIG_GENERIC_CPU_TOPOLOGY */ + static DEFINE_RWLOCK(cpu_add_remove_lock); =20 bool get_cpu_maps(void) 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..be82272c14 --- /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 + +#define INVALID_TOPO_ID (~0U) + +struct cpu_map { + unsigned int thread_id; + unsigned int core_id; + unsigned int cluster_id; + unsigned int package_id; +}; + +static struct cpu_map __initdata cpu_map[NR_CPUS] =3D { + [0 ... NR_CPUS - 1] =3D {INVALID_TOPO_ID, INVALID_TOPO_ID, + INVALID_TOPO_ID, INVALID_TOPO_ID} +}; +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 cluster, 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_cpu > cpu ) + continue; + + 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) ) + return np; + + return NULL; +} + +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 %u exceeds the max cpus %zu\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 Xen 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, "cpu", 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 thread_id; + unsigned int cpu; + + for ( thread_id =3D 0; ; thread_id++ ) + { + const struct dt_device_node *thread; + char name[20]; + + snprintf(name, sizeof(name), "thread%u", thread_id); + thread =3D dt_find_child_node_by_name(core, name); + + if ( !thread ) + break; + + leaf =3D false; + cpu =3D get_cpu_for_node(thread); + + if ( cpu =3D=3D INVALID_TOPO_ID ) + { + printk(XENLOG_ERR + "ERROR: %s: Can't get CPU for thread\n", dt_node_name(t= hread)); + return -EINVAL; + } + + ASSERT(cpu_map[cpu].package_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].cluster_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].core_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].thread_id =3D=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 thread_id; + } + + 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; + } + + ASSERT(cpu_map[cpu].package_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].cluster_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].core_id =3D=3D INVALID_TOPO_ID); + ASSERT(cpu_map[cpu].thread_id =3D=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 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; + unsigned int child_cluster_id; + + /* + * 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. + */ + for ( child_cluster_id =3D 0; ; child_cluster_id++ ) + { + const struct dt_device_node *child_cluster; + char name[20]; + int ret; + + snprintf(name, sizeof(name), "cluster%u", child_cluster_id); + child_cluster =3D dt_find_child_node_by_name(cluster, name); + + if ( !child_cluster ) + break; + + leaf =3D false; + ret =3D parse_cluster(child_cluster, package_id, child_cluster_id, + 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; + } + + /* Now check for cores */ + for ( core_id =3D 0; ; core_id++ ) + { + const struct dt_device_node *core; + char name[20]; + int ret; + + snprintf(name, sizeof(name), "core%u", core_id); + core =3D dt_find_child_node_by_name(cluster, name); + + if ( !core ) + 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(core)); + return -EINVAL; + } + + if ( leaf ) + { + ret =3D parse_core(core, 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; + } + } + + 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; + int ret; + + for ( package_id =3D 0; ; package_id++ ) + { + const struct dt_device_node *cluster; + char name[20]; + + snprintf(name, sizeof(name), "socket%u", package_id); + cluster =3D dt_find_child_node_by_name(socket, name); + + if ( !cluster ) + break; + + has_socket =3D true; + ret =3D parse_cluster(cluster, package_id, INVALID_TOPO_ID, 0); + if ( ret !=3D 0 ) + return ret; + } + + if ( !has_socket ) + ret =3D parse_cluster(socket, 0, INVALID_TOPO_ID, 0); + + return ret; +} + +static 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); +} + +int __init dt_init_cpu_topology(void) +{ + unsigned int cpu; + int ret; + + BUG_ON(!acpi_disabled); + BUG_ON(!cpu_topology); + + ret =3D parse_dt_topology(); + if ( ret =3D=3D 0 ) + for_each_possible_cpu(cpu) + setup_siblings_masks(cpu); + + return ret; +} + +/* + * 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..ef0b9a4502 100644 --- a/xen/drivers/acpi/Kconfig +++ b/xen/drivers/acpi/Kconfig @@ -2,6 +2,9 @@ config ACPI bool =20 +config ACPI_CPU_TOPOLOGY + bool + config ACPI_LEGACY_TABLES_LOOKUP bool =20 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..45d1f2c5be --- /dev/null +++ b/xen/drivers/acpi/topology.c @@ -0,0 +1,41 @@ +/* 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). + */ +int __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); + cpumask_copy(topo->cluster_sibling, &cpu_possible_map); + } + + return 0; +} + +/* + * 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..cbb02e0f35 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -135,6 +135,19 @@ static inline int acpi_boot_table_init(void) =20 #endif /*!CONFIG_ACPI*/ =20 +#ifdef CONFIG_ACPI_CPU_TOPOLOGY + +int acpi_init_cpu_topology(void); + +#else /* CONFIG_ACPI_CPU_TOPOLOGY */ + +static inline int acpi_init_cpu_topology(void) +{ + return -EOPNOTSUPP; +} + +#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..7cfe3752cd --- /dev/null +++ b/xen/include/xen/cpu-topology.h @@ -0,0 +1,34 @@ +/* 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 */ + +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..72b35b3cf2 --- /dev/null +++ b/xen/include/xen/dt-cpu-topology.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef XEN_DT_CPU_TOPOLOGY_H +#define XEN_DT_CPU_TOPOLOGY_H + +#include + +struct dt_device_node; + +#ifdef CONFIG_DT_CPU_TOPOLOGY + +void map_cpu_to_dt_node(unsigned int cpu, struct dt_device_node *cpu_node); +int 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) {} +static inline int dt_init_cpu_topology(void) +{ + return -EOPNOTSUPP; +} + +#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:01 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=1784025965; cv=pass; d=zohomail.com; s=zohoarc; b=CeH0wB+2ISXP5fU7QGAqFBvAZcFmjeKiuizLU8YovVHCvbjM2hNFzyz5wmMUns8MYqTFQo6Bz4s4c6L4i9j3GlC8nTeo3N2APIzIMerImHa4INdYNl5p9WnG2e92qPvu3FHWewS8i8vfKmI8aeNnITRcwBYWBVkZ0EV30mCjkjA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784025965; 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=LrblDw5uEnhXPxxiY8E5MhWRyS6n6kgC3oSPKKTLtMs=; b=VvLO2DPDiPKLrHY70b+jim8necDZEOQLsO/O/AnEQjVe7bE4mgwNVE0v+2W5r9a4/VKX4sZ+f3ngt5Qh8bOmLZbJA2Id1RIG/aAQyp+uWr8W4M6JfLAGF4MZx6KrT3bhvAl3J/c2/fdKzTj2JSixffSjgNmphJ6Y5dp/CexHSh4= 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 1784025965647935.3508748447938; Tue, 14 Jul 2026 03:46:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1362130.1614051 (Exim 4.92) (envelope-from ) id 1wjae2-00061E-PR; Tue, 14 Jul 2026 10:45:46 +0000 Received: by outflank-mailman (output) from mailman id 1362130.1614051; Tue, 14 Jul 2026 10:45:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjae2-000617-Lz; Tue, 14 Jul 2026 10:45:46 +0000 Received: by outflank-mailman (input) for mailman id 1362130; Tue, 14 Jul 2026 10:45:45 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjae0-0005md-Nx for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 10:45:44 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wjae0-00HHZm-4O for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 12:45:44 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a561351-2eae-0a2a0a5409dd-0a2a4509a954-12 for ; Tue, 14 Jul 2026 12:45:44 +0200 Received: from [52.101.125.100] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a561350-be1a-0a2a45090019-34657d6404e0-4 for ; Tue, 14 Jul 2026 12:45:43 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by TY6P286MB7347.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:361::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.20; Tue, 14 Jul 2026 10:45:42 +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.0202.014; Tue, 14 Jul 2026 10:45:42 +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=TnnagTWpBkoHsU13BMR9jqYUkWrcXplbMB43zC/nq3Gp8VqWkTDnG+R1YqUhY6eueVfJSt1aNxuihBFcna32Bi+yqQr2n8v+yYmq9/II5zxNPXPaLd4vYWHx1JTJLBYNI7kyKEjUGH/UH1l9LyfkcH8/GmTK3xXoOi0lMXKpu6I64ojqgnjkVqlyPpx3c0zKFovcURmu1a2ksrvw0kza+Um2JGO+6tmBfyks3CMR01i8zVg9fXRtmVj0x8I5NbnapUkVtOzt4anBPxsWT8CmfGBeii1moL4zoVLFzErZ/QHcTS0bxTKQsze99au2KIQYGOuVToaXB92hlzowclxsQA== 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=LrblDw5uEnhXPxxiY8E5MhWRyS6n6kgC3oSPKKTLtMs=; b=f2xI1m4YUIY2KbRxtXsb3jhJ/RZwE2C4lBhZ2aYXKySFUx7879HUbV6QxlO1Bj/y59JTaphxmfkeNr6lnNciTNv7d2R5LSk68P5PH0Ot9b92NzcsxgKoiDxItsS+yh00QUuQnZ540kp2SUklfatOBkpzoiDzAGj7typ1NbBGiVK3Y0O+tVW8uWulLK2XXrtpeKF211Zy5pv5caEhIQjgQla7Yf989L4ys14mq4xXLUww0Q11gmP2EkS8H7sjeqQlFSkqR8ie2xvTYPdeVC9pmDCGg+PE5nmY6qa/vl7RlTX3sdHs7/mdXZY7oWFz5Z2gcN9Zy1gjdt27rkVXspr0rA== 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=LrblDw5uEnhXPxxiY8E5MhWRyS6n6kgC3oSPKKTLtMs=; b=OJXMr2mPwWaGsOpK7+6xe4N+frArLEehIKY8PHnSbVOLp2pfydGwH2f99GEx2sGWnkxotI8aZ71SS19bD8LzHHu4qfHurwJVdYlKayEDSmhqZbnFu22NaFkZRc/fQ7/oBRptOLCFCcJc1U6Ha4US59K+glXtDRYczmBrS5A1fWQ= 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?= , Timothy Pearson , Alistair Francis , Connor Davis , Oleksii Kurochko , Dario Faggioli , Juergen Gross , George Dunlap Subject: [PATCH v6 2/5] xen/sched: Link CPU topology to scheduler Date: Tue, 14 Jul 2026 19:44:42 +0900 Message-ID: <20260714104445.919830-3-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260714104445.919830-1-taka@valinux.co.jp> References: <20260714104445.919830-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY4P301CA0081.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:36f::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_|TY6P286MB7347:EE_ X-MS-Office365-Filtering-Correlation-Id: d1796594-78dc-4920-b071-08dee1950d1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|376014|7416014|10070799003|18002099003|22082099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: sNc9PFKeUkvXPrjgLJEuyg4RQekOJoM9kPCG4lq5JEQ4O8Ca2iLwerM9X5AjPo9FL/MfMihJqFh5jNx1FzT3qhscRXSWbUg8+ADJZjawT5ASBUw8AgZdaANXyi8c2eoNK+/zF6AiyAR3f2rEDLstupilP9Q0JLxT/Zn18tx14NuEsfjTU0mGRoEBRLbqlpqU5FwwkFLu+N21sw3hYnn1RRcNNBNgl8vFBVJvoiWj+yhoZT1W4oCuG8jJzes52hxJLaYlF6UZ+J6T5GCo/dkSmJH0lXN6t9ycylbQrBNiQrh+YKJ3Tdplr/zjli/Yr8qAdaFLMYdEqIBmBBetUY4hIGB+s899dQtXFioDsuvKoBcN6ubkkD8VKKf0EztGuP8u3KFr9H38/IqRiaDIg4OEpvTQ5tEFkwlxEKzHoOpAKyiaGpkTqQjH2jOZwTOw+71+pnBrIPyqbBBWRry+VTy+PPuP5y5YVXqni5r8RhplV0dAnzBi55EeeAab7AllrxXIegiQOpcRTvo+i4eXll5KLZavPh7SwpE/iKUhZCyVX/Ek8ypYMiMPYkeYG+nnwlR3qlv+eDa+JtmbReoSLbOJAypilHRgyoQdNFxvQYTjo/7gTggin0mSpEgSUs7wv0WMQn+niMxDMHMGNodtdCGFNGfBXVIvaLhMlEEtam6TwoU= 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)(23010399003)(1800799024)(376014)(7416014)(10070799003)(18002099003)(22082099003)(56012099006)(6133799003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?1SJGapLDJPB/WiSNpnpE43ngNIfHdbai3xAiCL9nLiX7hnDBBrg/g4QiPTsF?= =?us-ascii?Q?pjkdDbUf3t9ABWqfkZir1eR6UTJzy4UkM+eQg39I4Bsej7Rf7AW+DJmcaC0Q?= =?us-ascii?Q?V087MBnKyUSu2/wGp4yfK9TxapvVDlshRGkSwDTcGH0jSXQdJbUc8PUse+U6?= =?us-ascii?Q?wBs5eBMP7jEqsKSCimbmc9TxaLdtiHp7/tvQ4iamKxD9RA0is9n4owdydO0b?= =?us-ascii?Q?gdRc9rg43kX+LrQdEAxMAs6EnjZbBE4+pX2iyGUwRHx8kDtUKZAxfyif8yYl?= =?us-ascii?Q?DQNggonqdrPusJaoYS3mWo22IJJu6XGZ+6TQCo791T3kWimeBmKVr3KK8nqU?= =?us-ascii?Q?IGBbu1pq7WmlYbfhPFlKrXkxKFjr79hSmYV1LNAbYiKzbLQ2bbmqC+iFy6oD?= =?us-ascii?Q?aNCNSHa/elagsYAyXc5xJz8b7lLCpqSUYwLc724yIm/JNCQv1lwUoESqeG3z?= =?us-ascii?Q?uow9mrFH4wSVk8hIoa/4HqeE1359zLlbYlTQY1dcJRAB8V/iY8f0qBSMnqxl?= =?us-ascii?Q?MMwvMD70SoqmolnhRqHSKj3PIuW/U8ePKTGC4Brm8NpFAve2kKARHWYFY6qI?= =?us-ascii?Q?wNJHznkQYOFvEElBbumqP+GiXXPEgPpdFVai9H9puw3Xsr3r5YrwtXcvvRf6?= =?us-ascii?Q?tibfvoVClxVYP9ZeRvsy+CHDiyhu1z0aLxFTmeEZ+jDXnNfMz6jzfADryVuo?= =?us-ascii?Q?ukpj4Ed/AGKMhB3RrhuQmzW6ZUhndhMtHzLvebGcIc6om+dH9g3dSXnGYa0e?= =?us-ascii?Q?XbI0tNACAYNMysKtoKNI8iE/zrSlEDqOnfa5AyGcgbWzzh0TZv0H2szmvwfe?= =?us-ascii?Q?Fcr/ZHe9fMXzUmYa7FAFO4MPfPWpFh/qWv+RgM5kSq9En3wk6eJHHfEiuWPp?= =?us-ascii?Q?fDBlXBzE7kI0lU3s3BGAbWU8NlNsKg+RfP5iWDQlgEKSAMoKRaPqwBqsnp6A?= =?us-ascii?Q?IUNzWRqdAl3RzEoeiOS3LG2oW0oWUMm6gPnczUedfymQUjm5YhnisevJmhAr?= =?us-ascii?Q?Bhe991l1t6gmNkSgcuaesK08hfzG3Ous7q7ejoEETDf086KNoQoVNZF3DSJk?= =?us-ascii?Q?lTNPX9RUaScdZM2gC7CJNj07H9wmdfIbVqpyhjyHvXvylnVKYk2lWhVtjePk?= =?us-ascii?Q?bTFcWCuNoXHlh6ZOMOWOPnozlXrdFui61hiPiPAK0pOCo0Cd7p2ZnMlwR4rZ?= =?us-ascii?Q?fbEm54ctELPhj61kh2AChQ7nOX/EqcAf5hPu/PxDzUOWYsvaU6lsY+Sj/ggF?= =?us-ascii?Q?77iB5NVcfeU2T1ki60V+UUowWpmFG9IDC8PbC4Pycb7wof1jVvaIBu3R9vhs?= =?us-ascii?Q?olA00LJsiusUw/XXxuXeHHv+hWHRFjGP3VJmkg9JsLghG1A1I7sB+Caq1qNx?= =?us-ascii?Q?O+eoq48b8JRPCOalYalgDGD2fyLcCjCHxj7eC9Jjou/fndBkcPFWKQ8NwGUT?= =?us-ascii?Q?jJo2prn1eNUnnrOOhGbKejXXwaL4vVUuXAYZ4iBv8r7sFWAZuyOmVyvOgcRE?= =?us-ascii?Q?+zy+Ij40cxXDrDQcvXO81TuODUghNPBYCXgxMnfTn0AzxTFM1RNhTfie/tco?= =?us-ascii?Q?rjJjWTKdjFMk93X8l6v3J6/uDRG3N0+KHfH7IOcXf4xCayM8V+NldN3EHa83?= =?us-ascii?Q?kshlpS7NVPTNvaYTSgkzmc77GsQaEyJAYuG8SrUlu46rSQG9xf5236/WL42t?= =?us-ascii?Q?5YS9N9n7y/J0JTrerAyaHD25KGSfpt5OYlUv4qSyeo4DsRrXJqlTAd0YXXGM?= =?us-ascii?Q?TIzkiZqHgi7HBU5suiI8zd7hSqvgaKUZcl3PpwAFj7og9+ku7/bcHhdGLnBL?= X-MS-Exchange-AntiSpam-MessageData-1: xp1tSVrhMWjjqA== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: d1796594-78dc-4920-b071-08dee1950d1c X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2026 10:45:42.0221 (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: GUefYS8E0GG3pCvH1sORiuQQiV1bO8LZH4rXRo2NdAR0ljVmYo5FrmBkNsN+097MqZxkAHa5xPOFvVWB/mE8hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY6P286MB7347 X-purgate-ID: tlsNG-bad1c0/1784025943-BCCCF034-CECA9430/0/0 X-purgate-type: clean X-purgate-size: 9491 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784025967639158500 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 v6: * Set the cluster ID to 0 when the cluster definition is missing from the Device Tree `cpu-map` node. * Added bounds-checking `ASSERT`s for values returned by `cpumask_first(= )`. * Added a blank line between `` and `` header groups. * Reordered `#ifdef` blocks to prioritize generic logic over architectur= e- specific ones. 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 | 65 ++++++++++++++++++++++++++ xen/common/sched/credit2.c | 5 +- xen/common/sysctl.c | 1 + xen/drivers/acpi/topology.c | 3 ++ xen/include/xen/cpu-topology.h | 44 +++++++++++++++++ 9 files changed, 118 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 be82272c14..03cad06303 100644 --- a/xen/common/device-tree/cpu-topology.c +++ b/xen/common/device-tree/cpu-topology.c @@ -316,6 +316,67 @@ static 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); + ASSERT(first_cpu < nr_cpu_ids); + + 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; + } + + first_cpu =3D cpumask_first(topo->cluster_sibling); + if ( first_cpu >=3D nr_cpu_ids ) + { + /* Clustering is not supported */ + topo->phys_cluster_id =3D 0; + } + else + { + 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); + ASSERT(first_cpu < nr_cpu_ids); + + 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); + } +} + int __init dt_init_cpu_topology(void) { unsigned int cpu; @@ -326,9 +387,13 @@ int __init dt_init_cpu_topology(void) =20 ret =3D parse_dt_topology(); if ( ret =3D=3D 0 ) + { for_each_possible_cpu(cpu) setup_siblings_masks(cpu); =20 + setup_cpu_topology_ids(); + } + return ret; } =20 diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index 95946634d1..a69327c808 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 @@ -35,7 +36,9 @@ */ static unsigned int cpu_nr_siblings(unsigned int cpu) { -#ifdef CONFIG_X86 +#if defined(CONFIG_GENERIC_CPU_TOPOLOGY) + return cpu_topology ? cpu_topology[cpu].num_siblings : 1; +#elif defined(CONFIG_X86) return cpu_data[cpu].x86_num_siblings; #else return 1; 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 45d1f2c5be..56fcfa4945 100644 --- a/xen/drivers/acpi/topology.c +++ b/xen/drivers/acpi/topology.c @@ -22,6 +22,9 @@ int __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); cpumask_copy(topo->cluster_sibling, &cpu_possible_map); diff --git a/xen/include/xen/cpu-topology.h b/xen/include/xen/cpu-topology.h index 7cfe3752cd..82608b7789 100644 --- a/xen/include/xen/cpu-topology.h +++ b/xen/include/xen/cpu-topology.h @@ -4,6 +4,17 @@ #define XEN_CPU_TOPOLOGY_H =20 #include +#include + +#include +#include + +/* Assume all CPUs reside in the same socket and no threading. */ +static inline void init_cpu_sibling_map_default(unsigned int cpu) +{ + cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu)); + cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map); +} =20 #ifdef CONFIG_GENERIC_CPU_TOPOLOGY =20 @@ -11,15 +22,48 @@ 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 + init_cpu_sibling_map_default(cpu); +} + +#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 static inline void init_cpu_topology(void) {} =20 +static inline void init_cpu_sibling_map(unsigned int cpu) +{ + init_cpu_sibling_map_default(cpu); +} + +#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:01 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=1784025965; cv=pass; d=zohomail.com; s=zohoarc; b=MQAlMewdbkjGEis2BIuAjhcLA9+0tX3e6AgGiC3IY5B4VY941+v8vwDBbRJaxjearQ8JuAh6sD4VDiY/4lewLnxa0r44yvczgYbnEy/cIXOn7P9AtKkYmqLKMwpOdoUJBRT13rWVewHS0Zw53bVVcu4L1N4rYyslFowUEFVxCwY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784025965; 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=aqRIT0ovWcpKUF4Ojak3jbwqwtoVYmAGHWnTq7kkF1A=; b=c4vzvSQAueOIU+kjrbo00X1no6gQ6PEV2n6M9pfOf9sB3dRYr8WV8My6ar5Vw6mdEziNW3m3r0OuG+motKWQuEMdQ9/vzL5TpttzKrF41v9lpBxpMJ/AYfQ43YXqRLjuz8Oe3vpDyhqMKGkSs9ObOS1e5ak5Qeyx17vU1Jrjwnw= 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 178402596525382.7557876884199; Tue, 14 Jul 2026 03:46:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1362131.1614060 (Exim 4.92) (envelope-from ) id 1wjae9-0006JK-1P; Tue, 14 Jul 2026 10:45:53 +0000 Received: by outflank-mailman (output) from mailman id 1362131.1614060; Tue, 14 Jul 2026 10:45:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjae8-0006JB-U1; Tue, 14 Jul 2026 10:45:52 +0000 Received: by outflank-mailman (input) for mailman id 1362131; Tue, 14 Jul 2026 10:45:51 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjae7-0006HT-33 for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 10:45:51 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wjae6-00HHZm-Fp for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 12:45:50 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a56135b-2eae-0a2a0a5409dd-0a2a4502907a-4 for ; Tue, 14 Jul 2026 12:45:50 +0200 Received: from [40.107.74.120] (helo=OS0P286CU010.outbound.protection.outlook.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a56135c-6ca4-0a2a45020019-286b4a782f33-3 for ; Tue, 14 Jul 2026 12:45:50 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by TY6P286MB7347.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:361::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.20; Tue, 14 Jul 2026 10:45:46 +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.0202.014; Tue, 14 Jul 2026 10:45:46 +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=s9C0P3G8hgjm90Qs9I0cF0+JR3BnJeksvOj40q/e9b41lJ+2ZKULQOWzysy5T9x6Lj2sAmqNKDM8HtxIMy4lYOXFKRIU3qfsbqvDHKvyBiT6sEYufiyBivEY7AoiKSwIaLwlDLLiSO/kBBJ5CJ5pWoabh+Ltfx/1SQz9npZ1lZjRIOdeCJYrNsrGqDgXEUArMetIp2iSjf5a4L4vBCkWoPvSA/5y9pRn9QYO8WU+6aTDwa5wj7LPmLeVL91pFUYqns1REd+DISjq/V7IslBJ38OpBXlUXz6i9Ww5IGEwAx0k88akPuOUtRGbne2Uc3FiHN+pCqGl6iEE2Sq7tF646Q== 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=aqRIT0ovWcpKUF4Ojak3jbwqwtoVYmAGHWnTq7kkF1A=; b=XCMEfh0T4ewItfSbeCOcDtee1BJ1hCQmV4hWg3xE54mARVtxroq1q7qezg++mjJfwFoS2PLgimiePLZ0sMV2k1hDip2vDI/S25UeSWiJ+ht6O0YOnxHfOCfhEksjT0JRu+855g6WzKTrOozLri8bMeSVYSF9fh2lBrN7zjpdbj2KyunL1kGDi7tRhm4vJ1HipH/UlOKt2ihEU9omu6W/cYvXWQxPWOph3Dwe2PG+U744hk1DhhwHVfAHY/OfGnugAJ2/rmRpUYMXvC1C7J8eDGLMegP3/iKH18CwqaFmuOMdymfBE8eZxaex4463s/vZCT7+tHNPLmTJmP+J9fcpRg== 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=aqRIT0ovWcpKUF4Ojak3jbwqwtoVYmAGHWnTq7kkF1A=; b=tw0RCRCFQUtvIAi8UXz2h9ML/gEFyIE6r/vxr+ioIA49uOsclVcIRtXIk6tvfx+aJJzjl2SqmTb5WQGOe6dsPV/YxCgNR9/lw2/m9kODbmry7pqs8TGVDhzYb1YdkFSzXt40DMENH3Xx4WBKqoh4HCKHXggAE+hJvVJ8Smt0v0k= 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 v6 3/5] xen/sched: Make cpu_nr_siblings() architecture-specific Date: Tue, 14 Jul 2026 19:44:43 +0900 Message-ID: <20260714104445.919830-4-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260714104445.919830-1-taka@valinux.co.jp> References: <20260714104445.919830-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYCP301CA0062.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:7d::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_|TY6P286MB7347:EE_ X-MS-Office365-Filtering-Correlation-Id: 277a1cb6-ca33-419c-3e83-08dee1950fa4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|376014|7416014|10070799003|18002099003|22082099003|56012099006; X-Microsoft-Antispam-Message-Info: ORyZ/x+pkgqvRPBHX/qWLeCIeJhpOkLDOPduWxlVpOBsJ2VGPD+xrGmeeQw+zTMT5ifB+8KkZxl2MZDaokbsYor4U9sPeXCp8KK/AUQipCuA3nrf+BRew/PSwPUd9OxZRpoDFFdy7Vf/k4sJqYzoBNj0Erx83MHTwOhbPWG8mCD+/3Xx1RA93vAzeAlvYIS9ArnooA/7sGW+4z7pLBqINmTf/nr6kQ+ft9RhrqVs+2Ojf1n09C7jBzXnI1JnY0IGWBUzZzLo5f7kyU4OuXbNU6bZLVqmu0KRARJtJZX3BRshWeNydEddCck+xXnnycpyjagJpEqwJM8JXhLN2Phf6NW2ZZGaVtIonVbc+qDBt//gryhNGMofioxcDJqmCkRT3nhF7ItIc+vFKBBEz53ACV2HRhRLoWbIZU1XoJ08kpY6ZKTZ9oZuulf2HnCwNp/lujmhA9P7z6TGL9YPHRGJSu7P72QqKTlRkxSbUfPuxYym07NRcpXF2tbQBIZoJHZ6Xqi3KnmZuIVFEQJ1h6rmxbgzroM7KpEl4QierEHyzqsJNo7st5dqG9Qk6dJzM/vavLUKjAbfsatHboKZNlwTeCQOpVSifOXiqildxBCvnMqsNMv41fcFC1PTgdAcQkzNc3kxqmygFCBVER3axXpNnPEiB6hfhWQQhMDZz6XXd+c= 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)(23010399003)(1800799024)(376014)(7416014)(10070799003)(18002099003)(22082099003)(56012099006);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lUtWFxNF8oIUjJ7ypPa6clBg8vzPK9E6ilJlqjt0AGE/nL0eLVB4FZhP0Oa0?= =?us-ascii?Q?tQzC6GH7rsccqZrb9qbGv6RE017pHNnM1tqiVhne5AxYeteXzh7kY4WLRsrK?= =?us-ascii?Q?Rutlz+TMekUFAyjOQyqH0ijwgJ7Qu8uSQIaBL32e2qLutOzcKS7h6jszKZys?= =?us-ascii?Q?+zGUnyGZyd/8Aybl3slhvjFtKzIpWR+dsm5HH7115TtmgRCqREvCGLlny2so?= =?us-ascii?Q?/HLGL0QbBM5lJYUsvvU7yMrArK7gWCUBuztLv4CBGOcVmHdxYVMtpF5EDGoh?= =?us-ascii?Q?m2/8Ai6pGVwoREzeDr0O7nAFiOqLSTKVMpzEQLkLIusrMMfLoiaeP6iFJ56G?= =?us-ascii?Q?b4FwMRvJWbzCsRuQZdCcYyBDp5mM//75XSX6Oa56+xzXUN7/2yOkSKsfA2Q6?= =?us-ascii?Q?L91sFbcAcFiWhtyyJNgU+Wu0DjbgYhknnvf7b9sDHFf6U2XDkv7T5vwmTvii?= =?us-ascii?Q?KALoRnFLViPK54GcD1mAcOQ6HktiDAzPW+CbCp6n/M2/nIiO7Ey+2qTrdT6H?= =?us-ascii?Q?TmcQ2A1ZaIfYYVYByqo0MmfelpTmO38jFGAlzMYbZ0DPYQZr2OhdBmZ/JP5b?= =?us-ascii?Q?HTTDX/YxXpqFH9VC3DQJCKd4UiQbH0U8qjCvBeQQdqeEd8n4Yujs9XDfrTUp?= =?us-ascii?Q?MXqI8g4hiwNiDDG/ucrX4/dh7oq1YVsZYbIuxBh2rmYb9GFQHLkwEFGKr1XX?= =?us-ascii?Q?W10htWrg4LEuZXYwr7NGcfrLNKTuXKqldV8+69DXQGl4vfPA9dOT8uAuLXD6?= =?us-ascii?Q?/BbTYy9gIRdxg5xDk0HeTWaT65wOIefEBo2OCTta/XrGyKe7FdVEMiTELMz7?= =?us-ascii?Q?nM7aqr1TH5NBpzLhB4aEsOhf0WF+/bprm67C7Sqw/Gl+7pSnS0Ys3D/kdxLA?= =?us-ascii?Q?2Ybk90lILCBp3sjS7FbSIil8ZYyT6q7+Noef+OkuILXO8v1NIRO3WxtE6pUH?= =?us-ascii?Q?KLPNoOGa4sJdiBmZiRLmXu4tz6IRjnTKEy+EO5oVffvLKjWgcz+lmtiGvGR5?= =?us-ascii?Q?VkmPTaDK04cTp8eI+pOi2jdbos5iVHJ3CFI1hKJdfGWxhkv3iaaK6UuZFp2Y?= =?us-ascii?Q?D/MoxGugcEB7x15I13kPNK99+iSB3pQOFPuglBHUFnGYKMHue6VZuJ583fj5?= =?us-ascii?Q?3NEcpjeLp6stZwsz3egQvrYn/wLLL2xy07oyzuDEHToq6yG8JJO1g7lLtk4n?= =?us-ascii?Q?JT8fijlbA5YzofvmIYH2MGSqTQez8pIm4LG51BqcicZfYJcbKnJXqyMj1gX8?= =?us-ascii?Q?X68IK5pwbzJnjuCf7rebha45SV6DY2AYRUW046vqb6eRGEQOPnTJ8WvavCDn?= =?us-ascii?Q?3sODVPylC0fNF18iDFLDROyv7U3FvN5UQMXHCrq32HmUw1yuo+JpCjB6YZUr?= =?us-ascii?Q?fzQsBHfDavE1ydkKhhxJe/C6PTcK5Dck1MqL003yB7pnfnJbh/tYVsltLRSu?= =?us-ascii?Q?uoKajQOvOfhKK4YRehLPbeRYKMQmEF+oVhpmZVeO4VgbkkUApD/wcLe+EAlF?= =?us-ascii?Q?z4WtQkPwURA7rGIQU04z3f60yGQxyfKEaUedW7yVsjiWbiClcJeMK+0iFkgN?= =?us-ascii?Q?6AfrXFIijTrznMX8+YI/MyHgAtAOBwdPf3IL1VTkOdWLPHmwySv+Nry/Xo5O?= =?us-ascii?Q?YTRYV7oztNOnUInoIpHHSkB4fI05c74KNIq41hFn/OZW4HiWqLpzJ3RXNSfm?= =?us-ascii?Q?SRlKGspw7wQcg2CuR94DU33H6RgwaEUIggL9LlU3KikMuE7Hk5EN+73ccjEI?= =?us-ascii?Q?nouI4RcOozMx9+jOyPUq9nZz/1Y4KbgvLB72BELzwPJsNYXn7bvys9nvHAiC?= X-MS-Exchange-AntiSpam-MessageData-1: 5kRIWTpL4TU5nw== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 277a1cb6-ca33-419c-3e83-08dee1950fa4 X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2026 10:45:46.2585 (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: 1I4fFc8juALGETbMm8onk7TUY9xvGRJdK1os6xESdoNTH+LWMxjoHRAL/I2wybJyhFTIYBwlzt/6yk8gn819qQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY6P286MB7347 X-purgate-ID: tlsNG-720697/1784025950-F1CAA2AC-AD3C4902/0/0 X-purgate-type: clean X-purgate-size: 3400 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784025965677158500 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 a69327c808..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) -{ -#if defined(CONFIG_GENERIC_CPU_TOPOLOGY) - return cpu_topology ? cpu_topology[cpu].num_siblings : 1; -#elif defined(CONFIG_X86) - return cpu_data[cpu].x86_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 82608b7789..8c653a1582 100644 --- a/xen/include/xen/cpu-topology.h +++ b/xen/include/xen/cpu-topology.h @@ -46,6 +46,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:01 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=1784025993; cv=pass; d=zohomail.com; s=zohoarc; b=CwDMhqOQfJ5S++mwpS/hwR/IqwpYKeGBJqTyRofwXGehNxV2rE2wnbyTplr55z5HWKAbmCTI+mRdeTKK0sBzCmF2srzxTX2DuFEsJ4SGqgf2nJ/oJFe4+o70KlLIBIp4KmTwMuyM2V1fDFQG7om8SsShAWz3iEv0WUb/BGi8o3w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784025993; 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=Y1Oex6Jp2bEa6wsCxPupOWjWoJICYxBHDdDfwmwaE6g=; b=XFDJi5brFdTASZVFeoUc4DO7BMWCrazRGMzAfAJ0QPF3tWzNuHE5jpMO7T+eQ0g3MSx+Edz63X4jApMLTO5ZyoZJ25zUct5bOKaPruCAOJKS5/oWAU6+ocjepsI2zsBOyNMmGyQ0ISqMjAsMLptHdevp02mzP6/IGeHgo5/5j0A= 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 1784025993907444.8347032122233; Tue, 14 Jul 2026 03:46:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1362151.1614070 (Exim 4.92) (envelope-from ) id 1wjaeT-0007AY-EL; Tue, 14 Jul 2026 10:46:13 +0000 Received: by outflank-mailman (output) from mailman id 1362151.1614070; Tue, 14 Jul 2026 10:46:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjaeT-0007AQ-A8; Tue, 14 Jul 2026 10:46:13 +0000 Received: by outflank-mailman (input) for mailman id 1362151; Tue, 14 Jul 2026 10:46:12 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjaeS-000766-6D for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 10:46:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wjaeR-009uid-J2 for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 12:46:11 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a561370-2eae-0a2a0a5409dd-0a2a4501e9c4-12 for ; Tue, 14 Jul 2026 12:46:11 +0200 Received: from [52.101.125.121] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a561370-5984-0a2a45010019-34657d792ce5-3 for ; Tue, 14 Jul 2026 12:46:10 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by TY6P286MB7347.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:361::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.20; Tue, 14 Jul 2026 10:46:06 +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.0202.014; Tue, 14 Jul 2026 10:46:06 +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=t8Ef3FD9pWRN0ERT84tbwVLPGPcp+pu0fDfFIJUl8Pvt4xiX5/P+R0p7ysV4yDoSvaC+eFSaKog3bQzXaHqaxuZ/kRJzm3NAGYPSzW7kL5u3TiWWBV3tdo/eby5XVaYZ+e7mkQP77+Jh3eo8Lqf+aJn6IsRD28w18Uq5nCmhnRsru46N9RW92b7HpNAmss79QY5WJe7xZp/NBdB5CLDn0Ud908BaOV8z3J3lTnG0pkEkE0AXsPJQSP9ApndmpNnqm/cO6VUj+OiLN7DWa5kCNyoRx8KDpXuy2q4lL+uyqf6Fx1JcTotePfxrQfTo7klUKwuRmzVGcC/7E2yEWmPPug== 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=Y1Oex6Jp2bEa6wsCxPupOWjWoJICYxBHDdDfwmwaE6g=; b=yTC2uQPs94XWNoLaIC44xaB66FGvU1hQcbe+OPiDOClzcpzSHAx3LKT7MhuGe0SYdgA5MnWq9Ofet0VtWMnHicR7f6mPUAAMb13z+43knT+C9hkymn7rOpCx9rRyw3iPqyGZdEIrKFAk5FEAZgAwESe5nbqwqWjCqrPvMQmA7Xgn73IkBovdZ2br2SHLX6avC/rAB31qTXam/V4bwyRvp99vYgSZF4yPEZ7bbFkhefPnjKLisajZhcsj0UohVoWpXmpvBo85YjX3aS7n3A/p5Lp/EXMFUxF35Bd6iprqln1FWb/yUpW6hnH4FIKVXYNuwYv+Zczwbl6DtFDq3oVN5Q== 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=Y1Oex6Jp2bEa6wsCxPupOWjWoJICYxBHDdDfwmwaE6g=; b=dtoOIwa3PkftxVGwpFPLWyyA+24ye0SAlKwV1yvM2lipFs68sG7/PVeIgilTgiFBheWJfawbB9FSfoFIl7UkgBkeK1RZOA5svERKLHvqizcBuC1Ghiwc+PfEjk6EwdTof7YJMj0BX5p+xyxL2nEg5i2Dv7/7EziPE3PQp3bWjEA= 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 Subject: [PATCH v6 4/5] xen/acpi: Import PPTT definitions from Linux Date: Tue, 14 Jul 2026 19:44:44 +0900 Message-ID: <20260714104445.919830-5-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260714104445.919830-1-taka@valinux.co.jp> References: <20260714104445.919830-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYCP286CA0321.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3b7::14) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|TY6P286MB7347:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ffacc93-b212-4e0b-533e-08dee1951bc0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|376014|10070799003|18002099003|22082099003|56012099006|3023799007|6133799003; X-Microsoft-Antispam-Message-Info: 0zwsD2pXdiR7YW1mAo7bqCVZtrKLTcADMSO1H2AYVpLozNsyIVJHbW8b8W4JSwuHmqxLX8lxfB+/8p1RlP587c3yw5F+a2bgx2o3TWcZ38WDvNwFdC1a+zbtiajN7ImalxwPawBI4dXHGCodqYrBLRezhlUd8YJyxvyYY/NK0GJt4ZMfvKYKC49eGo/0WQgV0YJ4DZB8C0tgix+LuHSaVTqzlSZ38Bcj+AY+mmjKMHrNqfeBWsHILoxMs4zmUcCfzcKX3FtI3TKyKFJ0MyO8a8cpHsWRxzimQ5fQWx3c/QKOL/jRcfNVqIgqpZ/KJnAJmfc0K2ADCcABcvcxVonBPKq2HDPg3bugdUUiOiz4JMaPoE86abyF4/Z1MhFDCMRiVygT8hctA+ZV8hh/o8ASVPLEb+iwyoMZVWiHRi1uFWVK3xcj5Bjtfrsd2Ha9eYlsy3kyf5JIJEhQN0x+etUuSge5LIFO32nR9ntackcDZvbcAC3x6xuNeEuknJZ4WQVhk0necRHLKCo0xAMy5c2VXbYXasScvZoR2utVut4OXPZtVcwnxjIyqjDKuxKY+X2dIiyoTtxAbzwpWRvawYO1YudH4mhyNPju/vNbFApnvvE06oVy1PVM8BOY+IJ/uuFHwIqlQtmb83wuBXoS+2DA0bIHfF64El31q062dkDVfvM= 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)(23010399003)(1800799024)(376014)(10070799003)(18002099003)(22082099003)(56012099006)(3023799007)(6133799003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?A662HdYSgjRZej7vh/5BIbK9aoAhcdeRu11j6E/KsIbT+IHq9ND3nav7rpD3?= =?us-ascii?Q?nCpyethdapQOwbTDwHKSq2jsBOEwF7r3jTWzTr7az2bl6JyUT2gj71F/HsGu?= =?us-ascii?Q?EhoosDA+HTiyVkiBEVrwvOmPT1YMmg0WZUjsiO06KoE/GtQ0+PWYox2BEacn?= =?us-ascii?Q?SEoUTPc6D95X5RlZ/UWynkFplJ+guHn+vQQJYWvTQWi3uhDZ9wrpiOiMAKM9?= =?us-ascii?Q?wrkiLE0TiapUiFQ4FqoLBiOOememkeDfYFTHDNRQhk8eDsWXDaBYqhcpq2Ix?= =?us-ascii?Q?Xmi+YqpFTzMHmlXsRllKrxGL14ElGQLuVwDW3mhjmxBdaP1zlHi1eH3MVpK6?= =?us-ascii?Q?ShiB0BoFOHXJSpwzmFOmQBC2ogIjIP5UxaLTwZ79EwKuRi8RFDAjZHd1xFjx?= =?us-ascii?Q?KZIBXjTylRm7fwEESNB38Lk3sHU5ZnnbUkhZ7HSejR5HP4POG7ks4Znl8eOe?= =?us-ascii?Q?q2YeaQpbaMfSPpHN3wvsRIXaNNnEbVMyeC+NtocuZ+z/N9FmwN6dzBVkCJt6?= =?us-ascii?Q?uaxmV8bzELVGzhjJT9Rb6L5TKCJ3++w3It73rVtak5gZRhsyc9yIzb/Ni2mu?= =?us-ascii?Q?fsWPO3bGgQgn7K1wIHfwI4mquCE0UtKhjpv+KvUrgAEQtIzynlbgZElzCX2b?= =?us-ascii?Q?Q1+HSxE7gfppbXQmR44FuGEO8QnL5JmOzTX6fuSkX/FHFUoZFCmhYSbOEQMJ?= =?us-ascii?Q?FeHk+fZhVXfYWHh1BUeV00b6Al2HNXTSfQPXckBc0O1zoBabuA0v/WR0GncZ?= =?us-ascii?Q?jDwSBxHHc3tkEqC51ZEF21eKSRwPSsfqH8g71X3gLqSUkZQoeDnUe7P/E/WL?= =?us-ascii?Q?XOAmrmolnfjLNonhkogFC+2CjDKkYuXKO+xBwBp/N6vDtjwRRBTx9Z+YwiB8?= =?us-ascii?Q?sLhKlhVx1JLZGguwwFxCI3TNOfulfhRlR2bZoAjaMJkWnpxL+JxSniHZGLJ8?= =?us-ascii?Q?J0A+KR05YY2kZub0gZWTnGedmZg2/SohY9EeYgoHXHTKLJfUYPJ7Q1g+CAOo?= =?us-ascii?Q?b91HkjXbJIV5VYsXxkH3lErETIvXE0Zzz3xCeDR8ZZnAHPI/0PfiRBbfHG13?= =?us-ascii?Q?eS9r8dUcoSB5Jj7lXiAgs34nfk390ZMZ61Kmu1bUCi5NKCwLcmA9bwKMucYx?= =?us-ascii?Q?bRWVxvM/kasFFFXiQehz0Lc5c7ju2ajSOV6i0wtVm+OWdFfhZ93KhoRy2k34?= =?us-ascii?Q?auvjj0skdeje/ImoOIzAmddef8HQD1NBfGVcwCPKEwESQODz43xa0273KbbH?= =?us-ascii?Q?/8N+58z6DaENuN9GIn73WfnxYc3qz1VgwBN1GOmLhkTyiqXaJg1kiKTU21Wh?= =?us-ascii?Q?9F/pIPGVQa6XJMAsghJKupJ5A6cObFU9MLbpmF3sIdwIeqie8xy111S5R+Js?= =?us-ascii?Q?mr5bzq++tXzo6TkgogCCfwq1Xb8lgKYcIU2lPbco6IGE8EqYeULWD/ffo066?= =?us-ascii?Q?tvZDJjGDF1rjecimxAmzlKiGSX1JsijSi45M1nBpvinaQ0Bo4+5NKrQk/7IW?= =?us-ascii?Q?gOZ0z+L5j3v+gAH00Ki3BDhEtuhOr9QhIMVToCww/RJqJtTNZIGIPgJfDchm?= =?us-ascii?Q?OjvU0EQ2cQkbQ9NZA8j+3XMOSKeWZ2azpF7slvmOaZ+S+UJHsZDNPrsZf42W?= =?us-ascii?Q?8N6b+bUksPG22v65PAornRZaku7GzkhgCJ+/mwdNMfTOOQy5ghiTPxsnYEfs?= =?us-ascii?Q?82zKN8q3CtqS+YkxAkeqo77sTbojYw1lNtyuagRswMKadlHh1joVcmB/CXli?= =?us-ascii?Q?Qn9LdofOiNAexP9lQ2oiT7K1rX9/Msnbjxzo4EZylch2PSm1hQ7dBq1rbgcb?= X-MS-Exchange-AntiSpam-MessageData-1: fwG1NlQQUUbllw== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 9ffacc93-b212-4e0b-533e-08dee1951bc0 X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2026 10:46:06.5794 (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: j7usOsSE5IwirrrBqMxw4WjGQAQshAV5JyIZZLd4xFdRfOrV7Rq0r5IbCLDBu7hOUerWFKwj5y5lrnr3Fr6KtA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY6P286MB7347 X-purgate-ID: tlsNG-d62444/1784025970-1D47D757-5AD2A1A5/0/0 X-purgate-type: clean X-purgate-size: 5269 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784025995807158500 Content-Type: text/plain; charset="utf-8" Import the Processor Properties Topology Table (PPTT) definitions from the Linux kernel header (include/acpi/actbl2.h) into Xen. Origin: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.g= it 091c4af3562d Signed-off-by: Hirokazu Takahashi Acked-by: Jan Beulich --- Changes in v6: * Split out the import of ACPI PPTT definitions from the Linux kernel (including unused definitions) into a separate standalone patch. xen/include/acpi/actbl2.h | 113 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h index ee96e990d6..4398d98e00 100644 --- a/xen/include/acpi/actbl2.h +++ b/xen/include/acpi/actbl2.h @@ -72,6 +72,7 @@ #define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Str= ucture */ #define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration = table */ #define ACPI_SIG_MCHI "MCHI" /* Management Controller Host Inter= face table */ +#define ACPI_SIG_PPTT "PPTT" /* Processor Properties Topology Ta= ble */ #define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description T= able */ #define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection = table */ #define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Inter= face table */ @@ -937,6 +938,118 @@ struct acpi_table_mchi { u8 pci_function; }; =20 +/*************************************************************************= ****** + * + * PPTT - Processor Properties Topology Table (ACPI 6.2) + * Version 1 + * + *************************************************************************= *****/ + +struct acpi_table_pptt { + struct acpi_table_header header; /* Common ACPI table header */ +}; + +/* Values for Type field above */ + +enum acpi_pptt_type { + ACPI_PPTT_TYPE_PROCESSOR =3D 0, + ACPI_PPTT_TYPE_CACHE =3D 1, + ACPI_PPTT_TYPE_ID =3D 2, + ACPI_PPTT_TYPE_RESERVED =3D 3 +}; + +/* 0: Processor Hierarchy Node Structure */ + +struct acpi_pptt_processor { + struct acpi_subtable_header header; + u16 reserved; + u32 flags; + u32 parent; + u32 acpi_processor_id; + u32 number_of_priv_resources; +}; + +/* Flags */ + +#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 */ + +/* 1: Cache Type Structure */ + +struct acpi_pptt_cache { + struct acpi_subtable_header header; + u16 reserved; + u32 flags; + u32 next_level_of_cache; + u32 size; + u32 number_of_sets; + u8 associativity; + u8 attributes; + u16 line_size; +}; + +/* 1: Cache Type Structure for PPTT version 3 */ + +struct acpi_pptt_cache_v1 { + struct acpi_subtable_header header; + u16 reserved; + u32 flags; + u32 next_level_of_cache; + u32 size; + u32 number_of_sets; + u8 associativity; + u8 attributes; + u16 line_size; + u32 cache_id; +}; + +/* Flags */ + +#define ACPI_PPTT_SIZE_PROPERTY_VALID (1) /* Physical property valid= */ +#define ACPI_PPTT_NUMBER_OF_SETS_VALID (1<<1) /* Number of sets valid= */ +#define ACPI_PPTT_ASSOCIATIVITY_VALID (1<<2) /* Associativity valid = */ +#define ACPI_PPTT_ALLOCATION_TYPE_VALID (1<<3) /* Allocation type vali= d */ +#define ACPI_PPTT_CACHE_TYPE_VALID (1<<4) /* Cache type valid */ +#define ACPI_PPTT_WRITE_POLICY_VALID (1<<5) /* Write policy valid */ +#define ACPI_PPTT_LINE_SIZE_VALID (1<<6) /* Line size valid */ +#define ACPI_PPTT_CACHE_ID_VALID (1<<7) /* Cache ID valid */ + +/* Masks for Attributes */ + +#define ACPI_PPTT_MASK_ALLOCATION_TYPE (0x03) /* Allocation type */ +#define ACPI_PPTT_MASK_CACHE_TYPE (0x0C) /* Cache type */ +#define ACPI_PPTT_MASK_WRITE_POLICY (0x10) /* Write policy */ + +/* Attributes describing cache */ +#define ACPI_PPTT_CACHE_READ_ALLOCATE (0x0) /* Cache line is allocat= ed on read */ +#define ACPI_PPTT_CACHE_WRITE_ALLOCATE (0x01) /* Cache line is alloca= ted on write */ +#define ACPI_PPTT_CACHE_RW_ALLOCATE (0x02) /* Cache line is alloca= ted on read and write */ +#define ACPI_PPTT_CACHE_RW_ALLOCATE_ALT (0x03) /* Alternate representa= tion of above */ + +#define ACPI_PPTT_CACHE_TYPE_DATA (0x0) /* Data cache */ +#define ACPI_PPTT_CACHE_TYPE_INSTR (1<<2) /* Instruction cache */ +#define ACPI_PPTT_CACHE_TYPE_UNIFIED (2<<2) /* Unified I & D cache = */ +#define ACPI_PPTT_CACHE_TYPE_UNIFIED_ALT (3<<2) /* Alternate representa= tion of above */ + +#define ACPI_PPTT_CACHE_POLICY_WB (0x0) /* Cache is write back */ +#define ACPI_PPTT_CACHE_POLICY_WT (1<<4) /* Cache is write throu= gh */ + +/* 2: ID Structure */ + +struct acpi_pptt_id { + struct acpi_subtable_header header; + u16 reserved; + u32 vendor_id; + u64 level1_id; + u64 level2_id; + u16 major_rev; + u16 minor_rev; + u16 spin_rev; +}; + /*************************************************************************= ****** * * SLIC - Software Licensing Description Table --=20 2.43.0 From nobody Thu Jul 23 21:17:01 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=1784025988; cv=pass; d=zohomail.com; s=zohoarc; b=WiQ/xx4IN/d0zp9jPRbJyipu/VLSLFkK55s6AZiEQc8fq7fvrMpEu03SWqxzWsvQwZ3wff0fgrUgK6pP0XoMZvnsXZ9mOyt994Klto6mLODe4XF+acQPyphS4E1+HuKGP4yV7f2NF8ZI5cDzA3846n7Lgvis6q0rFZdoFYMjEFk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784025988; 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=1FGPjsAtuJGsBWUU2sdzagAfn9WNOxXnDMlbchoHAy8=; b=V8/Gfelyb9DSKFgINZcgOi8WnaN4NR7anIg7Mvoi6KwEpgtV/S23WXljzK8X+xRqq9yoDWfN9sTwExztuaPOfHLzLpp0Dyote0fUWC09p7REScLnrvvYpzKT/r9AF1vjNPdu36md1Q/xddLO13x9Ixr6uogZhZUktOe2afTGQeQ= 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 1784025988661509.4595709497554; Tue, 14 Jul 2026 03:46:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1362154.1614079 (Exim 4.92) (envelope-from ) id 1wjaeU-0007Ot-OG; Tue, 14 Jul 2026 10:46:14 +0000 Received: by outflank-mailman (output) from mailman id 1362154.1614079; Tue, 14 Jul 2026 10:46:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjaeU-0007O0-IB; Tue, 14 Jul 2026 10:46:14 +0000 Received: by outflank-mailman (input) for mailman id 1362154; Tue, 14 Jul 2026 10:46:13 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wjaeT-000799-76 for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 10:46:13 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wjaeS-009uid-Jq for xen-devel@lists.xenproject.org; Tue, 14 Jul 2026 12:46:12 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a561370-2eae-0a2a0a5409dd-0a2a4501e9c4-14 for ; Tue, 14 Jul 2026 12:46:12 +0200 Received: from [52.101.125.121] (helo=TYVP286CU001.outbound.protection.outlook.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a561370-5984-0a2a45010019-34657d792ce5-4 for ; Tue, 14 Jul 2026 12:46:12 +0200 Received: from OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) by TY6P286MB7347.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:361::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.20; Tue, 14 Jul 2026 10:46:09 +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.0202.014; Tue, 14 Jul 2026 10:46:09 +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=Lm8jXPF7LAsNnD1MC0CUDvBQygWlqHVVY4+YADMwg0SdJhEuIDzCGol5Yc4zrheJAG1o865hcOLsIkZAtX/DPZNIr664dLvmMGXkIN7MCK4RSvJDzbPo6P5OPAxO6O3zQ/C87p+CpdEHPdwvUXYdFuoKVOWNcGS9DKkIBOy0ldhCvhq4kfre0HShhxSnUbX22Z/za2zeipS6Y0ID2q6scRTCuJNFVHLShQxy6vQmZ1TZIngOzHLCdIOSDTeGIvHfJZXtCuJLGeHM0qBEnjiPDoetvaNZCMHqXBXNmJXVP5pfg/kWkWOIBKJJ66lqwNepPi0cknNRvjWDzcKRrbJvVA== 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=1FGPjsAtuJGsBWUU2sdzagAfn9WNOxXnDMlbchoHAy8=; b=yU/DESxeSRzQV8dDsMCRNh2gSDtedGdLD4O0+saHmq3PWLJ9jAL1Hhw//1IJ2U87WLGIY+a3HY5u4hXw7TkW3iKFEMBtL4FH/8qEscxaWrXDAMTBFCsYHvFv7H+angBKuFJO6PyaE1RPh2r0JtyD95ceB71QNfTULCAqvGvmZjKZZAOlD9Xivvn3wdoTLA85ZgND9IzylRmzJsSjiVWs17OZTJhj1S6/y4IYLoyMioaL+wgqb1OX2NvjNPxq/o9EgwiUvH6GqKG4q87DYKJpFTUxxpysxdhQU4HZFma0pf1TsAOzPhfti0xydYN/T9frbr2hgsJY3VAW0to/npqNAQ== 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=1FGPjsAtuJGsBWUU2sdzagAfn9WNOxXnDMlbchoHAy8=; b=B0cp9drrh5r7EqhfB5baTLD2aI8VpZC24U7OQB5aL+6EEwOi+STrRrVH/G3kOga1rnnqAb25czpZxfxnV5ApqYZhgRJFau9YFfCKhoT0HEIT+SSGNNXA+Ryj25LdvxgkrN6CZujVnxh9PTcykL9sJCjDUdOhRPJYG435VYdUzlE= 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 v6 5/5] xen/acpi: Parse PPTT to initialize CPU topology Date: Tue, 14 Jul 2026 19:44:45 +0900 Message-ID: <20260714104445.919830-6-taka@valinux.co.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260714104445.919830-1-taka@valinux.co.jp> References: <20260714104445.919830-1-taka@valinux.co.jp> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYCP286CA0325.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3b7::8) To OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:458::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS9P286MB7222:EE_|TY6P286MB7347:EE_ X-MS-Office365-Filtering-Correlation-Id: dd2cba72-2b26-448a-7a9c-08dee1951d4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|1800799024|376014|7416014|10070799003|18002099003|22082099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: W+hwTxp/Yp0hthsQoc8C/9Zr2SMMf2m6eync4c78YXCSbcZ3mLDFi02glrIIr+kEv0uezFl4KdCl7ULdWeQ5WzJZPyB+Z65VqnqIx5av8iuFb5p/xR/9Cc8Q8LJ+4Tv7g5ctllD3+70UIcPk4s+u59B4WzRNfvyqJvnFRMtiWquP9mb8NMVY9qQ5TBQXYaQTxbupkviagtKWrV3bVz5qdm/WgRTxxnvVPUcH8CtjSqZWDzPF2M/qZLd/BWD0jTGzY734uPl/UgII+LRbVpFdtYyDfJLLVFoCSpR7Ekutf/dC3A0/Ge9nz11NNZ1J5woxz7zoVcGjyNh47yoAY4BI+r1Ty/5oAg/2zktU7q7fh8iJRw+Roa1KpHaeNuIfbPKpeFtrqVyKlSoVKC9Ho0Z7tXr9pVkujzvvWLoCgKS6dNyJVBHiUnvdozJ0wqTq+Tr6R2ArZxd78+5YqhkLvSA+lP7+WkktiC5TqczscbDegPawZ1yF48/AkLneP1NOi5v1OB99tei1zsRY2uORhHn0enWti/WtRZrzswwEMgLLhS450K4EFkRdAsyYQ9bEWAlwUzhwMpRlcTeAhb9cJLJI8TXq60hdK2Sjy6lSddHyw4W8JFAjlOHeL/m2aXsEIZaz6yddaW8+WZd0Dr06xF1kyaMTQTfI2EcaSuvpeU4roQc= 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)(23010399003)(1800799024)(376014)(7416014)(10070799003)(18002099003)(22082099003)(56012099006)(6133799003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ycSqhgwFfRq316KzM8TGapYAfQRvrLfh4DjO+hwLKHDE0WQePIE79TTKEDIA?= =?us-ascii?Q?mhAuL+NS7AFWPSti62Y2lNAbFVpZTtksJfBmHd1hHhE5b1SlDcg0Z4AFQnsk?= =?us-ascii?Q?YoOvQ2aY0G4+aqj95q7Gv9kfF1ZaHmkMt8XshkVwzVp0OEZNHwvbqS47GwuZ?= =?us-ascii?Q?XYG2wU1R0d4IMS2Ixw1QLTDAmOe/ouEDhIWoqC6B+80DIB+QvIvPMVwxNtPX?= =?us-ascii?Q?xHGZ7RdZ+4ZzE+WXLAWtWRC8vbliU6YGMlbkWAyCXc/ggfhKQv1Ui35MZ4t2?= =?us-ascii?Q?h2nQzv321a1NbZllq9H8nLmFcl3MFDH9s2s8Vy85GX+YLxDuZKhGTnJ6KfYk?= =?us-ascii?Q?MPxhunoaOA+TRe5LZlUcRoXWOykNkbi35gZSNQWvJIbbDZRGdAC6T9UZV9Qu?= =?us-ascii?Q?gX9YcPixvDCDHwXwClRvb7FC76bXADeaQJkXrWMLJpk59X6JJE9hPKyVM4Sj?= =?us-ascii?Q?RhI8Us84hSvnoTMw49tRNKj5zU3WXCXOplUGlmHNP6e5katRQKMIJlSCpM/t?= =?us-ascii?Q?R2Iqgix+HfG9wj5ikG2XRS4VFYQaZZJPe+m2OTztGvBi+2cvwUUtURV2yit4?= =?us-ascii?Q?fJVnRjwK+SeKJwgIiI5rKp879UVHz1wzScCDhfBZZx1Ndkh9Hi3djvQrWQpx?= =?us-ascii?Q?A6W1lL6IhQ68USpo9Iy1oGcgpENTfA2+SwY4hpDpG5/kKlxCArtOP2uMiqHt?= =?us-ascii?Q?RlJOWkV2bTYhKF3o/82XKDFzmzhptbw/cF2rSX8sEAunWgync90rSpooC8lg?= =?us-ascii?Q?jW8R0R/wxWMRYYPBQSTaR/tcesmv+Dl6ATFMTYHjgvNJBn6YNO3lHQOQUdtU?= =?us-ascii?Q?CCPDKDw9MtpCu11doDM1ecUywjD0tDsBdRXwXWAlWutn3Jc0jAzpVdSPAgUv?= =?us-ascii?Q?XbN3KydVFGoOjnfx0ZbuODJGHPncGDwRu6zRs8d7cqLQgxOWKmBcCy6XLZLW?= =?us-ascii?Q?aCrZQvlbcBNxscmN1ogiIasVWgVBKyI8zuC3b84TJgGFmZKa1hNcF9FQNYMh?= =?us-ascii?Q?kVlhhrE7cnwBAs3J1yELKAFqeGNpVAbmqAWv04RquW2alrlx4c5lK6zaLokO?= =?us-ascii?Q?ZlD6NEEfmJg+L8146mI057+02ey/8D3dTjDxZh60T1IbLd0nY7kCcHRfub8+?= =?us-ascii?Q?JavqlH7BoXyursnxZ5ctd2TF4fySFGVXT/GjraJTnAmpsESdG0uK3ptB6Ov9?= =?us-ascii?Q?HpLGuoGpWRkheq7jwdIgmHbAH7eSyBFITXO9FuEsrh4FwKFlK2ov+SRQaau5?= =?us-ascii?Q?NuafO7urBHzWg+M8CW8CfJQrXW0wp0U7c1ZGEsj3QnMHH9CGJYYYCFHHvIpU?= =?us-ascii?Q?uvvCqKJoKaajvNTkO0EvxXNCDRUu1koQGGTH0RbiLwtqVDg81dPmP3F8d8uR?= =?us-ascii?Q?YZQi1hBq9ytxHPT2l3h9mw5DzwJdnBoFhJlCElwg5N0JhJFP5ZFYZ03DgZMK?= =?us-ascii?Q?yEDAffF978HJ6G1qqHbJMLB8nDCEhFjiLn0l9WapsdTnt51LSf9QIV/v0rDK?= =?us-ascii?Q?Ebw2DI53iCJMg4JPKyv5lpu6ZGpKfpDwZHCm3JFAcOcuJVu2zfjjUKi0LN59?= =?us-ascii?Q?VfGS4K7fgtARcxY/0mm81juC5IQn8ANCmLxzpddT6qxcmc0hD42d4fAgZhZd?= =?us-ascii?Q?Gow3W/RvJXInFlrJjgMihCMQIdYy/ulhVBbHFFObotmEcDkxWAA7XsGm7aNM?= =?us-ascii?Q?EhP2UCrTFNfLluz6WDcCBSMYuJlg456QNUWqgwOVhA3STMAXqMqvNTnnmYMj?= =?us-ascii?Q?KubV6TjbVKjZgis9uccBkjnQWWs4yI1F2BzJ0ZC4uHbhEBcdu+k0N4ynycl1?= X-MS-Exchange-AntiSpam-MessageData-1: DGYL1lvnjHyx4A== X-OriginatorOrg: valinux.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: dd2cba72-2b26-448a-7a9c-08dee1951d4b X-MS-Exchange-CrossTenant-AuthSource: OS9P286MB7222.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2026 10:46:09.1591 (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: IgNiPIx/JQa9+OMAPM+xs+AfgzBASGI2OHixF2cnbSAzxK1dPL/I76y6QyCg7cIRog5sjAV1IkvDgUDxo772jA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY6P286MB7347 X-purgate-ID: tlsNG-d62444/1784025972-BD146757-B00D8951/0/0 X-purgate-type: clean X-purgate-size: 12747 X-ZohoMail-DKIM: pass (identity @valinux.co.jp) X-ZM-MESSAGEID: 1784025989825158500 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 threading. For ACPI 6.2 and earlier, CPUs are assumed not to support threading. Signed-off-by: Hirokazu Takahashi --- Changes in v6: * Handled cases where cluster info is missing upon reaching a physical package in the PPTT parser by assuming one cluster per socket. * Enforced an upper limit on the PPTT parsing loop iterations to prevent infinite loops on corrupted tables. * Treat the absence of a physical package node definition in PPTT as a parsing error. * Added explicit braces `{}` to nested `if` statements to clarify `else` scoping and maintain style symmetry. * Enforced an upper limit on the PPTT parsing loop iterations to prevent infinite loops on corrupted tables. * Treat the absence of a physical package node definition in PPTT as a parsing error. * Dynamically allocate the temporary data storage used during ACPI PPTT parsing. * Applied the `static` specifier to file-local data structures and funct= ions. * Minimized the use of fixed-width `uint32_t` types, restricting its use= only where strictly required by the 32-bit ACPI ID specification. * Declared `map_cpu_acpiid[]` as static and introduced the helper functi= on `acpi_map_cpu_acpiid()` for managed access. * Renamed local variables to more intuitive names. * Simplified the implementation of `get_logical_id()`. * Refactored PPTT parsing to reduce type casting by using `container_of(= )` and switching from `char *` to `void *` pointers. * Removed redundant error checks. * Cleaned up unused variables and eliminated debug print statements. xen/arch/arm/acpi/boot.c | 2 + xen/arch/arm/include/asm/acpi.h | 2 + xen/drivers/acpi/topology.c | 251 ++++++++++++++++++++++++++++++-- xen/include/xen/acpi.h | 2 + 4 files changed, 244 insertions(+), 13 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 56fcfa4945..e6dea527a6 100644 --- a/xen/drivers/acpi/topology.c +++ b/xen/drivers/acpi/topology.c @@ -5,32 +5,257 @@ #include #include =20 +#define ACPI_PPTT_MAX_LEVELS 16 + +static uint32_t __initdata map_cpu_acpiid[NR_CPUS] =3D { + [0 ... NR_CPUS - 1] =3D INVALID_ACPIID +}; + +/* + * The first argument `cpu` is the logical CPU ID assigned by Xen, + * and the second argument `acpi_id` is passed the `uid` field from + * the ACPI MADT Generic Interrupt subtable. + */ +void __init acpi_map_cpu_acpiid(unsigned int cpu, uint32_t acpi_id) +{ + map_cpu_acpiid[cpu] =3D acpi_id; +} + +static unsigned int __init get_logical_id(unsigned int key, + unsigned int *map, + unsigned int *count) +{ + unsigned int id; + + for ( id =3D 0; id < *count; id++ ) + if ( map[id] =3D=3D key ) + return id; + + map[*count] =3D key; + + return (*count)++; +} + +static const struct acpi_pptt_processor *__init find_pptt_node( + const struct acpi_table_pptt *pptt, uint32_t acpi_id) +{ + const struct acpi_subtable_header *entry; + unsigned long table_end; + const void *ptr; + + BUG_ON(!pptt); + + table_end =3D (unsigned long)pptt + pptt->header.length; + + ptr =3D pptt + 1; + + while ( (unsigned long)ptr + sizeof(struct acpi_subtable_header) + <=3D table_end ) + { + entry =3D 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 && + entry->length >=3D sizeof(struct acpi_pptt_processor) ) + { + const struct acpi_pptt_processor *proc =3D + container_of(entry, const struct acpi_pptt_processor, head= er); + + 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; +} + /* - * TODO: Populate the topology information by scanning the ACPI - * PPTT (Processor Properties Topology Table). + * Populate the topology information by scanning the ACPI PPTT + * (Processor Properties Topology Table). */ int __init acpi_init_cpu_topology(void) { + acpi_status status; + struct acpi_table_header *table_header; + const struct acpi_table_pptt *pptt; + unsigned int num_sockets =3D 0; + unsigned int num_clusters =3D 0; + unsigned int num_cores =3D 0; + unsigned int *socket_map =3D xmalloc_array(unsigned int, nr_cpu_ids); + unsigned int *cluster_map =3D xmalloc_array(unsigned int, nr_cpu_ids); + unsigned int *core_map =3D xmalloc_array(unsigned int, nr_cpu_ids); unsigned int cpu; + int ret =3D 0; + + if ( !socket_map || !cluster_map || !core_map ) + { + printk(XENLOG_ERR + "ACPI: Failed to allocate memory for topology parsing.\n"); + ret =3D -ENOMEM; + goto out; + } + + status =3D acpi_get_table(ACPI_SIG_PPTT, 0, &table_header); + if ( ACPI_FAILURE(status) ) + { + printk(XENLOG_WARNING + "ACPI: PPTT table not found. Topology fallback will be used= .\n"); + ret =3D -ENODEV; + goto out; + } + + pptt =3D container_of(table_header, const struct acpi_table_pptt, head= er); =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. - */ for_each_possible_cpu(cpu) { + uint32_t acpi_id =3D map_cpu_acpiid[cpu]; struct cpu_topology *topo =3D &cpu_topology[cpu]; + const struct acpi_pptt_processor *proc; + unsigned int level; + unsigned int core_group_key =3D 0; + unsigned int cluster_group_key =3D 0; + unsigned int socket_group_key =3D 0; + bool threading =3D false; + + proc =3D find_pptt_node(pptt, acpi_id); + if ( !proc ) + { + printk(XENLOG_WARNING + "ACPI: No PPTT leaf node for CPU %u (ACPI ID 0x%u)\n", + cpu, acpi_id); + ret =3D -ENOENT; + goto out; + } + + /* + * Limit the maximum loop depth to prevent an infinite loop in case + * the PPTT is corrupted or contains cyclic references. + */ + for ( level =3D 0; level < ACPI_PPTT_MAX_LEVELS; level++ ) + { + const unsigned int offset =3D (const void *)proc - (const void= *)pptt; + + if ( proc->flags & ACPI_PPTT_PHYSICAL_PACKAGE ) + { + socket_group_key =3D offset; + + /* + * If cluster/core info is absent upon reaching the physic= al + * package, assume one cluster per socket and one core per + * cluster. + */ + if ( cluster_group_key =3D=3D 0 ) + cluster_group_key =3D socket_group_key; + + if ( core_group_key =3D=3D 0 ) + core_group_key =3D cluster_group_key; + + break; + } + else if ( level =3D=3D 0 ) + { + /* + * ACPI_PPTT_PROCESSOR_IS_THREAD is supported in PPTT + * revision 2 and later. Assume no threading support when + * PPTT revision is 1. + */ + if ( proc->flags & ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD ) + threading =3D true; + else + core_group_key =3D offset; + } + else if ( level =3D=3D 1 ) + { + if ( threading ) + core_group_key =3D offset; + else + cluster_group_key =3D offset; + } + else if ( level =3D=3D 2 && threading ) + { + cluster_group_key =3D offset; + } + + if ( !proc->parent ) + break; =20 - topo->phys_core_id =3D cpu; - topo->num_siblings =3D 1; + proc =3D (const struct acpi_pptt_processor *) + ((const void *)pptt + proc->parent); + } =20 - cpumask_set_cpu(cpu, topo->thread_sibling); - cpumask_copy(topo->core_sibling, &cpu_possible_map); - cpumask_copy(topo->cluster_sibling, &cpu_possible_map); + if ( socket_group_key =3D=3D 0 ) + { + printk(XENLOG_WARNING + "ACPI: Could not reach the physical package node for CP= U %u (ACPI ID 0x%u)\n", + cpu, acpi_id); + ret =3D -ENOENT; + goto out; + } + + topo->phys_socket_id =3D + get_logical_id(socket_group_key, socket_map, &num_sockets); + topo->phys_cluster_id =3D + get_logical_id(cluster_group_key, cluster_map, &num_clusters); + topo->phys_core_id =3D + get_logical_id(core_group_key, core_map, &num_cores); } =20 - return 0; + 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); + } + +out: + xfree(socket_map); + xfree(cluster_map); + xfree(core_map); + + return ret; } =20 /* diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index cbb02e0f35..d2a1531893 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -137,10 +137,12 @@ static inline int acpi_boot_table_init(void) =20 #ifdef CONFIG_ACPI_CPU_TOPOLOGY =20 +void acpi_map_cpu_acpiid(unsigned int cpu, uint32_t acpi_id); int acpi_init_cpu_topology(void); =20 #else /* CONFIG_ACPI_CPU_TOPOLOGY */ =20 +static inline void acpi_map_cpu_acpiid(unsigned int cpu, uint32_t acpi_id)= {} static inline int acpi_init_cpu_topology(void) { return -EOPNOTSUPP; --=20 2.43.0