[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 13/52] cpu/core: Use generic topology helper for "help" to set nr_t
From: |
Zhao Liu |
Subject: |
[RFC 13/52] cpu/core: Use generic topology helper for "help" to set nr_threads |
Date: |
Mon, 13 Feb 2023 17:49:56 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
The commit 0b47ec4 (cpu/core: Fix "help" of CPU core device types) sets
nr_threads with current_machine's smp.threads for "help".
This will break if current_machine has hybrid topology. Though core
device now is only used by PPC, as the general code, hybrid topology
deserves to be handled more gracefully and does not depend on whether
the specific architecture supports hybrid topology.
So use a generic topology helper to get threads info (of CPU 0) from
current_machine. For smp case, this helper returns "threads per core"
as the original smp.threads, and for hybrid case, it returns threads of
the core that CPU 0 is located.
Since that nr_threads is just to make "help" happy and it isn't used
afterwards, give it the threads of CPU 0 can work.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/cpu/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/cpu/core.c b/hw/cpu/core.c
index 987607515574..bc5ab4e01038 100644
--- a/hw/cpu/core.c
+++ b/hw/cpu/core.c
@@ -71,10 +71,12 @@ static void cpu_core_instance_init(Object *obj)
/*
* Only '-device something-cpu-core,help' can get us there before
* the machine has been created. We don't care to set nr_threads
- * in this case since it isn't used afterwards.
+ * in this case since it isn't used afterwards, so we fetch the
+ * threads of the core where the CPU 0 is located, no matter whether
+ * the topology is smp or hybrid.
*/
if (current_machine) {
- core->nr_threads = current_machine->smp.threads;
+ core->nr_threads = machine_topo_get_threads_by_idx(current_machine, 0);
}
}
--
2.34.1
- [RFC 07/52] hw/core/machine: Add the new topology support in MachineState, (continued)
- [RFC 07/52] hw/core/machine: Add the new topology support in MachineState, Zhao Liu, 2023/02/13
- [RFC 08/52] machine: Add helpers to get cpu topology info from MachineState.topo, Zhao Liu, 2023/02/13
- [RFC 09/52] hw/machine: Introduce core type for hybrid topology, Zhao Liu, 2023/02/13
- [RFC 10/52] machine: Replace MachineState.topo.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 11/52] accel/kvm: Add hybrid info when check cpu num, Zhao Liu, 2023/02/13
- [RFC 12/52] hw/acpi: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 14/52] hw/smbios: Use generic topology name and helper, Zhao Liu, 2023/02/13
- [RFC 13/52] cpu/core: Use generic topology helper for "help" to set nr_threads,
Zhao Liu <=
- [RFC 15/52] migration/postcopy-ram: Use generic topology name and helper, Zhao Liu, 2023/02/13
- [RFC 16/52] plugins: Use generic topology name and helper, Zhao Liu, 2023/02/13
- [RFC 17/52] softmmu/cpus: Use generic topology helper in vcpus initialization, Zhao Liu, 2023/02/13
- [RFC 18/52] general: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 19/52] i386: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13
- [RFC 20/52] s390x: Replace MachineState.smp access with topology helpers, Zhao Liu, 2023/02/13