[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 35/52] i386: Support APIC ID topology for hybrid CPU topology
From: |
Zhao Liu |
Subject: |
[RFC 35/52] i386: Support APIC ID topology for hybrid CPU topology |
Date: |
Mon, 13 Feb 2023 17:50:18 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
X86ApicidTopoInfo is used to caculate offsets of topology levels for
APIC ID.
For hybrid CPU topology, X86ApicidTopoInfo should get the maximum
possible number of corresponding topology structures in each topology
level (currently, only for core and thread level).
Co-Developed-by: Zhuocheng Ding <zhuocheng.ding@intel.com>
Signed-off-by: Zhuocheng Ding <zhuocheng.ding@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/i386/x86.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 9ee0fcb9a460..1c071f8120cb 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -70,10 +70,37 @@ inline void init_apicid_topo_info(X86ApicidTopoInfo
*apicid_topo,
{
MachineState *ms = MACHINE(x86ms);
+ /*
+ * At present, the packages and dies in the hybrid CPU topology are the
+ * same, so the numbers of dies in one package and the numbers of modules
+ * in the dies are also the same.
+ */
apicid_topo->max_dies = machine_topo_get_dies(ms);
apicid_topo->max_modules = machine_topo_get_clusters(ms);
- apicid_topo->max_cores = machine_topo_get_smp_cores(ms);
- apicid_topo->max_threads = machine_topo_get_smp_threads(ms);
+
+ if (machine_topo_is_smp(ms)) {
+ apicid_topo->max_cores = machine_topo_get_smp_cores(ms);
+ apicid_topo->max_threads = machine_topo_get_smp_threads(ms);
+ } else {
+ int max_cores = 0;
+ int max_threads = 0;
+ int nr_clusters = machine_topo_get_clusters(ms);
+ int nr_cores, nr_threads;
+
+ for (int i = 0; i < nr_clusters; i++) {
+ nr_cores = machine_topo_get_cores(ms, i);
+ max_cores = max_cores > nr_cores ? max_cores : nr_cores;
+
+ for (int j = 0; j < nr_cores; j++) {
+ nr_threads = machine_topo_get_threads(ms, i, j);
+ max_threads = max_threads > nr_threads ?
+ max_threads : nr_threads;
+ }
+ }
+
+ apicid_topo->max_cores = max_cores;
+ apicid_topo->max_threads = max_threads;
+ }
}
/*
--
2.34.1
- [RFC 26/52] hw: Replace MachineState.smp access with topology helpers for all remaining archs, (continued)
- [RFC 26/52] hw: Replace MachineState.smp access with topology helpers for all remaining archs, Zhao Liu, 2023/02/13
- [RFC 27/52] test/test-smp-parse: Check fields of MachineState.topo.smp, Zhao Liu, 2023/02/13
- [RFC 28/52] hw/core/machine: Remove support of MachineState.smp, Zhao Liu, 2023/02/13
- [RFC 24/52] loongarch: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 30/52] i386: Drop nr_dies and nr_modules CPUX86State, Zhao Liu, 2023/02/13
- [RFC 29/52] hw/core/cpu: Introduce TopologyState in CPUState, Zhao Liu, 2023/02/13
- [RFC 31/52] i386/cpu: Use CPUState.topo to replace X86CPUTopoInfo to get topology info, Zhao Liu, 2023/02/13
- [RFC 32/52] i386: Rename X86CPUTopoInfo and its members to reflect relationship with APIC ID, Zhao Liu, 2023/02/13
- [RFC 35/52] i386: Support APIC ID topology for hybrid CPU topology,
Zhao Liu <=
- [RFC 33/52] i386: Rename init_topo_info() to init_apic_topo_info(), Zhao Liu, 2023/02/13
- [RFC 34/52] i386: Rename variable topo_info to apicid_topo, Zhao Liu, 2023/02/13
- [RFC 36/52] i386: Use init_apicid_topo_info() to initialize APIC ID topology for system emulator, Zhao Liu, 2023/02/13
- [RFC 38/52] i386: Introduce hybrid_core_type to CPUX86State, Zhao Liu, 2023/02/13
- [RFC 37/52] i386: Update X86CPUTopoIDs generating rule for hybrid topology, Zhao Liu, 2023/02/13
- [RFC 41/52] machine: Introduce core_type() hook, Zhao Liu, 2023/02/13