[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 0/3] xen/arm: Device Tree based CPU topology support


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Date: Tue, 30 Jun 2026 06:58:03 +0900
  • 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
  • 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=8206NVqXCPTNVxkDSfDdIXT3kJSrarb4kGiH6emSyTg=; b=PrM+SjEdTb/WCuTqN+LTGEqCDphQLd4h0wCldH+fREo8QVdO+aGRH4DhSQPOMSyLTc39uUkMKzsgYJOdNSyadnQeYjr01z+Hf2eF+ELi20uilTEavD/ik27tLnlI3p9YF8LJ1KGwbHWMbxEiAk6cbh0PwA5xGYImYzvos5f8mTSjAYBtlNc63JuGKPdF2KZvZZgWitRQ1V8TcQ0V6JqyHhWb+qePmpFa3B40BGfM7LuL85PJoAi9tZ5fYS5dqkFSxQhV2rTy4C97ftotRP/Akrh8nQZ0MdA0FcBHqFN4ovTKpizM+Rw/sXhiEo1CVnXHkPJKgLe8Wp2UrcJUulOcMg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KcFMOqujsJN1v7qsWfOuJJQjKuOj/h782ByHQRaL4i1p1hTrcGglctQNJCrke+kpJoTIjL2fefNQbq68X20cAfvC+avgsglQLlfORZlmjxo9pY5PqxVOtiDywDunCW0qhYm6rwEHdBvSlbYec2JYwlZ7FwHdv5QjtrkOcLjdIzXQW9wPhbhRB2rQ9PqFHutj7VE1mF26DCEIQJtTmXJcx2PgRVyLn/fLNIqw4rlIa1pmDFd+HvJFX8+xLGU9gjusg2YtW0tC2cObQoGNNs+KQi2j1kwzZ3ao1DZjiF2+4flKO4q0ontRRa0DNS1g8E++8PR8CwcaPmj+MTlqOOgYpw==
  • 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"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp;
  • Cc: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Delivery-date: Mon, 29 Jun 2026 21:58:36 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hello,

This patch series introduces basic CPU topology support for ARM Xen.

I'm a bit torn on the best way to implement the fallback macros like
cpu_to_socket() in cpu-topology.h when CONFIG_CPU_TOPOLOGY is off.
Specifically, I want non-x86 architectures to share these fallbacks
while keeping x86 from seeing them.

The first approach is simple, but it will break if x86 changes how it
defines these helpers in the future. For example, if it switches from
macros to inline functions:

#ifndef cpu_to_socket
#define cpu_to_socket(cpu) (0)
#endif

The second approach is to make them active only for Device Tree setups
via CONFIG_DEVICE_TREE_PARSE. However, this might not be the "right"
way either, just in case an architecture comes along that doesn't use
DT but still populates the topology table via another method like
ACPI.

#ifdef CONFIG_DEVICE_TREE_PARSE
#define cpu_to_socket(cpu) (0)
#endif /* CONFIG_DEVICE_TREE_PARSE */

Then again, if ARM, RISC-V, and PPC all end up enabling
CONFIG_CPU_TOPOLOGY by default anyway, we won't even need this =n
fallback code. So I'm maybe just overthinking this.

Future Work:
 - Support for the "credit2_runqueue=cluster" option.
 - CPU topology support for RISC-V and PPC (once SMP support is available).
 - Topology information generation from the ACPI PPTT.

Changes in v3:
 - Use (nr_cpu_ids - 1) as the maximum CPU ID here. The fix for the sparse
   map mismatch issue on ARM Xen has been split out into a separate patch.
 - Switch topology sibling masks to cpumask_var_t for dynamic allocation.
 - Allow the system to keep running with a degraded fallback even if
   the topology table allocation fails.
 - Remove the temporary definitions of cpu_to_core() and cpu_to_socket()
   from RISC-V and PPC processor.h.
 - Minimize the use of #ifdef blocks, leveraging compiler Dead Code
   Elimination (DCE) where possible.
 - Clean up the code to follow the Xen coding style. Please let me know
   if I missed any style nits!
 - Verify successful builds across x86, RISC-V, and PPC environments.

Changes in v2:
 - Generate topology information even when ACPI is enabled. Note that
   this is a temporary implementation and doesn't yet parse the PPTT
   (Processor Properties Topology Table).
 - Added support for cpu-map node in Device Tree that doesn't contain
   explicit cluster node definitions.

Changes in v1 from the previous series "Introduce Device Tree based NUMA
support for ARM Xen":

1. Optimized Memory Allocation:
   The series now allocates only the minimum required memory area to manage
   the essential data for the CPUs.

2. Flexible Device Tree Parsing:
   The parsing logic no longer depends on the definition order of the 'cpu'
   nodes and 'cpu-map' nodes in the Device Tree. They can now be read
   correctly even if their orders do not match.

3. CPU Hotplug Readiness:
   To support future CPU hotplug, the system assumes that inactive CPUs are
   also described in the Device Tree. Xen will pre-load and generate the
   topology information for these inactive CPUs during the boot phase so
   it stays available in memory.

Thank you,
Hirokazu Takahashi

Hirokazu Takahashi (3):
  xen/device-tree: Parse 'cpu-map' node for CPU topology exploration
  xen/sched: Link CPU topology to scheduler
  xen/sched: Make cpu_nr_siblings() architecture-specific

 xen/arch/arm/Kconfig                   |  10 +
 xen/arch/arm/include/asm/processor.h   |   4 -
 xen/arch/arm/smpboot.c                 |  29 +-
 xen/arch/ppc/include/asm/processor.h   |   4 -
 xen/arch/riscv/include/asm/processor.h |   4 -
 xen/arch/x86/include/asm/processor.h   |   1 +
 xen/common/Kconfig                     |   8 +
 xen/common/Makefile                    |   1 +
 xen/common/cpu-topology.c              |  59 ++++
 xen/common/device-tree/Makefile        |   1 +
 xen/common/device-tree/cpu-topology.c  | 403 +++++++++++++++++++++++++
 xen/common/sched/credit2.c             |  21 +-
 xen/common/sysctl.c                    |   1 +
 xen/drivers/acpi/Kconfig               |   3 +
 xen/drivers/acpi/Makefile              |   2 +
 xen/drivers/acpi/topology.c            |  41 +++
 xen/include/xen/acpi.h                 |   2 +
 xen/include/xen/cpu-topology.h         |  55 ++++
 xen/include/xen/dt-cpu-topology.h      |  29 ++
 19 files changed, 642 insertions(+), 36 deletions(-)
 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

-- 
2.43.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.