[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH RFC 08/16] hw/core/machine: set cpu global nr_cores, n
From: |
Andrew Jones |
Subject: |
[Qemu-arm] [PATCH RFC 08/16] hw/core/machine: set cpu global nr_cores, nr_threads in pre_init |
Date: |
Fri, 10 Jun 2016 19:40:19 +0200 |
CPUState nr_cores and nr_threads are properties so we can set
them using the GlobalProperty API. Doing this in machine pre_init
allows us to easily propagate the values from the machine properties
to all cpus. An excellent bonus of this is that we can now remove
the references to the cpu topology globals smp_cores,smp_threads
from cpus.c.
Signed-off-by: Andrew Jones <address@hidden>
---
cpus.c | 2 --
hw/core/machine.c | 18 ++++++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/cpus.c b/cpus.c
index 326742f445eef..36d8faa0091c8 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1427,8 +1427,6 @@ static void qemu_dummy_start_vcpu(CPUState *cpu)
void qemu_init_vcpu(CPUState *cpu)
{
- cpu->nr_cores = smp_cores;
- cpu->nr_threads = smp_threads;
cpu->stopped = true;
if (!cpu->as) {
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 75c5a1fdd7de1..5427924d4c911 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -511,9 +511,22 @@ static void machine_set_smp_parameters(MachineState *ms)
ms->cpus = cpus;
}
+#define NR_CPUS_STRLEN sizeof(stringify(MAX_CPUMASK_BITS))
+
static void machine_pre_init(MachineState *ms)
{
MachineClass *mc = MACHINE_CLASS(object_get_class(OBJECT(ms)));
+ static char nr_cores[NR_CPUS_STRLEN], nr_threads[NR_CPUS_STRLEN];
+ static GlobalProperty cpu_nr_cores = {
+ .driver = "cpu",
+ .property = "nr-cores",
+ .value = nr_cores,
+ };
+ static GlobalProperty cpu_nr_threads = {
+ .driver = "cpu",
+ .property = "nr-threads",
+ .value = nr_threads,
+ };
machine_set_smp_parameters(ms);
smp_cores = ms->cores;
@@ -529,6 +542,11 @@ static void machine_pre_init(MachineState *ms)
exit(1);
}
+ snprintf(nr_cores, NR_CPUS_STRLEN, "%d", ms->cores);
+ snprintf(nr_threads, NR_CPUS_STRLEN, "%d", ms->threads);
+ qdev_prop_register_global(&cpu_nr_cores);
+ qdev_prop_register_global(&cpu_nr_threads);
+
if (ms->cpus > 1) {
Error *blocker = NULL;
error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
--
2.4.11
- Re: [Qemu-arm] [Qemu-devel] [PATCH RFC 06/16] vl: move smp parsing to machine pre_init, (continued)
- [Qemu-arm] [PATCH RFC 03/16] hw/smbios/smbios: fix number of sockets calculation, Andrew Jones, 2016/06/10
- [Qemu-arm] [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties, Andrew Jones, 2016/06/10
- Re: [Qemu-arm] [Qemu-devel] [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties, Thomas Huth, 2016/06/11
- Re: [Qemu-arm] [Qemu-devel] [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties, Andrew Jones, 2016/06/12
- Re: [Qemu-arm] [Qemu-devel] [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties, David Gibson, 2016/06/13
- Re: [Qemu-arm] [Qemu-devel] [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties, Andrew Jones, 2016/06/14
- Re: [Qemu-arm] [Qemu-devel] [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties, David Gibson, 2016/06/14
[Qemu-arm] [PATCH RFC 09/16] hw/i386/pc: don't use smp_cores, smp_threads, Andrew Jones, 2016/06/10
[Qemu-arm] [PATCH RFC 08/16] hw/core/machine: set cpu global nr_cores, nr_threads in pre_init,
Andrew Jones <=
[Qemu-arm] [PATCH RFC 05/16] hw/core/machine: add smp properites, Andrew Jones, 2016/06/10
[Qemu-arm] [PATCH RFC 11/16] target-ppc: don't use smp_threads, Andrew Jones, 2016/06/10
[Qemu-arm] [PATCH RFC 10/16] hw/ppc/spapr: don't use smp_cores, smp_threads, Andrew Jones, 2016/06/10