qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]