[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 10/41] hw/core/topo: Add virtual method to update topology info for
From: |
Zhao Liu |
Subject: |
[RFC 10/41] hw/core/topo: Add virtual method to update topology info for parent |
Date: |
Thu, 30 Nov 2023 22:41:32 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
When a new topology device is inserted into the topology tree,
its'parents (including non-direct parent) need to update topology
information.
Add the virtual method to help parents on topology tree update
topology information statistics.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/core/cpu-topo.c | 20 ++++++++++++++++++++
include/hw/core/cpu-topo.h | 4 ++++
2 files changed, 24 insertions(+)
diff --git a/hw/core/cpu-topo.c b/hw/core/cpu-topo.c
index 3e0c183388d8..e244f0a3564e 100644
--- a/hw/core/cpu-topo.c
+++ b/hw/core/cpu-topo.c
@@ -154,6 +154,20 @@ static void cpu_topo_build_hierarchy(CPUTopoState *topo,
Error **errp)
cpu_topo_refresh_free_child_index(parent);
}
+static void cpu_topo_update_info(CPUTopoState *topo, bool is_realize)
+{
+ CPUTopoState *parent = topo->parent;
+ CPUTopoClass *tc;
+
+ while (parent) {
+ tc = CPU_TOPO_GET_CLASS(parent);
+ if (tc->update_topo_info) {
+ tc->update_topo_info(parent, topo, is_realize);
+ }
+ parent = parent->parent;
+ }
+}
+
static void cpu_topo_set_parent(CPUTopoState *topo, Error **errp)
{
Object *obj = OBJECT(topo);
@@ -178,6 +192,11 @@ static void cpu_topo_set_parent(CPUTopoState *topo, Error
**errp)
if (topo->parent) {
cpu_topo_build_hierarchy(topo, errp);
+ if (*errp) {
+ return;
+ }
+
+ cpu_topo_update_info(topo, true);
}
}
@@ -203,6 +222,7 @@ static void cpu_topo_destroy_hierarchy(CPUTopoState *topo)
return;
}
+ cpu_topo_update_info(topo, false);
QTAILQ_REMOVE(&parent->children, topo, sibling);
parent->num_children--;
diff --git a/include/hw/core/cpu-topo.h b/include/hw/core/cpu-topo.h
index c0dfff9dc63b..79cd8606feca 100644
--- a/include/hw/core/cpu-topo.h
+++ b/include/hw/core/cpu-topo.h
@@ -44,6 +44,8 @@ OBJECT_DECLARE_TYPE(CPUTopoState, CPUTopoClass, CPU_TOPO)
/**
* CPUTopoClass:
* @level: Topology level for this CPUTopoClass.
+ * @update_topo_info: Method to update topology information statistics when
+ * new child (including direct child and non-direct child) is added.
*/
struct CPUTopoClass {
/*< private >*/
@@ -51,6 +53,8 @@ struct CPUTopoClass {
/*< public >*/
CPUTopoLevel level;
+ void (*update_topo_info)(CPUTopoState *parent, CPUTopoState *child,
+ bool is_realize);
};
/**
--
2.34.1
- [RFC 38/41] hw/i386: Wrap apic id and topology sub ids assigning as helpers, (continued)
- [RFC 38/41] hw/i386: Wrap apic id and topology sub ids assigning as helpers, Zhao Liu, 2023/11/30
- [RFC 01/41] qdev: Introduce new device category to cover basic topology device, Zhao Liu, 2023/11/30
- [RFC 21/41] hw/cpu/cluster: Allow cpu-cluster to be created by -device, 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 27/41] hw/core/slot: Introduce CPU slot as the root of CPU topology, Zhao Liu, 2023/11/30
- [RFC 07/41] qdev: Introduce parent option in -device, Zhao Liu, 2023/11/30
- [RFC 30/41] hw/core/slot: Check topology child to be added under CPU slot, Zhao Liu, 2023/11/30
- [RFC 04/41] qom/object: Introduce helper to resolve path from non-direct parent, Zhao Liu, 2023/11/30
- [RFC 06/41] qdev: Introduce user-child interface to collect devices from -device, Zhao Liu, 2023/11/30
- [RFC 09/41] hw/core/topo: Support topology index for topology device, Zhao Liu, 2023/11/30
- [RFC 10/41] hw/core/topo: Add virtual method to update topology info for parent,
Zhao Liu <=
- [RFC 16/41] PPC/ppc-core: Limit plugged-threads and nr-threads to be equal, Zhao Liu, 2023/11/30
- [RFC 24/41] hw/cpu/socket: Abstract cpu-socket level as topology device, Zhao Liu, 2023/11/30
- [RFC 26/41] hw/cpu/drawer: Abstract cpu-drawer level as topology device, Zhao Liu, 2023/11/30
- [RFC 15/41] hw/cpu/core: Allow to configure plugged threads for cpu-core, Zhao Liu, 2023/11/30
- [RFC 28/41] hw/core/slot: Maintain the core queue in CPU slot, Zhao Liu, 2023/11/30
- [RFC 33/41] hw/machine: Validate smp topology tree without -smp, 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 41/41] hw/i386: Cleanup non-QOM topology support, Zhao Liu, 2023/11/30