[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 46/52] hw/machine: build core level hybrid topology form HybridCore
From: |
Zhao Liu |
Subject: |
[RFC 46/52] hw/machine: build core level hybrid topology form HybridCorePack |
Date: |
Mon, 13 Feb 2023 17:50:29 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
After verifying the hybrid topology, we need to convert the topology
structure of the core level from a single linked list to an array,
so that we can make full use of the core-id to quickly access the
corresponding core.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/core/machine-topo.c | 48 ++++++++++++++++++++++++++++++++----------
hw/core/machine.c | 1 +
include/hw/boards.h | 1 +
3 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/hw/core/machine-topo.c b/hw/core/machine-topo.c
index 2cf71cc466aa..ebd2c40396a2 100644
--- a/hw/core/machine-topo.c
+++ b/hw/core/machine-topo.c
@@ -604,22 +604,13 @@ void set_hybrid_options(MachineState *ms,
void machine_free_hybrid_topology(MachineState *ms)
{
HybridCluster *cluster;
- HybridCorePack *core_pack;
- HybridCorePack *tmp;
if (ms->topo.hybrid.clusters) {
for (int i = 0; i < ms->topo.hybrid.clusters; i++) {
cluster = &ms->topo.hybrid.cluster_list[i];
- /*
- * TODO: Temporarily free core_pack_list here. When the
- * building of core_list array is supported, it will be
- * freeed there.
- */
- QSLIST_FOREACH_SAFE(core_pack, &cluster->core_pack_list,
- node, tmp) {
- QSLIST_REMOVE_HEAD(&cluster->core_pack_list, node);
- g_free(core_pack);
+ if (cluster->core_list != NULL) {
+ g_free(cluster->core_list);
}
}
g_free(ms->topo.hybrid.cluster_list);
@@ -751,3 +742,38 @@ void machine_validate_hybrid_topology(MachineState *ms,
Error **errp)
exit(1);
}
}
+
+void machine_consolidate_hybrid_topology(MachineState *ms)
+{
+ HybridCluster *cluster;
+ HybridCorePack *core_pack;
+ HybridCorePack *tmp;
+ int core_num;
+
+ for (int i = 0; i < ms->topo.hybrid.clusters; i++) {
+ cluster = &ms->topo.hybrid.cluster_list[i];
+ cluster->core_list = g_malloc0(sizeof(HybridCore) * cluster->cores);
+
+ core_num = cluster->cores;
+ QSLIST_FOREACH_SAFE(core_pack, &cluster->core_pack_list, node, tmp) {
+ QSLIST_REMOVE_HEAD(&cluster->core_pack_list, node);
+
+ /*
+ * Here we add cores in "reverse order" because core_pack_list uses
+ * "QSLIST_INSERT_HEAD()" to collect the cores in the "-hybrid"
+ * command line in reverse order.
+ *
+ * The "reverse order" here can ensure that the growth of core-id
+ * is consistent with the order of adding cores in "-hybrid".
+ */
+ for (int j = 0; j < core_pack->core_num; j++) {
+ cluster->core_list[core_num - j - 1].core_type =
+ core_pack->core.core_type;
+ cluster->core_list[core_num - j - 1].threads =
+ core_pack->core.threads;
+ }
+ core_num -= core_pack->core_num;
+ g_free(core_pack);
+ }
+ }
+}
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 630934317e3c..08a0c117ce1b 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1329,6 +1329,7 @@ void machine_run_board_init(MachineState *machine, const
char *mem_path, Error *
if (!machine_topo_is_smp(machine)) {
machine_validate_hybrid_topology(machine, errp);
+ machine_consolidate_hybrid_topology(machine);
}
if (machine->memdev) {
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 9156982e4de6..0f865c21e2a8 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -42,6 +42,7 @@ void set_hybrid_options(MachineState *ms,
Error **errp);
void machine_free_hybrid_topology(MachineState *ms);
void machine_validate_hybrid_topology(MachineState *ms, Error **errp);
+void machine_consolidate_hybrid_topology(MachineState *ms);
/**
* machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices
--
2.34.1
- Re: [RFC 41/52] machine: Introduce core_type() hook, (continued)
- [RFC 42/52] hw/machine: Add hybrid_supported in generic topo properties, Zhao Liu, 2023/02/13
- [RFC 40/52] qapi: Introduce hybrid options, Zhao Liu, 2023/02/13
- [RFC 39/52] i386/cpu: Add Intel hybrid related CPUID support, Zhao Liu, 2023/02/13
- [RFC 43/52] hw/machine: Rename MachineClass.smp_props to MachineClass.topo_props, Zhao Liu, 2023/02/13
- [RFC 44/52] machine: Add "-hybrid" parsing rule, Zhao Liu, 2023/02/13
- [RFC 45/52] hw/machine: Add hybrid cpu topology validation, Zhao Liu, 2023/02/13
- [RFC 47/52] hw/machine: Use opts_visitor to parse hybrid topo, Zhao Liu, 2023/02/13
- [RFC 46/52] hw/machine: build core level hybrid topology form HybridCorePack,
Zhao Liu <=
- [RFC 48/52] machine: Support "-hybrid" command, Zhao Liu, 2023/02/13
- [RFC 49/52] i386/pc: Support hybrid cpu topology, Zhao Liu, 2023/02/13
- [RFC 50/52] qemu-options: Add the document of hybrid command, Zhao Liu, 2023/02/13
- [RFC 51/52] qapi: Expose CPU topology info in query_cpus_fast, Zhao Liu, 2023/02/13
- [RFC 52/52] i386: Support cpu_index_to_core_type() for x86, Zhao Liu, 2023/02/13
- Re: [RFC 00/52] Introduce hybrid CPU topology, Alex Bennée, 2023/02/13
- Re: [RFC 00/52] Introduce hybrid CPU topology, Daniel P . Berrangé, 2023/02/13