[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/22] hw/core/machine: Introduce the module as a CPU topology lev
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 19/22] hw/core/machine: Introduce the module as a CPU topology level |
Date: |
Thu, 25 Apr 2024 13:01:52 +0200 |
From: Zhao Liu <zhao1.liu@intel.com>
In x86, module is the topology level above core, which contains a set
of cores that share certain resources (in current products, the resource
usually includes L2 cache, as well as module scoped features and MSRs).
Though smp.clusters could also share the L2 cache resource [1], there
are following reasons that drive us to introduce the new smp.modules:
* As the CPU topology abstraction in device tree [2], cluster supports
nesting (though currently QEMU hasn't support that). In contrast,
(x86) module does not support nesting.
* Due to nesting, there is great flexibility in sharing resources
on cluster, rather than narrowing cluster down to sharing L2 (and
L3 tags) as the lowest topology level that contains cores.
* Flexible nesting of cluster allows it to correspond to any level
between the x86 package and core.
* In Linux kernel, x86's cluster only represents the L2 cache domain
but QEMU's smp.clusters is the CPU topology level. Linux kernel will
also expose module level topology information in sysfs for x86. To
avoid cluster ambiguity and keep a consistent CPU topology naming
style with the Linux kernel, we introduce module level for x86.
The module is, in existing hardware practice, the lowest layer that
contains the core, while the cluster is able to have a higher
topological scope than the module due to its nesting.
Therefore, place the module between the cluster and the core:
drawer/book/socket/die/cluster/module/core/thread
With the above topological hierarchy order, introduce module level
support in MachineState and MachineClass.
[1]:
https://lore.kernel.org/qemu-devel/c3d68005-54e0-b8fe-8dc1-5989fe3c7e69@huawei.com/
[2]:
https://www.kernel.org/doc/Documentation/devicetree/bindings/cpu/cpu-topology.txt
Suggested-by: Xiaoyao Li <xiaoyao.li@intel.com>
Tested-by: Yongwei Ma <yongwei.ma@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Message-ID: <20240424154929.1487382-2-zhao1.liu@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/boards.h | 4 ++++
hw/core/machine-smp.c | 2 +-
hw/core/machine.c | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 69c1ba45cf..2fa800f11a 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -144,6 +144,7 @@ typedef struct {
* provided SMP configuration
* @books_supported - whether books are supported by the machine
* @drawers_supported - whether drawers are supported by the machine
+ * @modules_supported - whether modules are supported by the machine
*/
typedef struct {
bool prefer_sockets;
@@ -152,6 +153,7 @@ typedef struct {
bool has_clusters;
bool books_supported;
bool drawers_supported;
+ bool modules_supported;
} SMPCompatProps;
/**
@@ -339,6 +341,7 @@ typedef struct DeviceMemoryState {
* @sockets: the number of sockets in one book
* @dies: the number of dies in one socket
* @clusters: the number of clusters in one die
+ * @modules: the number of modules in one cluster
* @cores: the number of cores in one cluster
* @threads: the number of threads in one core
* @max_cpus: the maximum number of logical processors on the machine
@@ -350,6 +353,7 @@ typedef struct CpuTopology {
unsigned int sockets;
unsigned int dies;
unsigned int clusters;
+ unsigned int modules;
unsigned int cores;
unsigned int threads;
unsigned int max_cpus;
diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c
index 27864c9507..2e68fcfdfd 100644
--- a/hw/core/machine-smp.c
+++ b/hw/core/machine-smp.c
@@ -266,7 +266,7 @@ void machine_parse_smp_config(MachineState *ms,
unsigned int machine_topo_get_cores_per_socket(const MachineState *ms)
{
- return ms->smp.cores * ms->smp.clusters * ms->smp.dies;
+ return ms->smp.cores * ms->smp.modules * ms->smp.clusters * ms->smp.dies;
}
unsigned int machine_topo_get_threads_per_socket(const MachineState *ms)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 582c2df37a..9966641159 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1157,6 +1157,7 @@ static void machine_initfn(Object *obj)
ms->smp.sockets = 1;
ms->smp.dies = 1;
ms->smp.clusters = 1;
+ ms->smp.modules = 1;
ms->smp.cores = 1;
ms->smp.threads = 1;
--
2.41.0
- [PULL 05/22] hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h, (continued)
- [PULL 05/22] hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 07/22] hw/misc/applesmc: Simplify DeviceReset handler, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 06/22] target/i386: Move APIC related code to cpu-apic.c, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 10/22] hw: Fix problem with the A*MPCORE switches in the Kconfig files, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 09/22] hw/riscv/virt: Replace sprintf by g_strdup_printf, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 13/22] hw/cxl/cxl-cdat: Make ct3_build_cdat() return boolean, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 11/22] hw: Add a Kconfig switch for the TYPE_CPU_CLUSTER device, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 08/22] hw/misc/imx: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/25
- [PULL 16/22] hw/xtensa: Include missing 'exec/cpu-common.h' in 'bootparam.h', Philippe Mathieu-Daudé, 2024/04/25
- [PULL 15/22] hw/elf_ops: Rename elf_ops.h -> elf_ops.h.inc, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 19/22] hw/core/machine: Introduce the module as a CPU topology level,
Philippe Mathieu-Daudé <=
- [PULL 21/22] hw/core: Introduce module-id as the topology subindex, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 12/22] hw/cxl/cxl-cdat: Make ct3_load_cdat() return boolean, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 18/22] hw/i386/pc_sysfw: Remove unused parameter from pc_isa_bios_init(), Philippe Mathieu-Daudé, 2024/04/25
- [PULL 22/22] hw/core: Support module-id in numa configuration, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 17/22] hw/misc : Correct 5 spaces indents in stm32l4x5_exti, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 14/22] hw/cxl/cxl-cdat: Make cxl_doe_cdat_init() return boolean, Philippe Mathieu-Daudé, 2024/04/25
- [PULL 20/22] hw/core/machine: Support modules in -smp, Philippe Mathieu-Daudé, 2024/04/25
- Re: [PULL 00/22] Misc HW patches for 2024-04-25, Richard Henderson, 2024/04/25