All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] spapr: fix cpu core hotunplug call flow
@ 2017-02-02 15:02 Igor Mammedov
  2017-02-02 15:02 ` [Qemu-devel] [PATCH 1/3] spapr: cpu core: separate child threads destruction from machine state operations Igor Mammedov
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Igor Mammedov @ 2017-02-02 15:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson, Alexander Graf, qemu-ppc, Bharata B Rao

Make cpu core hotunplug use the same (expected)
unplug_request/unplug call flow like spapr memory unplug
and mem/cpu unplug on x86.

While doing it separate internal cpu core handling and
machine wiring code and move machine related callbacks
close to related machine code in spapr.c.

Series applies on top of tags/ppc-for-2.9-20170202 pull req.

repo for testing:
  git@github.com:imammedo/qemu.git spapr_cpu_unplug_cleanup

CC: David Gibson <david@gibson.dropbear.id.au> (supporter:sPAPR)
CC: Alexander Graf <agraf@suse.de> (supporter:sPAPR)
CC: qemu-ppc@nongnu.org 
CC: Bharata B Rao <bharata@linux.vnet.ibm.com>

Igor Mammedov (3):
  spapr: cpu core: separate child threads destruction from machine state
    operations
  spapr: move spapr_core_[foo]plug() callbacks close to machine code in
    spapr.c
  spapr: make cpu core unplug follow expected hotunplug call flow

 include/hw/ppc/spapr_cpu_core.h |   6 --
 hw/ppc/spapr.c                  | 150 +++++++++++++++++++++++++++++++++++++++-
 hw/ppc/spapr_cpu_core.c         | 137 +-----------------------------------
 3 files changed, 151 insertions(+), 142 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 1/3] spapr: cpu core: separate child threads destruction from machine state operations
  2017-02-02 15:02 [Qemu-devel] [PATCH 0/3] spapr: fix cpu core hotunplug call flow Igor Mammedov
@ 2017-02-02 15:02 ` Igor Mammedov
  2017-02-03  7:04   ` Bharata B Rao
  2017-02-02 15:02 ` [Qemu-devel] [PATCH 2/3] spapr: move spapr_core_[foo]plug() callbacks close to machine code in spapr.c Igor Mammedov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Igor Mammedov @ 2017-02-02 15:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson, Alexander Graf, qemu-ppc, Bharata B Rao

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/ppc/spapr_cpu_core.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 9dddaeb..b9e5f80 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -111,11 +111,19 @@ char *spapr_get_cpu_core_type(const char *model)
 
 static void spapr_core_release(DeviceState *dev, void *opaque)
 {
+    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
+    CPUCore *cc = CPU_CORE(dev);
+
+    spapr->cores[cc->core_id / smp_threads] = NULL;
+    object_unparent(OBJECT(dev));
+}
+
+static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp)
+{
     sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
     sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev));
     const char *typename = object_class_get_name(scc->cpu_class);
     size_t size = object_type_get_instance_size(typename);
-    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
     CPUCore *cc = CPU_CORE(dev);
     int i;
 
@@ -129,11 +137,7 @@ static void spapr_core_release(DeviceState *dev, void *opaque)
         cpu_remove_sync(cs);
         object_unparent(obj);
     }
-
-    spapr->cores[cc->core_id / smp_threads] = NULL;
-
     g_free(sc->threads);
-    object_unparent(OBJECT(dev));
 }
 
 void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
@@ -368,6 +372,7 @@ void spapr_cpu_core_class_init(ObjectClass *oc, void *data)
     sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_CLASS(oc);
 
     dc->realize = spapr_cpu_core_realize;
+    dc->unrealize = spapr_cpu_core_unrealizefn;
     scc->cpu_class = cpu_class_by_name(TYPE_POWERPC_CPU, data);
     g_assert(scc->cpu_class);
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 2/3] spapr: move spapr_core_[foo]plug() callbacks close to machine code in spapr.c
  2017-02-02 15:02 [Qemu-devel] [PATCH 0/3] spapr: fix cpu core hotunplug call flow Igor Mammedov
  2017-02-02 15:02 ` [Qemu-devel] [PATCH 1/3] spapr: cpu core: separate child threads destruction from machine state operations Igor Mammedov
@ 2017-02-02 15:02 ` Igor Mammedov
  2017-02-02 15:02 ` [Qemu-devel] [PATCH 3/3] spapr: make cpu core unplug follow expected hotunplug call flow Igor Mammedov
  2017-02-05 23:46 ` [Qemu-devel] [PATCH 0/3] spapr: fix cpu core " David Gibson
  3 siblings, 0 replies; 8+ messages in thread
From: Igor Mammedov @ 2017-02-02 15:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson, Alexander Graf, qemu-ppc, Bharata B Rao

spapr_core_pre_plug/spapr_core_plug/spapr_core_unplug() are managing
wiring CPU core into spapr machine state and not internal CPU core state.
So move them from spapr_cpu_core.c to spapr.c where other similar
(spapr_memory_[foo]plug()) callbacks are located, which also matches
x86 target practice.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/ppc/spapr_cpu_core.h |   6 --
 hw/ppc/spapr.c                  | 138 ++++++++++++++++++++++++++++++++++++++++
 hw/ppc/spapr_cpu_core.c         | 138 ----------------------------------------
 3 files changed, 138 insertions(+), 144 deletions(-)

diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_core.h
index 50292f4..3c35665 100644
--- a/include/hw/ppc/spapr_cpu_core.h
+++ b/include/hw/ppc/spapr_cpu_core.h
@@ -34,12 +34,6 @@ typedef struct sPAPRCPUCoreClass {
     ObjectClass *cpu_class;
 } sPAPRCPUCoreClass;
 
-void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
-                         Error **errp);
 char *spapr_get_cpu_core_type(const char *model);
-void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
-                     Error **errp);
-void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
-                       Error **errp);
 void spapr_cpu_core_class_init(ObjectClass *oc, void *data);
 #endif
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index e465d7a..8c2efd8 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2488,6 +2488,144 @@ void *spapr_populate_hotplug_cpu_dt(CPUState *cs, int *fdt_offset,
     return fdt;
 }
 
+static void spapr_core_release(DeviceState *dev, void *opaque)
+{
+    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
+    CPUCore *cc = CPU_CORE(dev);
+
+    spapr->cores[cc->core_id / smp_threads] = NULL;
+    object_unparent(OBJECT(dev));
+}
+
+static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
+                              Error **errp)
+{
+    CPUCore *cc = CPU_CORE(dev);
+    int smt = kvmppc_smt_threads();
+    int index = cc->core_id / smp_threads;
+    sPAPRDRConnector *drc =
+        spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * smt);
+    sPAPRDRConnectorClass *drck;
+    Error *local_err = NULL;
+
+    if (index == 0) {
+        error_setg(errp, "Boot CPU core may not be unplugged");
+        return;
+    }
+
+    g_assert(drc);
+
+    drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
+    drck->detach(drc, dev, spapr_core_release, NULL, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    spapr_hotplug_req_remove_by_index(drc);
+}
+
+static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
+                            Error **errp)
+{
+    sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
+    MachineClass *mc = MACHINE_GET_CLASS(spapr);
+    sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(dev));
+    CPUCore *cc = CPU_CORE(dev);
+    CPUState *cs = CPU(core->threads);
+    sPAPRDRConnector *drc;
+    Error *local_err = NULL;
+    void *fdt = NULL;
+    int fdt_offset = 0;
+    int index = cc->core_id / smp_threads;
+    int smt = kvmppc_smt_threads();
+
+    drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * smt);
+    spapr->cores[index] = OBJECT(dev);
+
+    g_assert(drc || !mc->query_hotpluggable_cpus);
+
+    /*
+     * Setup CPU DT entries only for hotplugged CPUs. For boot time or
+     * coldplugged CPUs DT entries are setup in spapr_build_fdt().
+     */
+    if (dev->hotplugged) {
+        fdt = spapr_populate_hotplug_cpu_dt(cs, &fdt_offset, spapr);
+    }
+
+    if (drc) {
+        sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
+        drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, &local_err);
+        if (local_err) {
+            g_free(fdt);
+            spapr->cores[index] = NULL;
+            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.
+         */
+        if (drc) {
+            sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
+            drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USABLE);
+            drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOLATED);
+        }
+    }
+}
+
+static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
+                                Error **errp)
+{
+    MachineState *machine = MACHINE(OBJECT(hotplug_dev));
+    MachineClass *mc = MACHINE_GET_CLASS(hotplug_dev);
+    sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
+    int spapr_max_cores = max_cpus / smp_threads;
+    int index;
+    Error *local_err = NULL;
+    CPUCore *cc = CPU_CORE(dev);
+    char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model);
+    const char *type = object_get_typename(OBJECT(dev));
+
+    if (dev->hotplugged && !mc->query_hotpluggable_cpus) {
+        error_setg(&local_err, "CPU hotplug not supported for this machine");
+        goto out;
+    }
+
+    if (strcmp(base_core_type, type)) {
+        error_setg(&local_err, "CPU core type should be %s", base_core_type);
+        goto out;
+    }
+
+    if (cc->core_id % smp_threads) {
+        error_setg(&local_err, "invalid core id %d", cc->core_id);
+        goto out;
+    }
+
+    index = cc->core_id / smp_threads;
+    if (index < 0 || index >= spapr_max_cores) {
+        error_setg(&local_err, "core id %d out of range", cc->core_id);
+        goto out;
+    }
+
+    if (spapr->cores[index]) {
+        error_setg(&local_err, "core %d already populated", cc->core_id);
+        goto out;
+    }
+
+out:
+    g_free(base_core_type);
+    error_propagate(errp, local_err);
+}
+
 static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
                                       DeviceState *dev, Error **errp)
 {
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index b9e5f80..55cd045 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -109,15 +109,6 @@ char *spapr_get_cpu_core_type(const char *model)
     return core_type;
 }
 
-static void spapr_core_release(DeviceState *dev, void *opaque)
-{
-    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
-    CPUCore *cc = CPU_CORE(dev);
-
-    spapr->cores[cc->core_id / smp_threads] = NULL;
-    object_unparent(OBJECT(dev));
-}
-
 static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp)
 {
     sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
@@ -140,135 +131,6 @@ static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp)
     g_free(sc->threads);
 }
 
-void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
-                       Error **errp)
-{
-    CPUCore *cc = CPU_CORE(dev);
-    int smt = kvmppc_smt_threads();
-    int index = cc->core_id / smp_threads;
-    sPAPRDRConnector *drc =
-        spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * smt);
-    sPAPRDRConnectorClass *drck;
-    Error *local_err = NULL;
-
-    if (index == 0) {
-        error_setg(errp, "Boot CPU core may not be unplugged");
-        return;
-    }
-
-    g_assert(drc);
-
-    drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
-    drck->detach(drc, dev, spapr_core_release, NULL, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-        return;
-    }
-
-    spapr_hotplug_req_remove_by_index(drc);
-}
-
-void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
-                     Error **errp)
-{
-    sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
-    MachineClass *mc = MACHINE_GET_CLASS(spapr);
-    sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(dev));
-    CPUCore *cc = CPU_CORE(dev);
-    CPUState *cs = CPU(core->threads);
-    sPAPRDRConnector *drc;
-    Error *local_err = NULL;
-    void *fdt = NULL;
-    int fdt_offset = 0;
-    int index = cc->core_id / smp_threads;
-    int smt = kvmppc_smt_threads();
-
-    drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * smt);
-    spapr->cores[index] = OBJECT(dev);
-
-    g_assert(drc || !mc->query_hotpluggable_cpus);
-
-    /*
-     * Setup CPU DT entries only for hotplugged CPUs. For boot time or
-     * coldplugged CPUs DT entries are setup in spapr_build_fdt().
-     */
-    if (dev->hotplugged) {
-        fdt = spapr_populate_hotplug_cpu_dt(cs, &fdt_offset, spapr);
-    }
-
-    if (drc) {
-        sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
-        drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, &local_err);
-        if (local_err) {
-            g_free(fdt);
-            spapr->cores[index] = NULL;
-            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.
-         */
-        if (drc) {
-            sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
-            drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USABLE);
-            drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOLATED);
-        }
-    }
-}
-
-void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
-                         Error **errp)
-{
-    MachineState *machine = MACHINE(OBJECT(hotplug_dev));
-    MachineClass *mc = MACHINE_GET_CLASS(hotplug_dev);
-    sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
-    int spapr_max_cores = max_cpus / smp_threads;
-    int index;
-    Error *local_err = NULL;
-    CPUCore *cc = CPU_CORE(dev);
-    char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model);
-    const char *type = object_get_typename(OBJECT(dev));
-
-    if (dev->hotplugged && !mc->query_hotpluggable_cpus) {
-        error_setg(&local_err, "CPU hotplug not supported for this machine");
-        goto out;
-    }
-
-    if (strcmp(base_core_type, type)) {
-        error_setg(&local_err, "CPU core type should be %s", base_core_type);
-        goto out;
-    }
-
-    if (cc->core_id % smp_threads) {
-        error_setg(&local_err, "invalid core id %d", cc->core_id);
-        goto out;
-    }
-
-    index = cc->core_id / smp_threads;
-    if (index < 0 || index >= spapr_max_cores) {
-        error_setg(&local_err, "core id %d out of range", cc->core_id);
-        goto out;
-    }
-
-    if (spapr->cores[index]) {
-        error_setg(&local_err, "core %d already populated", cc->core_id);
-        goto out;
-    }
-
-out:
-    g_free(base_core_type);
-    error_propagate(errp, local_err);
-}
-
 static void spapr_cpu_core_realize_child(Object *child, Error **errp)
 {
     Error *local_err = NULL;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 3/3] spapr: make cpu core unplug follow expected hotunplug call flow
  2017-02-02 15:02 [Qemu-devel] [PATCH 0/3] spapr: fix cpu core hotunplug call flow Igor Mammedov
  2017-02-02 15:02 ` [Qemu-devel] [PATCH 1/3] spapr: cpu core: separate child threads destruction from machine state operations Igor Mammedov
  2017-02-02 15:02 ` [Qemu-devel] [PATCH 2/3] spapr: move spapr_core_[foo]plug() callbacks close to machine code in spapr.c Igor Mammedov
@ 2017-02-02 15:02 ` Igor Mammedov
  2017-02-03  7:07   ` Bharata B Rao
  2017-02-05 23:46 ` [Qemu-devel] [PATCH 0/3] spapr: fix cpu core " David Gibson
  3 siblings, 1 reply; 8+ messages in thread
From: Igor Mammedov @ 2017-02-02 15:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson, Alexander Graf, qemu-ppc, Bharata B Rao

spapr_core_unplug() were essentially spapr_core_unplug_request()
handler that requested CPU removal and registered callback
which did actual cpu core removali but it was called from
spapr_machine_device_unplug() which is intended for actual object
removal. Commit (cf632463 spapr: Memory hot-unplug support)
sort of fixed it introducing spapr_machine_device_unplug_request()
and calling spapr_core_unplug() but it hasn't renamed callback and
by mistake calls it from spapr_machine_device_unplug().

However spapr_machine_device_unplug() isn't ever called for
cpu core since spapr_core_release() doesn't follow expected
hotunplug call flow which is:
 1: device_del() ->
        hotplug_handler_unplug_request() ->
            set destroy_cb()
 2: destroy_cb() ->
        hotplug_handler_unplug() ->
            object_unparent // actual device removal

Fix it by renaming spapr_core_unplug() to spapr_core_unplug_request()
which is called from spapr_machine_device_unplug_request() and
making spapr_core_release() call hotplug_handler_unplug() which
will call spapr_machine_device_unplug() -> spapr_core_unplug()
to remove cpu core.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/ppc/spapr.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 8c2efd8..37cb338 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2488,7 +2488,8 @@ void *spapr_populate_hotplug_cpu_dt(CPUState *cs, int *fdt_offset,
     return fdt;
 }
 
-static void spapr_core_release(DeviceState *dev, void *opaque)
+static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
+                              Error **errp)
 {
     sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
     CPUCore *cc = CPU_CORE(dev);
@@ -2497,8 +2498,17 @@ static void spapr_core_release(DeviceState *dev, void *opaque)
     object_unparent(OBJECT(dev));
 }
 
-static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
-                              Error **errp)
+static void spapr_core_release(DeviceState *dev, void *opaque)
+{
+    HotplugHandler *hotplug_ctrl;
+
+    hotplug_ctrl = qdev_get_hotplug_handler(dev);
+    hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort);
+}
+
+static
+void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev,
+                               Error **errp)
 {
     CPUCore *cc = CPU_CORE(dev);
     int smt = kvmppc_smt_threads();
@@ -2719,7 +2729,7 @@ static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev,
             error_setg(errp, "CPU hot unplug not supported on this machine");
             return;
         }
-        spapr_core_unplug(hotplug_dev, dev, errp);
+        spapr_core_unplug_request(hotplug_dev, dev, errp);
     }
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] spapr: cpu core: separate child threads destruction from machine state operations
  2017-02-02 15:02 ` [Qemu-devel] [PATCH 1/3] spapr: cpu core: separate child threads destruction from machine state operations Igor Mammedov
@ 2017-02-03  7:04   ` Bharata B Rao
  2017-02-03 10:51     ` [Qemu-devel] [PATCH v2 " Igor Mammedov
  0 siblings, 1 reply; 8+ messages in thread
From: Bharata B Rao @ 2017-02-03  7:04 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, David Gibson, Alexander Graf, qemu-ppc

On Thu, Feb 02, 2017 at 04:02:33PM +0100, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  hw/ppc/spapr_cpu_core.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 

I would mention explicitly that we are adding core unrealizefn and
doing threads' destruction from it now.

Otherwise, Reviewed-by: Bharata B Rao <bharata@linux.vnet.ibm.com>

Regards,
Bharata.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] spapr: make cpu core unplug follow expected hotunplug call flow
  2017-02-02 15:02 ` [Qemu-devel] [PATCH 3/3] spapr: make cpu core unplug follow expected hotunplug call flow Igor Mammedov
@ 2017-02-03  7:07   ` Bharata B Rao
  0 siblings, 0 replies; 8+ messages in thread
From: Bharata B Rao @ 2017-02-03  7:07 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, David Gibson, Alexander Graf, qemu-ppc

On Thu, Feb 02, 2017 at 04:02:35PM +0100, Igor Mammedov wrote:
> spapr_core_unplug() were essentially spapr_core_unplug_request()
> handler that requested CPU removal and registered callback
> which did actual cpu core removali but it was called from
> spapr_machine_device_unplug() which is intended for actual object
> removal. Commit (cf632463 spapr: Memory hot-unplug support)
> sort of fixed it introducing spapr_machine_device_unplug_request()
> and calling spapr_core_unplug() but it hasn't renamed callback and
> by mistake calls it from spapr_machine_device_unplug().
> 
> However spapr_machine_device_unplug() isn't ever called for
> cpu core since spapr_core_release() doesn't follow expected
> hotunplug call flow which is:
>  1: device_del() ->
>         hotplug_handler_unplug_request() ->
>             set destroy_cb()
>  2: destroy_cb() ->
>         hotplug_handler_unplug() ->
>             object_unparent // actual device removal
> 
> Fix it by renaming spapr_core_unplug() to spapr_core_unplug_request()
> which is called from spapr_machine_device_unplug_request() and
> making spapr_core_release() call hotplug_handler_unplug() which
> will call spapr_machine_device_unplug() -> spapr_core_unplug()
> to remove cpu core.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  hw/ppc/spapr.c | 18 ++++++++++++++----

Reveiwed-by: Bharata B Rao <bharata@linux.vnet.ibm.com>

Regards,
Bharata.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v2 1/3] spapr: cpu core: separate child threads destruction from machine state operations
  2017-02-03  7:04   ` Bharata B Rao
@ 2017-02-03 10:51     ` Igor Mammedov
  0 siblings, 0 replies; 8+ messages in thread
From: Igor Mammedov @ 2017-02-03 10:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: david, agraf, qemu-ppc

Split off destroying VCPU threads from drc callback
spapr_core_release() into new spapr_cpu_core_unrealizefn()
which takes care of internal cpu core state cleanup (i.e.
VCPU threads) and is called when object_unparent(core)
is called.

That leaves spapr_core_release() only with board mgmt
code, which will be moved to board related file in
follow up patch along with the rest on hotplug callbacks.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 hw/ppc/spapr_cpu_core.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 9dddaeb..b9e5f80 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -111,11 +111,19 @@ char *spapr_get_cpu_core_type(const char *model)
 
 static void spapr_core_release(DeviceState *dev, void *opaque)
 {
+    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
+    CPUCore *cc = CPU_CORE(dev);
+
+    spapr->cores[cc->core_id / smp_threads] = NULL;
+    object_unparent(OBJECT(dev));
+}
+
+static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp)
+{
     sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
     sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev));
     const char *typename = object_class_get_name(scc->cpu_class);
     size_t size = object_type_get_instance_size(typename);
-    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
     CPUCore *cc = CPU_CORE(dev);
     int i;
 
@@ -129,11 +137,7 @@ static void spapr_core_release(DeviceState *dev, void *opaque)
         cpu_remove_sync(cs);
         object_unparent(obj);
     }
-
-    spapr->cores[cc->core_id / smp_threads] = NULL;
-
     g_free(sc->threads);
-    object_unparent(OBJECT(dev));
 }
 
 void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
@@ -368,6 +372,7 @@ void spapr_cpu_core_class_init(ObjectClass *oc, void *data)
     sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_CLASS(oc);
 
     dc->realize = spapr_cpu_core_realize;
+    dc->unrealize = spapr_cpu_core_unrealizefn;
     scc->cpu_class = cpu_class_by_name(TYPE_POWERPC_CPU, data);
     g_assert(scc->cpu_class);
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] spapr: fix cpu core hotunplug call flow
  2017-02-02 15:02 [Qemu-devel] [PATCH 0/3] spapr: fix cpu core hotunplug call flow Igor Mammedov
                   ` (2 preceding siblings ...)
  2017-02-02 15:02 ` [Qemu-devel] [PATCH 3/3] spapr: make cpu core unplug follow expected hotunplug call flow Igor Mammedov
@ 2017-02-05 23:46 ` David Gibson
  3 siblings, 0 replies; 8+ messages in thread
From: David Gibson @ 2017-02-05 23:46 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Alexander Graf, qemu-ppc, Bharata B Rao

[-- Attachment #1: Type: text/plain, Size: 954 bytes --]

On Thu, Feb 02, 2017 at 04:02:32PM +0100, Igor Mammedov wrote:
> Make cpu core hotunplug use the same (expected)
> unplug_request/unplug call flow like spapr memory unplug
> and mem/cpu unplug on x86.
> 
> While doing it separate internal cpu core handling and
> machine wiring code and move machine related callbacks
> close to related machine code in spapr.c.
> 
> Series applies on top of tags/ppc-for-2.9-20170202 pull req.
> 
> repo for testing:
>   git@github.com:imammedo/qemu.git spapr_cpu_unplug_cleanup
> 
> CC: David Gibson <david@gibson.dropbear.id.au> (supporter:sPAPR)
> CC: Alexander Graf <agraf@suse.de> (supporter:sPAPR)
> CC: qemu-ppc@nongnu.org 
> CC: Bharata B Rao <bharata@linux.vnet.ibm.com>

Merged to ppc-for-2.9.

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-02-06  1:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-02 15:02 [Qemu-devel] [PATCH 0/3] spapr: fix cpu core hotunplug call flow Igor Mammedov
2017-02-02 15:02 ` [Qemu-devel] [PATCH 1/3] spapr: cpu core: separate child threads destruction from machine state operations Igor Mammedov
2017-02-03  7:04   ` Bharata B Rao
2017-02-03 10:51     ` [Qemu-devel] [PATCH v2 " Igor Mammedov
2017-02-02 15:02 ` [Qemu-devel] [PATCH 2/3] spapr: move spapr_core_[foo]plug() callbacks close to machine code in spapr.c Igor Mammedov
2017-02-02 15:02 ` [Qemu-devel] [PATCH 3/3] spapr: make cpu core unplug follow expected hotunplug call flow Igor Mammedov
2017-02-03  7:07   ` Bharata B Rao
2017-02-05 23:46 ` [Qemu-devel] [PATCH 0/3] spapr: fix cpu core " David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.