[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 30/41] hw/core/slot: Check topology child to be added under CPU slot, (continued)
- [RFC 30/41] hw/core/slot: Check topology child to be added under CPU slot, Zhao Liu, 2023/11/30
- [RFC 32/41] hw/machine: Build smp topology tree from -smp, Zhao Liu, 2023/11/30
- [RFC 34/41] hw/core/topo: Implement user-child to collect topology device from cli, Zhao Liu, 2023/11/30
- [RFC 35/41] hw/i386: Make x86_cpu_new() private in x86.c, Zhao Liu, 2023/11/30
- [RFC 31/41] hw/machine: Plug cpu-slot into machine to maintain topology tree, Zhao Liu, 2023/11/30
- [RFC 33/41] hw/machine: Validate smp topology tree without -smp, 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 36/41] hw/i386: Allow x86_cpu_new() to specify parent for new CPU, Zhao Liu, 2023/11/30
- [RFC 39/41] hw/i386: Add the interface to search parent for QOM topology, Zhao Liu, 2023/11/30
- [RFC 40/41] hw/i386: Support QOM topology, Zhao Liu, 2023/11/30
- [RFC 37/41] hw/i386: Allow i386 to create new CPUs from QOM topology,
Zhao Liu <=
- [RFC 41/41] hw/i386: Cleanup non-QOM topology support, Zhao Liu, 2023/11/30