Skip to contentSkip to conversation

cpu-package hotplug

RFC PATCH In review Bharata B Rao 5 participants 22 messages Feb 22, 2016 – Feb 23, 2016

lore
Share & tools
lore
#0 lore raw

cover cpu-package hotplug

Hi,

This is an attempt to implement David Gibson's RFC that was posted at
https://lists.gnu.org/archive/html/qemu-ppc/2016-02/msg00000.html
I am not sure if I have followed all the aspects of the RFC fully, but we can make changes going forward.

An example cpu-package implementation is done for sPAPR in this patchset. Hot removal is not yet done in this patchset.

For the command line,

-smp 8,sockets=1,cores=1,threads=8,maxcpus=16 -numa node,nodeid=0,cpus=0-7 -numa node,nodeid=1,cpus=8-15

the HMP query looks like this:

(qemu) info cpu-packages
CPU Package: ""
type: "spapr-cpu-package"
qom_path: "/machine/cpu-package[0]"
realized: true
nr_cpus: 8

  CPU: 0
    Type: "host-powerpc64-cpu"
    Arch ID: 0
    Thread: 0
    Core: 0
    Socket: 0
    Node: 0
  CPU: 1
    Type: "host-powerpc64-cpu"
    Arch ID: 1
    Thread: 1
    Core: 0
    Socket: 0
    Node: 0
  CPU: 2
    Type: "host-powerpc64-cpu"
    Arch ID: 2
    Thread: 2
    Core: 0
    Socket: 0
    Node: 0
  CPU: 3
    Type: "host-powerpc64-cpu"
    Arch ID: 3
    Thread: 3
    Core: 0
    Socket: 0
    Node: 0
  CPU: 4
    Type: "host-powerpc64-cpu"
    Arch ID: 4
    Thread: 4
    Core: 0
    Socket: 0
    Node: 0
  CPU: 5
    Type: "host-powerpc64-cpu"
    Arch ID: 5
    Thread: 5
    Core: 0
    Socket: 0
    Node: 0
  CPU: 6
    Type: "host-powerpc64-cpu"
    Arch ID: 6
    Thread: 6
    Core: 0
    Socket: 0
    Node: 0
  CPU: 7
    Type: "host-powerpc64-cpu"
    Arch ID: 7
    Thread: 7
    Core: 0
    Socket: 0
    Node: 0

CPU Package: ""
type: "spapr-cpu-package"
qom_path: "/machine/cpu-package[1]"
realized: false
nr_cpus: 8

As can be seen from above, all the cores upto max_cpus are created upfront here and hot plug is done in the following manner:

(qemu) qom-set /machine/cpu-package[1] realized true

This will result in the 2nd cpu-package consisting of a core with 8 threads to become available.

I am not fully sure if the QMP emumeration here works for all archs, but just wanted to share what I currently.

Bharata B Rao (8):
cpu: Store CPU typename in MachineState
cpu: Don't realize CPU from cpu_generic_init()
cpu: CPU package abstract device
spapr: Introduce CPU core device
spapr: Convert boot CPUs into CPU core device initialization
spapr: CPU hotplug support
qmp: Implement query cpu-packages
hmp: Implement 'info cpu-slots'

 hmp-commands-info.hx               |  14 +++
 hmp.c                              |  50 ++++++++
 hmp.h                              |   1 +
 hw/cpu/Makefile.objs               |   1 +
 hw/cpu/package.c                   |  85 +++++++++++++
 hw/ppc/Makefile.objs               |   1 +
 hw/ppc/spapr.c                     | 246 +++++++++++++++++++++++++++++++++++--
 hw/ppc/spapr_cpu_package.c         |  50 ++++++++
 hw/ppc/spapr_events.c              |   3 +
 hw/ppc/spapr_rtas.c                |  24 ++++
 include/hw/boards.h                |   2 +
 include/hw/cpu/package.h           |  27 ++++
 include/hw/ppc/spapr.h             |   1 +
 include/hw/ppc/spapr_cpu_package.h |  27 ++++
 qapi-schema.json                   |  48 ++++++++
 qom/cpu.c                          |   6 -
 target-arm/helper.c                |  16 ++-
 target-cris/cpu.c                  |  16 ++-
 target-lm32/helper.c               |  16 ++-
 target-moxie/cpu.c                 |  16 ++-
 target-openrisc/cpu.c              |  16 ++-
 target-ppc/translate_init.c        |  16 ++-
 target-sh4/cpu.c                   |  16 ++-
 target-tricore/helper.c            |  16 ++-
 target-unicore32/helper.c          |  16 ++-
 25 files changed, 707 insertions(+), 23 deletions(-)
 create mode 100644 hw/cpu/package.c
 create mode 100644 hw/ppc/spapr_cpu_package.c
 create mode 100644 include/hw/cpu/package.h
 create mode 100644 include/hw/ppc/spapr_cpu_package.h
Signature · 1 line
2.1.0
#1 lore raw

RFC PATCH 1/8 cpu: Store CPU typename in MachineState

Storing CPU typename in MachineState lets us to create CPU threads for all architectures in uniform manner from arch-neutral code.

TODO: Touching only sPAPR target for now

---
 hw/ppc/spapr.c      | 2 ++
 include/hw/boards.h | 1 +
 2 files changed, 3 insertions(+)
hw/ppc/spapr.c +2 -0
index 5bd8fd3..3892a99 100644
@@ -1823,6 +1823,8 @@ static void ppc_spapr_init(MachineState *machine)
     if (machine->cpu_model == NULL) {
         machine->cpu_model = kvm_enabled() ? "host" : "POWER7";
     }
+    machine->cpu_type = TYPE_POWERPC_CPU;
+
     for (i = 0; i < smp_cpus; i++) {
         cpu = cpu_ppc_init(machine->cpu_model);
         if (cpu == NULL) {
include/hw/boards.h +1 -0
index 0f30959..cf95d10 100644
@@ -137,6 +137,7 @@ struct MachineState {
     char *kernel_cmdline;
     char *initrd_filename;
     const char *cpu_model;
+    const char *cpu_type;
     AccelState *accelerator;
 };
 
Signature · 1 line
2.1.0
#2 lore raw

Re: [Qemu-devel] [RFC PATCH v0 1/8] cpu: Store CPU typename in MachineState

Quoted 6 lines · Bharata B Rao

Storing CPU typename in MachineState lets us to create CPU threads for all architectures in uniform manner from arch-neutral code.

TODO: Touching only sPAPR target for now

As noted elsewhere, I hope we can do away with the need for this, but I haven't yet figured out enough about the QOM model to see how.

Quoted 30 lines
---
 hw/ppc/spapr.c      | 2 ++
 include/hw/boards.h | 1 +
 2 files changed, 3 insertions(+)
hw/ppc/spapr.c +2 -0
index 5bd8fd3..3892a99 100644
@@ -1823,6 +1823,8 @@ static void ppc_spapr_init(MachineState *machine)
     if (machine->cpu_model == NULL) {
         machine->cpu_model = kvm_enabled() ? "host" : "POWER7";
     }
+    machine->cpu_type = TYPE_POWERPC_CPU;
+
     for (i = 0; i < smp_cpus; i++) {
         cpu = cpu_ppc_init(machine->cpu_model);
         if (cpu == NULL) {
include/hw/boards.h +1 -0
index 0f30959..cf95d10 100644
@@ -137,6 +137,7 @@ struct MachineState {
     char *kernel_cmdline;
     char *initrd_filename;
     const char *cpu_model;
+    const char *cpu_type;
     AccelState *accelerator;
 };
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw

RFC PATCH 2/8 cpu: Don't realize CPU from cpu_generic_init()

In reply to Bharata B Rao

Don't do CPU realization from cpu_generic_init(). With this cpu_generic_init() will be used to just create CPU threads and they should be realized separately from realizefn call.

Convert the existing callers to do explicit realization.

---
 qom/cpu.c                   |  6 ------
 target-arm/helper.c         | 16 +++++++++++++++-
 target-cris/cpu.c           | 16 +++++++++++++++-
 target-lm32/helper.c        | 16 +++++++++++++++-
 target-moxie/cpu.c          | 16 +++++++++++++++-
 target-openrisc/cpu.c       | 16 +++++++++++++++-
 target-ppc/translate_init.c | 16 +++++++++++++++-
 target-sh4/cpu.c            | 16 +++++++++++++++-
 target-tricore/helper.c     | 16 +++++++++++++++-
 target-unicore32/helper.c   | 16 +++++++++++++++-
 10 files changed, 135 insertions(+), 15 deletions(-)
qom/cpu.c +0 -6
index 38dc713..c0211fa 100644
@@ -64,13 +64,7 @@ CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
     featurestr = strtok(NULL, ",");
     cc->parse_features(cpu, featurestr, &err);
     g_free(str);
-    if (err != NULL) {
-        goto out;
-    }
-
-    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
 
-out:
     if (err != NULL) {
         error_report_err(err);
         object_unref(OBJECT(cpu));
target-arm/helper.c +15 -1
index 5ea507f..d76c55c 100644
@@ -4564,7 +4564,21 @@ void register_cp_regs_for_features(ARMCPU *cpu)
 
 ARMCPU *cpu_arm_init(const char *cpu_model)
 {
-    return ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_ARM_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return ARM_CPU(cpu);
+    }
 }
 
 void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
target-cris/cpu.c +15 -1
index b2c8624..82f0ce5 100644
@@ -90,7 +90,21 @@ static ObjectClass *cris_cpu_class_by_name(const char *cpu_model)
 
 CRISCPU *cpu_cris_init(const char *cpu_model)
 {
-    return CRIS_CPU(cpu_generic_init(TYPE_CRIS_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_CRIS_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return CRIS_CPU(cpu);
+    }
 }
 
 /* Sort alphabetically by VR. */
target-lm32/helper.c +15 -1
index 655248f..4080496 100644
@@ -220,7 +220,21 @@ bool lm32_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
 
 LM32CPU *cpu_lm32_init(const char *cpu_model)
 {
-    return LM32_CPU(cpu_generic_init(TYPE_LM32_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_LM32_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return LM32_CPU(cpu);
+    }
 }
 
 /* Some soc ignores the MSB on the address bus. Thus creating a shadow memory
target-moxie/cpu.c +15 -1
index b33c2b3..95fc3d0 100644
@@ -153,7 +153,21 @@ static const MoxieCPUInfo moxie_cpus[] = {
 
 MoxieCPU *cpu_moxie_init(const char *cpu_model)
 {
-    return MOXIE_CPU(cpu_generic_init(TYPE_MOXIE_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_MOXIE_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return MOXIE_CPU(cpu);
+    }
 }
 
 static void cpu_register(const MoxieCPUInfo *info)
target-openrisc/cpu.c +15 -1
index cafc07f..e82bcfc 100644
@@ -223,7 +223,21 @@ static void openrisc_cpu_register_types(void)
 
 OpenRISCCPU *cpu_openrisc_init(const char *cpu_model)
 {
-    return OPENRISC_CPU(cpu_generic_init(TYPE_OPENRISC_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_OPENRISC_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return OPENRISC_CPU(cpu);
+    }
 }
 
 /* Sort alphabetically by type name, except for "any". */
target-ppc/translate_init.c +15 -1
index cdd18ac..a577bec 100644
@@ -9458,7 +9458,21 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
 
 PowerPCCPU *cpu_ppc_init(const char *cpu_model)
 {
-    return POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_POWERPC_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return POWERPC_CPU(cpu);
+    }
 }
 
 /* Sort by PVR, ordering special case "host" last. */
target-sh4/cpu.c +15 -1
index 8621d70..db02ac2 100644
@@ -156,7 +156,21 @@ static ObjectClass *superh_cpu_class_by_name(const char *cpu_model)
 
 SuperHCPU *cpu_sh4_init(const char *cpu_model)
 {
-    return SUPERH_CPU(cpu_generic_init(TYPE_SUPERH_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_SUPERH_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return SUPERH_CPU(cpu);
+    }
 }
 
 static void sh7750r_cpu_initfn(Object *obj)
target-tricore/helper.c +15 -1
index a8fd418..b9aa497 100644
@@ -79,7 +79,21 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address,
 
 TriCoreCPU *cpu_tricore_init(const char *cpu_model)
 {
-    return TRICORE_CPU(cpu_generic_init(TYPE_TRICORE_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_TRICORE_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return TRICORE_CPU(cpu);
+    }
 }
 
 static void tricore_cpu_list_entry(gpointer data, gpointer user_data)
target-unicore32/helper.c +15 -1
index 21f5f35..f0209b7 100644
@@ -28,7 +28,21 @@
 
 UniCore32CPU *uc32_cpu_init(const char *cpu_model)
 {
-    return UNICORE32_CPU(cpu_generic_init(TYPE_UNICORE32_CPU, cpu_model));
+    CPUState *cpu = cpu_generic_init(TYPE_UNICORE32_CPU, cpu_model);
+    Error *err = NULL;
+
+    if (!cpu) {
+        return NULL;
+    }
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err != NULL) {
+        error_report_err(err);
+        object_unref(OBJECT(cpu));
+        return NULL;
+    } else {
+        return UNICORE32_CPU(cpu);
+    }
 }
 
 uint32_t HELPER(clo)(uint32_t x)
Signature · 1 line
2.1.0
#4 lore raw

RFC PATCH 3/8 cpu: CPU package abstract device

In reply to Bharata B Rao

A minimal abstract device that target machines can create sub-types of to define their own cpu-package devices. Provides a realize routine that walks the child objects and realizes them iteratively. Hence cpu-package interface expects the target implementations to have a hierarchical setup for their CPU objects.

---
 hw/cpu/Makefile.objs     |  1 +
 hw/cpu/package.c         | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/cpu/package.h | 27 ++++++++++++++++++++
 3 files changed, 94 insertions(+)
 create mode 100644 hw/cpu/package.c
 create mode 100644 include/hw/cpu/package.h
hw/cpu/Makefile.objs +1 -0
index 0954a18..f540826 100644
@@ -2,4 +2,5 @@ obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o
 obj-$(CONFIG_REALVIEW) += realview_mpcore.o
 obj-$(CONFIG_A9MPCORE) += a9mpcore.o
 obj-$(CONFIG_A15MPCORE) += a15mpcore.o
+obj-y += package.o
 
hw/cpu/package.c new file +66 -0

66 lines not on this page · raw message

include/hw/cpu/package.h new file +27 -0
new file mode 100644
index 0000000..0579a42
@@ -0,0 +1,27 @@
+/*
+ * CPU package device
+ *
+ * Copyright (C) 2016 Bharata B Rao <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef HW_CPU_PACKAGE_H
+#define HW_CPU_PACKAGE_H
+
+#include "hw/qdev.h"
+
+#define TYPE_CPU_PACKAGE "cpu-package"
+#define CPU_PACKAGE(obj) \
+    OBJECT_CHECK(CPUPackage, (obj), TYPE_CPU_PACKAGE)
+
+typedef struct CPUPackage {
+    /* private */
+    DeviceState parent_obj;
+
+    /* public */
+} CPUPackage;
+
+Object *cpu_package_create_object(const char *typename, uint32_t index,
+                                  Error **errp);
+#endif
Signature · 1 line
2.1.0
#5 lore raw

RFC PATCH 4/8 spapr: Introduce CPU core device

In reply to Bharata B Rao

sPAPR CPU core device is a container of CPU thread devices. CPU hotplug is performed in the granularity of CPU core device by setting the "realized" property of this device to "true". When hotplugged, CPU core creates CPU thread devices.

TODO: Right now allows for only homogeneous configurations as we depend on global smp_threads and machine->cpu_model.

---
 hw/ppc/Makefile.objs               |  1 +
 hw/ppc/spapr_cpu_package.c         | 50 ++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/spapr_cpu_package.h | 26 ++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 hw/ppc/spapr_cpu_package.c
 create mode 100644 include/hw/ppc/spapr_cpu_package.h
hw/ppc/Makefile.objs +1 -0
index c1ffc77..3000982 100644
@@ -4,6 +4,7 @@ obj-y += ppc.o ppc_booke.o
 obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
 obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o
+obj-$(CONFIG_PSERIES) += spapr_cpu_package.o
 ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
 obj-y += spapr_pci_vfio.o
 endif
hw/ppc/spapr_cpu_package.c new file +50 -0

50 lines not on this page · raw message

include/hw/ppc/spapr_cpu_package.h new file +26 -0
new file mode 100644
index 0000000..547dbc1
@@ -0,0 +1,26 @@
+/*
+ * sPAPR CPU package device.
+ *
+ * Copyright (C) 2016 Bharata B Rao <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef HW_SPAPR_CPU_PACKAGE_H
+#define HW_SPAPR_CPU_PACKAGE_H
+
+#include "hw/qdev.h"
+
+#define TYPE_SPAPR_CPU_PACKAGE "spapr-cpu-package"
+#define SPAPR_CPU_PACKAGE(obj) \
+    OBJECT_CHECK(sPAPRCPUPackage, (obj), TYPE_SPAPR_CPU_PACKAGE)
+
+typedef struct sPAPRCPUPackage {
+    /*< private >*/
+    DeviceState parent_obj;
+
+    /*< public >*/
+    PowerPCCPU *thread0;
+} sPAPRCPUPackage;
+
+#endif
Signature · 1 line
2.1.0
#6 lore raw

Re: [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device

Am 22.02.2016 um 06:01 schrieb Bharata B Rao:

Quoted 49 lines

sPAPR CPU core device is a container of CPU thread devices. CPU hotplug is performed in the granularity of CPU core device by setting the "realized" property of this device to "true". When hotplugged, CPU core creates CPU thread devices.

TODO: Right now allows for only homogeneous configurations as we depend on global smp_threads and machine->cpu_model.

---
 hw/ppc/Makefile.objs               |  1 +
 hw/ppc/spapr_cpu_package.c         | 50 ++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/spapr_cpu_package.h | 26 ++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 hw/ppc/spapr_cpu_package.c
 create mode 100644 include/hw/ppc/spapr_cpu_package.h
hw/ppc/Makefile.objs +1 -0
index c1ffc77..3000982 100644
@@ -4,6 +4,7 @@ obj-y += ppc.o ppc_booke.o
 obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
 obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o
+obj-$(CONFIG_PSERIES) += spapr_cpu_package.o
 ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
 obj-y += spapr_pci_vfio.o
 endif
hw/ppc/spapr_cpu_package.c new file +14 -0
new file mode 100644
index 0000000..3120a16
@@ -0,0 +1,50 @@
+/*
+ * sPAPR CPU package device, acts as container of CPU thread devices.
+ *
+ * Copyright (C) 2016 Bharata B Rao <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/cpu/package.h"
+#include "hw/ppc/spapr_cpu_package.h"
+#include "hw/boards.h"
+#include <sysemu/cpus.h>
+#include "qemu/error-report.h"
+

hw/ppc/spapr_cpu_package.c line 24

Quoted 10 lines
hw/ppc/spapr_cpu_package.c new file +10 -0
+static void spapr_cpu_package_instance_init(Object *obj)
+{
+    int i;
+    CPUState *cpu;
+    MachineState *machine = MACHINE(qdev_get_machine());
+    sPAPRCPUPackage *package = SPAPR_CPU_PACKAGE(obj);
+
+    /* Create as many CPU threads as specified in the topology */
+    for (i = 0; i < smp_threads; i++) {
+        cpu = cpu_generic_init(machine->cpu_type, machine->cpu_model);

No, no, no. This is horribly violating QOM design.

Please compare the x86 RFC.

Andreas

Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
#7 lore raw

Re: [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device

Quoted 54 lines · Andreas Färber

Am 22.02.2016 um 06:01 schrieb Bharata B Rao:

Quoted 53 lines

sPAPR CPU core device is a container of CPU thread devices. CPU hotplug is performed in the granularity of CPU core device by setting the "realized" property of this device to "true". When hotplugged, CPU core creates CPU thread devices.

TODO: Right now allows for only homogeneous configurations as we depend on global smp_threads and machine->cpu_model.

---
 hw/ppc/Makefile.objs               |  1 +
 hw/ppc/spapr_cpu_package.c         | 50 ++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/spapr_cpu_package.h | 26 ++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 hw/ppc/spapr_cpu_package.c
 create mode 100644 include/hw/ppc/spapr_cpu_package.h
hw/ppc/Makefile.objs +1 -0
index c1ffc77..3000982 100644
@@ -4,6 +4,7 @@ obj-y += ppc.o ppc_booke.o
 obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
 obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o
+obj-$(CONFIG_PSERIES) += spapr_cpu_package.o
 ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
 obj-y += spapr_pci_vfio.o
 endif
hw/ppc/spapr_cpu_package.c new file +18 -0
new file mode 100644
index 0000000..3120a16
@@ -0,0 +1,50 @@
+/*
+ * sPAPR CPU package device, acts as container of CPU thread devices.
+ *
+ * Copyright (C) 2016 Bharata B Rao <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/cpu/package.h"
+#include "hw/ppc/spapr_cpu_package.h"
+#include "hw/boards.h"
+#include <sysemu/cpus.h>
+#include "qemu/error-report.h"
+
+static void spapr_cpu_package_instance_init(Object *obj)
+{
+    int i;
+    CPUState *cpu;
Quoted 8 lines

hw/ppc/spapr_cpu_package.c line 24

Quoted 6 lines
hw/ppc/spapr_cpu_package.c new file +6 -0
+    MachineState *machine = MACHINE(qdev_get_machine());
+    sPAPRCPUPackage *package = SPAPR_CPU_PACKAGE(obj);
+
+    /* Create as many CPU threads as specified in the topology */
+    for (i = 0; i < smp_threads; i++) {
+        cpu = cpu_generic_init(machine->cpu_type, machine->cpu_model);

No, no, no. This is horribly violating QOM design.

Ok.. why? There does not, to me, seem to be any remotely easily discoverable means of finding out what QOM design principles are.

It also would have been nice if you weighed in on my RFC this code is based on.

Quoted 1 line

Please compare the x86 RFC.

Where do I find this?

From all I could tell there just seemed to be a lot of spinning of wheels on the cpu hotplug stuff, which is why I made the cpu-packages proposal to try and move things forward.

There's been a lot of "don't do it like that" but precious little "here's how you _should_ do it" that actually addresses the needs of the various platforms.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#8 lore raw

Re: [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device

Am 22.02.2016 um 08:47 schrieb David Gibson:

Quoted 64 lines · Andreas Färber
Quoted 54 lines

Am 22.02.2016 um 06:01 schrieb Bharata B Rao:

Quoted 53 lines

sPAPR CPU core device is a container of CPU thread devices. CPU hotplug is performed in the granularity of CPU core device by setting the "realized" property of this device to "true". When hotplugged, CPU core creates CPU thread devices.

TODO: Right now allows for only homogeneous configurations as we depend on global smp_threads and machine->cpu_model.

---
 hw/ppc/Makefile.objs               |  1 +
 hw/ppc/spapr_cpu_package.c         | 50 ++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/spapr_cpu_package.h | 26 ++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 hw/ppc/spapr_cpu_package.c
 create mode 100644 include/hw/ppc/spapr_cpu_package.h
hw/ppc/Makefile.objs +1 -0
index c1ffc77..3000982 100644
@@ -4,6 +4,7 @@ obj-y += ppc.o ppc_booke.o
 obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
 obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o
+obj-$(CONFIG_PSERIES) += spapr_cpu_package.o
 ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
 obj-y += spapr_pci_vfio.o
 endif
hw/ppc/spapr_cpu_package.c new file +18 -0
new file mode 100644
index 0000000..3120a16
@@ -0,0 +1,50 @@
+/*
+ * sPAPR CPU package device, acts as container of CPU thread devices.
+ *
+ * Copyright (C) 2016 Bharata B Rao <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/cpu/package.h"
+#include "hw/ppc/spapr_cpu_package.h"
+#include "hw/boards.h"
+#include <sysemu/cpus.h>
+#include "qemu/error-report.h"
+
+static void spapr_cpu_package_instance_init(Object *obj)
+{
+    int i;
+    CPUState *cpu;
Quoted 8 lines

hw/ppc/spapr_cpu_package.c line 24

Quoted 6 lines
hw/ppc/spapr_cpu_package.c new file +6 -0
+    MachineState *machine = MACHINE(qdev_get_machine());
+    sPAPRCPUPackage *package = SPAPR_CPU_PACKAGE(obj);
+
+    /* Create as many CPU threads as specified in the topology */
+    for (i = 0; i < smp_threads; i++) {
+        cpu = cpu_generic_init(machine->cpu_type, machine->cpu_model);

No, no, no. This is horribly violating QOM design.

Quoted 5 lines

Ok.. why? There does not, to me, seem to be any remotely easily discoverable means of finding out what QOM design principles are.

It also would have been nice if you weighed in on my RFC this code is based on.

It would've been nice had you joined our KVM call prompted by _your_ suggestions (which again you could've discussed at KVM Forum where I had a session specifically for discussing this topic), but you didn't. I did discuss several aspects on the call and in the recorded session and will not write it by email again. Feel free to put it on the call agenda again.

I told Bharata that you can't have a base type that suddenly mutates its topology, therefore we discussed the possibility of having a QOM _interface_, not a base type as apparently done here. We deliberately do not have multi-inheritence in QOM; there's not just ppc in the world.

My time for reading list mails is limited. Make it easy for me to understand what the difference is between your package and my core and why instead of reusing my posted cpu-core type you need to propose your own cpu-package type. In one point you are right, we keep going in circles and sometimes backwards rather than forward here.

Andreas

Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
#9 lore raw

Re: [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device

Quoted 70 lines · Andreas Färber

Am 22.02.2016 um 08:47 schrieb David Gibson:

Quoted 69 lines · Andreas Färber
Quoted 54 lines

Am 22.02.2016 um 06:01 schrieb Bharata B Rao:

Quoted 53 lines

sPAPR CPU core device is a container of CPU thread devices. CPU hotplug is performed in the granularity of CPU core device by setting the "realized" property of this device to "true". When hotplugged, CPU core creates CPU thread devices.

TODO: Right now allows for only homogeneous configurations as we depend on global smp_threads and machine->cpu_model.

---
 hw/ppc/Makefile.objs               |  1 +
 hw/ppc/spapr_cpu_package.c         | 50 ++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/spapr_cpu_package.h | 26 ++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 hw/ppc/spapr_cpu_package.c
 create mode 100644 include/hw/ppc/spapr_cpu_package.h
hw/ppc/Makefile.objs +1 -0
index c1ffc77..3000982 100644
@@ -4,6 +4,7 @@ obj-y += ppc.o ppc_booke.o
 obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
 obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o
+obj-$(CONFIG_PSERIES) += spapr_cpu_package.o
 ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
 obj-y += spapr_pci_vfio.o
 endif
hw/ppc/spapr_cpu_package.c new file +18 -0
new file mode 100644
index 0000000..3120a16
@@ -0,0 +1,50 @@
+/*
+ * sPAPR CPU package device, acts as container of CPU thread devices.
+ *
+ * Copyright (C) 2016 Bharata B Rao <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/cpu/package.h"
+#include "hw/ppc/spapr_cpu_package.h"
+#include "hw/boards.h"
+#include <sysemu/cpus.h>
+#include "qemu/error-report.h"
+
+static void spapr_cpu_package_instance_init(Object *obj)
+{
+    int i;
+    CPUState *cpu;
Quoted 8 lines

hw/ppc/spapr_cpu_package.c line 24

Quoted 6 lines
hw/ppc/spapr_cpu_package.c new file +6 -0
+    MachineState *machine = MACHINE(qdev_get_machine());
+    sPAPRCPUPackage *package = SPAPR_CPU_PACKAGE(obj);
+
+    /* Create as many CPU threads as specified in the topology */
+    for (i = 0; i < smp_threads; i++) {
+        cpu = cpu_generic_init(machine->cpu_type, machine->cpu_model);

No, no, no. This is horribly violating QOM design.

Ok.. why? There does not, to me, seem to be any remotely easily discoverable means of finding out what QOM design principles are.

It also would have been nice if you weighed in on my RFC this code is based on.

So, first, apologies for my grumpy tone. This is just one of a number of frustrations I've had in the last few days, putting me in an uncharitable frame of mind.

Quoted 2 lines

It would've been nice had you joined our KVM call prompted by _your_ suggestions

Ok, a) I was not aware that this call was prompted by my suggestions. I got some vague second hand notices about it; as I do about KVM calls from time to time, which I ignored, as usual, because b) the KVM call is at stupid o'clock for me.

Quoted 2 lines

(which again you could've discussed at KVM Forum where I had a session specifically for discussing this topic), but you didn't.

At KVM Forum, cpu hotplug wasn't yet on my radar.

Quoted 6 lines

I did discuss several aspects on the call and in the recorded session and will not write it by email again. Feel free to put it on the call agenda again.

I told Bharata that you can't have a base type that suddenly mutates its topology,

Ok, I'm not entirely sure what you mean by that. Do you mean the fact that the core object constructs its own sub-objects?

Quoted 3 lines

therefore we discussed the possibility of having a QOM _interface_, not a base type as apparently done here. We deliberately do not have multi-inheritence in QOM; there's not just ppc in the world.

So, in other discussions I've realised the package needs to be an interface, rather than a type. But the patch your objecting to here implements the spapr-core subtype. If that were implementing rather than inheriting "cpu-package" I don't see that it would really change the logic here.

Like you (I think) I do dislike the use of machine->cpu_type and machine->cpu_model. I just haven't figured out enough QOM to know how to avoid them. What is the QOM equivalent of, essentially, arguments to a constructor?

Quoted 3 lines

My time for reading list mails is limited. Make it easy for me to understand what the difference is between your package and my core and why instead of reusing my posted cpu-core type you need to propose your

Because my time for reading the list is also limited, so I haven't seen your cpu-core posting. I did see Bharata's earlier core based stuff which didn't seem to go over well either.

Quoted 2 lines

own cpu-package type. In one point you are right, we keep going in circles and sometimes backwards rather than forward here.

But, also, from what I can tell of those parts of the discussion I have seen, locking the hotplug at core level doesn't seem to work. It seems to create an awful backwards compatibility tangle for x86 which has existing thread-level hotplug, and I expect it would cause problems when we encounter a platform with socket level hotplug only (this seems very plausible for something modelling physical hotplug).

The idea of cpu-package was to abstract away the granularity of cpu hotplug from a fixed level of the socket/core/thread heirarchy, while still making that granularity easy to discover for management.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#10 lore raw

Re: [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device

In reply to Andreas Färber
Quoted 63 lines · Andreas Färber

Am 22.02.2016 um 06:01 schrieb Bharata B Rao:

Quoted 49 lines

sPAPR CPU core device is a container of CPU thread devices. CPU hotplug is performed in the granularity of CPU core device by setting the "realized" property of this device to "true". When hotplugged, CPU core creates CPU thread devices.

TODO: Right now allows for only homogeneous configurations as we depend on global smp_threads and machine->cpu_model.

---
 hw/ppc/Makefile.objs               |  1 +
 hw/ppc/spapr_cpu_package.c         | 50 ++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/spapr_cpu_package.h | 26 ++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 hw/ppc/spapr_cpu_package.c
 create mode 100644 include/hw/ppc/spapr_cpu_package.h
hw/ppc/Makefile.objs +1 -0
index c1ffc77..3000982 100644
@@ -4,6 +4,7 @@ obj-y += ppc.o ppc_booke.o
 obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
 obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o
+obj-$(CONFIG_PSERIES) += spapr_cpu_package.o
 ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
 obj-y += spapr_pci_vfio.o
 endif
hw/ppc/spapr_cpu_package.c new file +14 -0
new file mode 100644
index 0000000..3120a16
@@ -0,0 +1,50 @@
+/*
+ * sPAPR CPU package device, acts as container of CPU thread devices.
+ *
+ * Copyright (C) 2016 Bharata B Rao <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/cpu/package.h"
+#include "hw/ppc/spapr_cpu_package.h"
+#include "hw/boards.h"
+#include <sysemu/cpus.h>
+#include "qemu/error-report.h"
+

hw/ppc/spapr_cpu_package.c line 24

Quoted 10 lines
hw/ppc/spapr_cpu_package.c new file +10 -0
+static void spapr_cpu_package_instance_init(Object *obj)
+{
+    int i;
+    CPUState *cpu;
+    MachineState *machine = MACHINE(qdev_get_machine());
+    sPAPRCPUPackage *package = SPAPR_CPU_PACKAGE(obj);
+
+    /* Create as many CPU threads as specified in the topology */
+    for (i = 0; i < smp_threads; i++) {
+        cpu = cpu_generic_init(machine->cpu_type, machine->cpu_model);

No, no, no. This is horribly violating QOM design.

Quoted 1 line

Please compare the x86 RFC.

Are you referring to the in-place initialization of child objects like that you did in socket based x86 hotplug RFC last year ?

Regards,
Bharata.

#11 lore raw

Re: [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device

Am 22.02.2016 um 09:05 schrieb Bharata B Rao:

Quoted 64 lines · Andreas Färber
Quoted 63 lines

Am 22.02.2016 um 06:01 schrieb Bharata B Rao:

Quoted 49 lines

sPAPR CPU core device is a container of CPU thread devices. CPU hotplug is performed in the granularity of CPU core device by setting the "realized" property of this device to "true". When hotplugged, CPU core creates CPU thread devices.

TODO: Right now allows for only homogeneous configurations as we depend on global smp_threads and machine->cpu_model.

---
 hw/ppc/Makefile.objs               |  1 +
 hw/ppc/spapr_cpu_package.c         | 50 ++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/spapr_cpu_package.h | 26 ++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 hw/ppc/spapr_cpu_package.c
 create mode 100644 include/hw/ppc/spapr_cpu_package.h
hw/ppc/Makefile.objs +1 -0
index c1ffc77..3000982 100644
@@ -4,6 +4,7 @@ obj-y += ppc.o ppc_booke.o
 obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
 obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o
+obj-$(CONFIG_PSERIES) += spapr_cpu_package.o
 ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
 obj-y += spapr_pci_vfio.o
 endif
hw/ppc/spapr_cpu_package.c new file +14 -0
new file mode 100644
index 0000000..3120a16
@@ -0,0 +1,50 @@
+/*
+ * sPAPR CPU package device, acts as container of CPU thread devices.
+ *
+ * Copyright (C) 2016 Bharata B Rao <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/cpu/package.h"
+#include "hw/ppc/spapr_cpu_package.h"
+#include "hw/boards.h"
+#include <sysemu/cpus.h>
+#include "qemu/error-report.h"
+

hw/ppc/spapr_cpu_package.c line 24

Quoted 10 lines
hw/ppc/spapr_cpu_package.c new file +10 -0
+static void spapr_cpu_package_instance_init(Object *obj)
+{
+    int i;
+    CPUState *cpu;
+    MachineState *machine = MACHINE(qdev_get_machine());
+    sPAPRCPUPackage *package = SPAPR_CPU_PACKAGE(obj);
+
+    /* Create as many CPU threads as specified in the topology */
+    for (i = 0; i < smp_threads; i++) {
+        cpu = cpu_generic_init(machine->cpu_type, machine->cpu_model);

No, no, no. This is horribly violating QOM design.

Quoted 4 lines
Quoted 1 line

Please compare the x86 RFC.

Are you referring to the in-place initialization of child objects like that you did in socket based x86 hotplug RFC last year ?

Yes, in-place object_initialize() is one of two options. The other is using object_initialize() with g_try_malloc0() from property setters, like Alexey did for xics I think.

But mainly the idea is to not bend your QOM types to reuse the legacy glue but to use true QOM concepts in the design of those new objects.

If there is some big hurdle I'm missing, please say so openly.

Regards,
Andreas

Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
#12 lore raw

RFC PATCH 5/8 spapr: Convert boot CPUs into CPU core device initialization

In reply to Bharata B Rao

Initialize boot CPUs specified with -smp option as CPU core devices. Create as many CPU package devices as necessary to fit in max_cpus and populate (i,e., realize) only as many as required.

---
 hw/ppc/spapr.c                     | 31 +++++++++++++++++++++++--------
 include/hw/ppc/spapr_cpu_package.h |  1 +
 2 files changed, 24 insertions(+), 8 deletions(-)
hw/ppc/spapr.c +23 -8
index 3892a99..f3913b4 100644
@@ -64,6 +64,8 @@
 
 #include "hw/compat.h"
 #include "qemu-common.h"
+#include "hw/ppc/spapr_cpu_package.h"
+#include "monitor/monitor.h"
 
 #include <libfdt.h>
 
@@ -1739,7 +1741,6 @@ static void ppc_spapr_init(MachineState *machine)
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
-    PowerPCCPU *cpu;
     PCIHostState *phb;
     int i;
     MemoryRegion *sysmem = get_system_memory();
@@ -1753,6 +1754,8 @@ static void ppc_spapr_init(MachineState *machine)
     long load_limit, fw_size;
     bool kernel_le = false;
     char *filename;
+    int spapr_packages = smp_cpus / smp_threads;
+    int spapr_max_packages = max_cpus / smp_threads;
 
     msi_supported = true;
 
@@ -1825,13 +1828,18 @@ static void ppc_spapr_init(MachineState *machine)
     }
     machine->cpu_type = TYPE_POWERPC_CPU;
 
-    for (i = 0; i < smp_cpus; i++) {
-        cpu = cpu_ppc_init(machine->cpu_model);
-        if (cpu == NULL) {
-            error_report("Unable to find PowerPC CPU definition");
-            exit(1);
+    /*
+     * Create enough CPU package devices for max_cpus and realize the
+     * required number of them.
+     */
+    for (i = 0; i < spapr_max_packages; i++) {
+        Object *spapr_cpu_package  =
+            cpu_package_create_object(TYPE_SPAPR_CPU_PACKAGE, i, &error_fatal);
+
+        if (i < spapr_packages) {
+            object_property_set_bool(spapr_cpu_package, true, "realized",
+                                     &error_fatal);
         }
-        spapr_cpu_init(spapr, cpu, &error_fatal);
     }
 
     if (kvm_enabled()) {
@@ -2231,6 +2239,7 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
                                       DeviceState *dev, Error **errp)
 {
     sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(qdev_get_machine());
+    sPAPRMachineState *ms = SPAPR_MACHINE(hotplug_dev);
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
         int node;
@@ -2267,6 +2276,11 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
         }
 
         spapr_memory_plug(hotplug_dev, dev, node, errp);
+    } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+        CPUState *cs = CPU(dev);
+        PowerPCCPU *cpu = POWERPC_CPU(cs);
+
+        spapr_cpu_init(ms, cpu, errp);
     }
 }
 
@@ -2281,7 +2295,8 @@ static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev,
 static HotplugHandler *spapr_get_hotpug_handler(MachineState *machine,
                                              DeviceState *dev)
 {
-    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
+        object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         return HOTPLUG_HANDLER(machine);
     }
     return NULL;
include/hw/ppc/spapr_cpu_package.h +1 -0
index 547dbc1..a3810d8 100644
@@ -10,6 +10,7 @@
 #define HW_SPAPR_CPU_PACKAGE_H
 
 #include "hw/qdev.h"
+#include "hw/cpu/package.h"
 
 #define TYPE_SPAPR_CPU_PACKAGE "spapr-cpu-package"
 #define SPAPR_CPU_PACKAGE(obj) \
Signature · 1 line
2.1.0
#13 lore raw

RFC PATCH 6/8 spapr: CPU hotplug support

In reply to Bharata B Rao

Set up device tree entries for the hotplugged CPU core and use the exising EPOW event infrastructure to send CPU hotplug notification to the guest.

---
 hw/ppc/spapr.c         | 136 ++++++++++++++++++++++++++++++++++++++++++++++++-
 hw/ppc/spapr_events.c  |   3 ++
 hw/ppc/spapr_rtas.c    |  24 +++++++++
 include/hw/ppc/spapr.h |   1 +
 4 files changed, 163 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +135 -1
index f3913b4..0bbbaf8 100644
@@ -604,6 +604,18 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
     size_t page_sizes_prop_size;
     uint32_t vcpus_per_socket = smp_threads * smp_cores;
     uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
+    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(qdev_get_machine());
+    sPAPRDRConnector *drc;
+    sPAPRDRConnectorClass *drck;
+    int drc_index;
+
+    if (smc->dr_cpu_enabled) {
+        drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index);
+        g_assert(drc);
+        drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
+        drc_index = drck->get_index(drc);
+        _FDT((fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)));
+    }
 
     /* Note: we keep CI large pages off for now because a 64K capable guest
      * provisioned with large pages might otherwise try to map a qemu
@@ -988,6 +1000,16 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
         _FDT(spapr_drc_populate_dt(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYPE_LMB));
     }
 
+    if (smc->dr_cpu_enabled) {
+        int offset = fdt_path_offset(fdt, "/cpus");
+        ret = spapr_drc_populate_dt(fdt, offset, NULL,
+                                    SPAPR_DR_CONNECTOR_TYPE_CPU);
+        if (ret < 0) {
+            fprintf(stderr, "Couldn't set up CPU DR device tree properties\n");
+            exit(1);
+        }
+    }
+
     _FDT((fdt_pack(fdt)));
 
     if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {
@@ -1756,6 +1778,7 @@ static void ppc_spapr_init(MachineState *machine)
     char *filename;
     int spapr_packages = smp_cpus / smp_threads;
     int spapr_max_packages = max_cpus / smp_threads;
+    int smt = kvmppc_smt_threads();
 
     msi_supported = true;
 
@@ -1822,6 +1845,15 @@ static void ppc_spapr_init(MachineState *machine)
         spapr_validate_node_memory(machine, &error_fatal);
     }
 
+    if (smc->dr_cpu_enabled) {
+        for (i = 0; i < spapr_max_packages; i++) {
+            sPAPRDRConnector *drc =
+                spapr_dr_connector_new(OBJECT(spapr),
+                                       SPAPR_DR_CONNECTOR_TYPE_CPU, i * smt);
+            qemu_register_reset(spapr_drc_reset, drc);
+        }
+    }
+
     /* init CPUs */
     if (machine->cpu_model == NULL) {
         machine->cpu_model = kvm_enabled() ? "host" : "POWER7";
@@ -2235,6 +2267,88 @@ out:
     error_propagate(errp, local_err);
 }
 
+static void *spapr_populate_hotplug_cpu_dt(DeviceState *dev, CPUState *cs,
+                                           int *fdt_offset,
+                                           sPAPRMachineState *spapr)
+{
+    PowerPCCPU *cpu = POWERPC_CPU(cs);
+    DeviceClass *dc = DEVICE_GET_CLASS(cs);
+    int id = ppc_get_vcpu_dt_id(cpu);
+    void *fdt;
+    int offset, fdt_size;
+    char *nodename;
+
+    fdt = create_device_tree(&fdt_size);
+    nodename = g_strdup_printf("%s@%x", dc->fw_name, id);
+    offset = fdt_add_subnode(fdt, 0, nodename);
+
+    spapr_populate_cpu_dt(cs, fdt, offset, spapr);
+    g_free(nodename);
+
+    *fdt_offset = offset;
+    return fdt;
+}
+
+static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
+                            Error **errp)
+{
+    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(qdev_get_machine());
+    sPAPRMachineState *ms = SPAPR_MACHINE(qdev_get_machine());
+    sPAPRCPUPackage *package = SPAPR_CPU_PACKAGE(OBJECT(dev));
+    PowerPCCPU *cpu = package->thread0;
+    CPUState *cs = CPU(cpu);
+    int id = ppc_get_vcpu_dt_id(cpu);
+    sPAPRDRConnector *drc =
+        spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, id);
+    sPAPRDRConnectorClass *drck;
+    Error *local_err = NULL;
+    void *fdt = NULL;
+    int fdt_offset = 0;
+
+    if (!smc->dr_cpu_enabled) {
+        /*
+         * This is a cold plugged CPU core but the machine doesn't support
+         * DR. So skip the hotplug path ensuring that the core is brought
+         * up online with out an associated DR connector.
+         */
+        return;
+    }
+
+    g_assert(drc);
+
+    /*
+     * Setup CPU DT entries only for hotplugged CPUs. For boot time or
+     * coldplugged CPUs DT entries are setup in spapr_finalize_fdt().
+     */
+    if (qdev_hotplug) {
+        fdt = spapr_populate_hotplug_cpu_dt(dev, cs, &fdt_offset, ms);
+        dev->hotplugged = true;
+    }
+
+    drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
+    drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, &local_err);
+    if (local_err) {
+        g_free(fdt);
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    if (dev->hotplugged) {
+        /*
+         * Send hotplug notification interrupt to the guest only in case
+         * of hotplugged CPUs.
+         */
+        spapr_hotplug_req_add_by_index(drc);
+    } else {
+        /*
+         * Set the right DRC states for cold plugged CPU.
+         */
+        drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USABLE);
+        drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOLATED);
+    }
+    return;
+}
+
 static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
                                       DeviceState *dev, Error **errp)
 {
@@ -2279,8 +2393,25 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         CPUState *cs = CPU(dev);
         PowerPCCPU *cpu = POWERPC_CPU(cs);
+        int i;
+
+        if (!smc->dr_cpu_enabled && dev->hotplugged) {
+            error_setg(errp, "CPU hotplug not supported for this machine");
+            return;
+        }
+
+        /* Set NUMA node for the added CPUs  */
+        for (i = 0; i < nb_numa_nodes; i++) {
+            if (test_bit(cs->cpu_index, numa_info[i].node_cpu)) {
+                cs->numa_node = i;
+                break;
+            }
+        }
 
         spapr_cpu_init(ms, cpu, errp);
+        spapr_cpu_reset(cpu);
+    } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_PACKAGE)) {
+        spapr_core_plug(hotplug_dev, dev, errp);
     }
 }
 
@@ -2296,7 +2427,8 @@ static HotplugHandler *spapr_get_hotpug_handler(MachineState *machine,
                                              DeviceState *dev)
 {
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
-        object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+        object_dynamic_cast(OBJECT(dev), TYPE_CPU) ||
+        object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_PACKAGE)) {
         return HOTPLUG_HANDLER(machine);
     }
     return NULL;
@@ -2340,6 +2472,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id;
 
     smc->dr_lmb_enabled = true;
+    smc->dr_cpu_enabled = true;
     fwc->get_dev_path = spapr_get_fw_dev_path;
     nc->nmi_monitor_handler = spapr_nmi;
 }
@@ -2419,6 +2552,7 @@ static void spapr_machine_2_5_class_options(MachineClass *mc)
 
     spapr_machine_2_6_class_options(mc);
     smc->use_ohci_by_default = true;
+    smc->dr_cpu_enabled = false;
     SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_5);
 }
 
hw/ppc/spapr_events.c +3 -0
index f5eac4b..e50bb16 100644
@@ -437,6 +437,9 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,
     case SPAPR_DR_CONNECTOR_TYPE_LMB:
         hp->hotplug_type = RTAS_LOG_V6_HP_TYPE_MEMORY;
         break;
+    case SPAPR_DR_CONNECTOR_TYPE_CPU:
+        hp->hotplug_type = RTAS_LOG_V6_HP_TYPE_CPU;
+        break;
     default:
         /* we shouldn't be signaling hotplug events for resources
          * that don't support them
hw/ppc/spapr_rtas.c +24 -0
index 07ad672..ed19466 100644
@@ -34,6 +34,7 @@
 
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_vio.h"
+#include "hw/ppc/ppc.h"
 #include "qapi-event.h"
 #include "hw/boards.h"
 
@@ -160,6 +161,27 @@ static void rtas_query_cpu_stopped_state(PowerPCCPU *cpu_,
     rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
 }
 
+/*
+ * Set the timebase offset of the CPU to that of first CPU.
+ * This helps hotplugged CPU to have the correct timebase offset.
+ */
+static void spapr_cpu_update_tb_offset(PowerPCCPU *cpu)
+{
+    PowerPCCPU *fcpu = POWERPC_CPU(first_cpu);
+
+    cpu->env.tb_env->tb_offset = fcpu->env.tb_env->tb_offset;
+}
+
+static void spapr_cpu_set_endianness(PowerPCCPU *cpu)
+{
+    PowerPCCPU *fcpu = POWERPC_CPU(first_cpu);
+    PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(fcpu);
+
+    if (!pcc->interrupts_big_endian(fcpu)) {
+        cpu->env.spr[SPR_LPCR] |= LPCR_ILE;
+    }
+}
+
 static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
                            uint32_t token, uint32_t nargs,
                            target_ulong args,
@@ -196,6 +218,8 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
         env->nip = start;
         env->gpr[3] = r3;
         cs->halted = 0;
+        spapr_cpu_set_endianness(cpu);
+        spapr_cpu_update_tb_offset(cpu);
 
         qemu_cpu_kick(cs);
 
include/hw/ppc/spapr.h +1 -0
index 1f9e722..a9d98e7 100644
@@ -36,6 +36,7 @@ struct sPAPRMachineClass {
 
     /*< public >*/
     bool dr_lmb_enabled;       /* enable dynamic-reconfig/hotplug of LMBs */
+    bool dr_cpu_enabled;       /* enable dynamic-reconfig/hotplug of CPUs */
     bool use_ohci_by_default;  /* use USB-OHCI instead of XHCI */
 };
 
Signature · 1 line
2.1.0
#14 lore raw

RFC PATCH 7/8 qmp: Implement query cpu-packages

In reply to Bharata B Rao
---
 hw/cpu/package.c    | 19 +++++++++++++
 hw/ppc/spapr.c      | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/boards.h |  1 +
 qapi-schema.json    | 48 ++++++++++++++++++++++++++++++++
 4 files changed, 147 insertions(+)
hw/cpu/package.c +19 -0
index 259dbfa..4ff20fa 100644
@@ -7,7 +7,26 @@
  * See the COPYING file in the top-level directory.
  */
 #include "hw/cpu/package.h"
+#include "hw/boards.h"
 #include "qom/object_interfaces.h"
+#include "qmp-commands.h"
+#include "qapi/qmp/qerror.h"
+
+/*
+ * QMP: query cpu-pacakges
+ */
+CPUPackageInfoList *qmp_query_cpu_packages(Error **errp)
+{
+    MachineState *ms = MACHINE(qdev_get_machine());
+    MachineClass *mc = MACHINE_GET_CLASS(ms);
+
+    if (!mc->cpu_packages) {
+        error_setg(errp, QERR_UNSUPPORTED);
+        return NULL;
+    }
+
+    return mc->cpu_packages(ms);
+}
 
 Object *cpu_package_create_object(const char *typename, uint32_t index,
                                   Error **errp)
hw/ppc/spapr.c +79 -0

91 lines not on this page · raw message

include/hw/boards.h +1 -0
index cf95d10..66d8780 100644
@@ -99,6 +99,7 @@ struct MachineClass {
     HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
                                            DeviceState *dev);
     unsigned (*cpu_index_to_socket_id)(unsigned cpu_index);
+    CPUPackageInfoList *(*cpu_packages)(MachineState *machine);
 };
 
 /**
qapi-schema.json +48 -0

51 lines not on this page · raw message

Signature · 1 line
2.1.0
#15 lore raw

Re: [Qemu-devel] [RFC PATCH v0 7/8] qmp: Implement query cpu-packages

Quoted 11 lines · Bharata B Rao
---
 hw/cpu/package.c    | 19 +++++++++++++
 hw/ppc/spapr.c      | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/boards.h |  1 +
 qapi-schema.json    | 48 ++++++++++++++++++++++++++++++++
 4 files changed, 147 insertions(+)

+++ b/qapi-schema.json

qapi-schema.json line 4091

Quoted 9 lines
qapi-schema.json +6 -0
@@ -4083,3 +4083,51 @@
 ##
 { 'enum': 'ReplayMode',
   'data': [ 'none', 'record', 'play' ] }
+
+##
+# @CPUThreadInfo:
+#
+# Information about CPU Threads
+#

Missing documentation for the fields.

qapi-schema.json line 4096

Quoted 5 lines
qapi-schema.json +5 -0
+# Since: 2.6
+##
+
+{ 'struct': 'CPUInfo',
+  'data': { 'arch_id': 'int',

New QMP code should favor '-' over '_'; this should be 'arch-id'.

Review line 4097

Quoted 1 line
(quoted diff) +1 -0
+            'type': 'str',

Is this string free-form, or is it a finite set of values? If the latter, then it should be an enum type.

qapi-schema.json line 4102

Quoted 5 lines
qapi-schema.json +5 -0
+            '*thread': 'int',
+            '*core': 'int',
+            '*socket' : 'int',
+            '*node' : 'int',
+            '*qom_path': 'str'

'qom-path'. But this one is definitely free-form, so 'str' is right.

qapi-schema.json line 4110

Quoted 8 lines
qapi-schema.json +8 -0
+          }
+}
+
+##
+# @CPUPackageInfo:
+#
+# Information about CPU Packages
+#

Missing field documentation.

qapi-schema.json line 4119

Quoted 9 lines
qapi-schema.json +9 -0
+# Since: 2.6
+##
+
+{ 'struct': 'CPUPackageInfo',
+  'data': { '*id': 'str',
+            'type': 'str',
+            'qom_path': 'str',
+            'realized': 'bool',
+            'nr_cpus': 'int',

'nr-cpus'. Is this field redundant, given that the caller can just count the length of the 'cpus' array?

Quoted 15 lines
qapi-schema.json +14 -0
+            'cpus' : ['CPUInfo']
+          }
+}
+
+##
+# @query-cpu-packages:
+#
+# Returns information for all CPU packages
+#
+# Returns: a list of @CPUPackageInfo
+#
+# Since: 2.6
+##
+{ 'command': 'query-cpu-packages', 'returns': ['CPUPackageInfo'] }
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#16 lore raw

Re: [Qemu-devel] [RFC PATCH v0 7/8] qmp: Implement query cpu-packages

Quoted 32 lines · On Mon, 22 Feb 2016 09:49:40 -0700 Eric Blake <[email protected]> wrote:
Quoted 11 lines · Bharata B Rao
---
 hw/cpu/package.c    | 19 +++++++++++++
 hw/ppc/spapr.c      | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/boards.h |  1 +
 qapi-schema.json    | 48 ++++++++++++++++++++++++++++++++
 4 files changed, 147 insertions(+)

+++ b/qapi-schema.json

qapi-schema.json line 4091

Quoted 9 lines
qapi-schema.json +6 -0
@@ -4083,3 +4083,51 @@
 ##
 { 'enum': 'ReplayMode',
   'data': [ 'none', 'record', 'play' ] }
+
+##
+# @CPUThreadInfo:
+#
+# Information about CPU Threads
+#  

Missing documentation for the fields.

qapi-schema.json line 4096

Quoted 5 lines
qapi-schema.json +5 -0
+# Since: 2.6
+##
+
+{ 'struct': 'CPUInfo',
+  'data': { 'arch_id': 'int',  

New QMP code should favor '-' over '_'; this should be 'arch-id'.

Quoted 4 lines

Review line 4097

Quoted 1 line
(quoted diff) +1 -0
+            'type': 'str',  

Is this string free-form, or is it a finite set of values? If the latter, then it should be an enum type.

I'd say it's a limited set of values. The same applies to other targets. It's basically cpu_model translated into corresponding QOM type name.
Is there a way to auto-generate this QAPI enum dynamically?

Quoted 49 lines

qapi-schema.json line 4102

Quoted 6 lines
qapi-schema.json +5 -0
+            '*thread': 'int',
+            '*core': 'int',
+            '*socket' : 'int',
+            '*node' : 'int',
+            '*qom_path': 'str'  

'qom-path'. But this one is definitely free-form, so 'str' is right.

qapi-schema.json line 4110

Quoted 8 lines
qapi-schema.json +8 -0
+          }
+}
+
+##
+# @CPUPackageInfo:
+#
+# Information about CPU Packages
+#  

Missing field documentation.

qapi-schema.json line 4119

Quoted 9 lines
qapi-schema.json +9 -0
+# Since: 2.6
+##
+
+{ 'struct': 'CPUPackageInfo',
+  'data': { '*id': 'str',
+            'type': 'str',
+            'qom_path': 'str',
+            'realized': 'bool',
+            'nr_cpus': 'int',  

'nr-cpus'. Is this field redundant, given that the caller can just count the length of the 'cpus' array?

Quoted 15 lines
qapi-schema.json +14 -0
+            'cpus' : ['CPUInfo']
+          }
+}
+
+##
+# @query-cpu-packages:
+#
+# Returns information for all CPU packages
+#
+# Returns: a list of @CPUPackageInfo
+#
+# Since: 2.6
+##
+{ 'command': 'query-cpu-packages', 'returns': ['CPUPackageInfo'] }
#17 lore raw

RFC PATCH 8/8 hmp: Implement 'info cpu-slots'

In reply to Bharata B Rao
---
 hmp-commands-info.hx | 14 ++++++++++++++
 hmp.c                | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hmp.h                |  1 +
 3 files changed, 65 insertions(+)
hmp-commands-info.hx +14 -0
index 9b71351..6ca6da3 100644
@@ -786,6 +786,20 @@ STEXI
 Display the value of a storage key (s390 only)
 ETEXI
 
+    {
+        .name       = "cpu-packages",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show CPU packages",
+        .mhandler.cmd = hmp_info_cpu_packages,
+    },
+
+STEXI
+@item info cpu-packages
+@findex cpu-packages
+Show CPU packages
+ETEXI
+
 STEXI
 @end table
 ETEXI
hmp.c +50 -0

53 lines not on this page · raw message

hmp.h +1 -0
index a8c5b5a..f78f55f 100644
@@ -131,5 +131,6 @@ void hmp_rocker(Monitor *mon, const QDict *qdict);
 void hmp_rocker_ports(Monitor *mon, const QDict *qdict);
 void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict);
 void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict);
+void hmp_info_cpu_packages(Monitor *mon, const QDict *qdict);
 
 #endif
Signature · 1 line
2.1.0
#18 lore raw
In reply to Bharata B Rao
Quoted 22 lines · Bharata B Rao

Hi,

This is an attempt to implement David Gibson's RFC that was posted at
https://lists.gnu.org/archive/html/qemu-ppc/2016-02/msg00000.html
I am not sure if I have followed all the aspects of the RFC fully, but we can make changes going forward.

An example cpu-package implementation is done for sPAPR in this patchset. Hot removal is not yet done in this patchset.

For the command line,

-smp 8,sockets=1,cores=1,threads=8,maxcpus=16 -numa node,nodeid=0,cpus=0-7 -numa node,nodeid=1,cpus=8-15

the HMP query looks like this:

(qemu) info cpu-packages
CPU Package: ""
type: "spapr-cpu-package"
qom_path: "/machine/cpu-package[0]"
realized: true
nr_cpus: 8

Quoted 7 lines
  CPU: 0
    Type: "host-powerpc64-cpu"
    Arch ID: 0
    Thread: 0
    Core: 0
    Socket: 0
    Node: 0
      qom_path: "/machine/cpu-package[0]/thread[0]"

Missed qom_path.

Regards,
Bharata.

#19 lore raw
In reply to Bharata B Rao

Hi Bharata,

Am 22.02.2016 um 06:01 schrieb Bharata B Rao:

Quoted 4 lines

This is an attempt to implement David Gibson's RFC that was posted at
https://lists.gnu.org/archive/html/qemu-ppc/2016-02/msg00000.html
I am not sure if I have followed all the aspects of the RFC fully, but we can make changes going forward.

I am not familiar with David's RFC beyond what was portrayed on the KVM call - this is not what we discussed on the call and I don't like it.

Further, your commits are pretty cryptic to me. Please improve your commit messages.

For example, you add a cpu_type field and you assign it the value TYPE_POWERPC_CPU. That's not the user-chosen CPU type then, it's a base CPU type that cannot be instantiated. Either name it cpu_base_type or fill it in with proper values in one patch - that patch on its own does not create value and does not explain your claim:
"Storing CPU typename in MachineState lets us to create CPU threads for all architectures in uniform manner from arch-neutral code." I'm pretty sure that CPU threads cannot be created from that type, as it would run into an assertion.

Next, you make a functionally correct refactoring of cpu_generic_init(), but I don't understand why you duplicate that code. cpu_foo_init() still expects things to be realized, so instead of realizing once in a central place you do it in nine different places. Had you touched all helper functions we might be able to move that to three places, once for softmmu, once or twice for linux-user and once for bsd-user. But I rather get the feeling that you misunderstand those legacy helper functions, they're for -cpu handling and not to my knowledge used for cpu-add at all. You should not be using them and then won't need to touch them in this way. By using them in your supposedly QOM code you are hiding an object_new() call inside deep layers of helper functions instead of using QOM native functions such as object_initialize(), object_new() and object_property_set*().

Is "CPU package" some IBM sPAPR term? It is new to me and does not match -smp precedence, so I really don't think we should be forcing that term on all architectures for no good reason.

Regards,
Andreas

Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
#20 lore raw
Quoted 38 lines · Andreas Färber

Hi Bharata,

Am 22.02.2016 um 06:01 schrieb Bharata B Rao:

Quoted 4 lines

This is an attempt to implement David Gibson's RFC that was posted at
https://lists.gnu.org/archive/html/qemu-ppc/2016-02/msg00000.html
I am not sure if I have followed all the aspects of the RFC fully, but we can make changes going forward.

I am not familiar with David's RFC beyond what was portrayed on the KVM call - this is not what we discussed on the call and I don't like it.

Further, your commits are pretty cryptic to me. Please improve your commit messages.

For example, you add a cpu_type field and you assign it the value TYPE_POWERPC_CPU. That's not the user-chosen CPU type then, it's a base CPU type that cannot be instantiated. Either name it cpu_base_type or fill it in with proper values in one patch - that patch on its own does not create value and does not explain your claim:
"Storing CPU typename in MachineState lets us to create CPU threads for all architectures in uniform manner from arch-neutral code." I'm pretty sure that CPU threads cannot be created from that type, as it would run into an assertion.

Next, you make a functionally correct refactoring of cpu_generic_init(), but I don't understand why you duplicate that code. cpu_foo_init() still expects things to be realized, so instead of realizing once in a central place you do it in nine different places. Had you touched all helper functions we might be able to move that to three places, once for softmmu, once or twice for linux-user and once for bsd-user. But I rather get the feeling that you misunderstand those legacy helper functions, they're for -cpu handling and not to my knowledge used for cpu-add at all. You should not be using them and then won't need to touch them in this way. By using them in your supposedly QOM code you are hiding an object_new() call inside deep layers of helper functions instead of using QOM native functions such as object_initialize(), object_new() and object_property_set*().

Quoted 3 lines

Is "CPU package" some IBM sPAPR term? It is new to me and does not match -smp precedence, so I really don't think we should be forcing that term on all architectures for no good reason.

No, it's not an spapr term. *By design* it doesn't match -smp precedence, as noted elsewhere the point is to not lock the unit of hotplug granularity to a fixed level of the -smp heirarchy, because there doesn't seem to be a level there we can pick which works for all platforms.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#21 lore raw
In reply to Andreas Färber
Quoted 14 lines · Andreas Färber

Hi Bharata,

Am 22.02.2016 um 06:01 schrieb Bharata B Rao:

Quoted 4 lines

This is an attempt to implement David Gibson's RFC that was posted at
https://lists.gnu.org/archive/html/qemu-ppc/2016-02/msg00000.html
I am not sure if I have followed all the aspects of the RFC fully, but we can make changes going forward.

I am not familiar with David's RFC beyond what was portrayed on the KVM call - this is not what we discussed on the call and I don't like it.

Further, your commits are pretty cryptic to me. Please improve your commit messages.

Quoted 9 lines

For example, you add a cpu_type field and you assign it the value TYPE_POWERPC_CPU. That's not the user-chosen CPU type then, it's a base CPU type that cannot be instantiated. Either name it cpu_base_type or fill it in with proper values in one patch - that patch on its own does not create value and does not explain your claim:
"Storing CPU typename in MachineState lets us to create CPU threads for all architectures in uniform manner from arch-neutral code." I'm pretty sure that CPU threads cannot be created from that type, as it would run into an assertion.

Yes, that should have been called cpu_base_type.

Quoted 14 lines

Next, you make a functionally correct refactoring of cpu_generic_init(), but I don't understand why you duplicate that code. cpu_foo_init() still expects things to be realized, so instead of realizing once in a central place you do it in nine different places. Had you touched all helper functions we might be able to move that to three places, once for softmmu, once or twice for linux-user and once for bsd-user. But I rather get the feeling that you misunderstand those legacy helper functions, they're for -cpu handling and not to my knowledge used for cpu-add at all. You should not be using them and then won't need to touch them in this way. By using them in your supposedly QOM code you are hiding an object_new() call inside deep layers of helper functions instead of using QOM native functions such as object_initialize(), object_new() and object_property_set*().

The intention was to re-use this generic sounding (cpu_generic_init) routine with a bit of modification. But since it is a legacy helper as you mention, we should be fine with using object_new() and other QOM native functions directly.

Regards,
Bharata.