[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 37/41] hw/i386: Allow i386 to create new CPUs from QOM topology
From: |
Zhao Liu |
Subject: |
[RFC 37/41] hw/i386: Allow i386 to create new CPUs from QOM topology |
Date: |
Thu, 30 Nov 2023 22:41:59 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
For QOM topology, maximum number of CPUs and the number of plugged CPUs
are configured in core level.
Iterate through all the cpu-cores to determine how many CPUs should be
created in each cpu-core.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/i386/x86.c | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 3c99f4c3ab51..febffed92a83 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -152,9 +152,35 @@ void x86_cpus_init(X86MachineState *x86ms, int
default_cpu_version)
}
possible_cpus = mc->possible_cpu_arch_ids(ms);
- for (i = 0; i < ms->smp.cpus; i++) {
- x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id,
- NULL, i, &error_fatal);
+
+ /*
+ * possible_cpus_qom_granu means the QOM topology support.
+ *
+ * TODO: Drop the "!mc->smp_props.possible_cpus_qom_granu" case when
+ * i386 completes QOM topology support.
+ */
+ if (mc->smp_props.possible_cpus_qom_granu) {
+ CPUCore *core;
+ int cpu_index = 0;
+ int core_idx = 0;
+
+ MACHINE_CORE_FOREACH(ms, core) {
+ for (i = 0; i < core->plugged_threads; i++) {
+ x86_cpu_new(x86ms, possible_cpus->cpus[cpu_index].arch_id,
+ OBJECT(core), cpu_index, &error_fatal);
+ cpu_index++;
+ }
+
+ if (core->plugged_threads < core->nr_threads) {
+ cpu_index += core->nr_threads - core->plugged_threads;
+ }
+ core_idx++;
+ }
+ } else {
+ for (i = 0; i < ms->smp.cpus; i++) {
+ x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id,
+ NULL, i, &error_fatal);
+ }
}
}
--
2.34.1
- [RFC 08/41] hw/core/topo: Introduce CPU topology device abstraction, (continued)
- [RFC 08/41] hw/core/topo: Introduce CPU topology device abstraction, Zhao Liu, 2023/11/30
- [RFC 16/41] PPC/ppc-core: Limit plugged-threads and nr-threads to be equal, Zhao Liu, 2023/11/30
- [RFC 22/41] hw/cpu/cluster: Convert cpu-cluster from general device to topology device, Zhao Liu, 2023/11/30
- [RFC 12/41] hw/core/topo: Add helpers to traverse the CPU topology tree, Zhao Liu, 2023/11/30
- [RFC 14/41] PPC/ppc-core: Offload core-id to PPC specific core abstarction, Zhao Liu, 2023/11/30
- [RFC 17/41] hw/cpu/core: Convert cpu-core from general device to topology device, Zhao Liu, 2023/11/30
- [RFC 19/41] hw/cpu/cluster: Wrap TCG related ops and props into CONFIG_TCG, Zhao Liu, 2023/11/30
- [RFC 41/41] hw/i386: Cleanup non-QOM topology support, Zhao Liu, 2023/11/30
- [RFC 02/41] qdev: Allow qdev_device_add() to add specific category device, Zhao Liu, 2023/11/30
- [RFC 38/41] hw/i386: Wrap apic id and topology sub ids assigning as helpers, Zhao Liu, 2023/11/30
- [RFC 37/41] hw/i386: Allow i386 to create new CPUs from QOM topology,
Zhao Liu <=