[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [RFC PATCH v4 10/11] spapr: CPU hot unplug support
From: |
Bharata B Rao |
Subject: |
[Qemu-ppc] [RFC PATCH v4 10/11] spapr: CPU hot unplug support |
Date: |
Thu, 6 Aug 2015 10:57:16 +0530 |
Support hot removal of CPU for sPAPR guests by sending the hot unplug
notification to the guest via EPOW interrupt. Release the vCPU object
after CPU hot unplug so that vCPU fd can be parked and reused.
Signed-off-by: Bharata B Rao <address@hidden>
---
hw/ppc/spapr.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 004a8e1..c05d85b 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2374,11 +2374,83 @@ static void spapr_machine_device_plug(HotplugHandler
*hotplug_dev,
}
}
+static void spapr_cpu_destroy(PowerPCCPU *cpu)
+{
+ sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
+
+ xics_cpu_destroy(spapr->icp, cpu);
+ qemu_unregister_reset(spapr_cpu_reset, cpu);
+}
+
+static void spapr_cpu_release(DeviceState *dev, void *opaque)
+{
+ CPUState *cs;
+ int i;
+ int id = ppc_get_vcpu_dt_id(POWERPC_CPU(CPU(dev)));
+
+ for (i = id; i < id + smp_threads; i++) {
+ CPU_FOREACH(cs) {
+ PowerPCCPU *cpu = POWERPC_CPU(cs);
+
+ if (i == ppc_get_vcpu_dt_id(cpu)) {
+ spapr_cpu_destroy(cpu);
+ cpu_remove(cs);
+ }
+ }
+ }
+}
+
+static int spapr_cpu_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
+ Error **errp)
+{
+ CPUState *cs = CPU(dev);
+ PowerPCCPU *cpu = POWERPC_CPU(cs);
+ int id = ppc_get_vcpu_dt_id(cpu);
+ int smt = kvmppc_smt_threads();
+ sPAPRDRConnector *drc =
+ spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, id);
+ sPAPRDRConnectorClass *drck;
+ Error *local_err = NULL;
+
+ /*
+ * SMT threads return from here, only main thread (core) will
+ * continue and signal hot unplug event to the guest.
+ */
+ if ((id % smt) != 0) {
+ return 0;
+ }
+ g_assert(drc);
+
+ drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
+ drck->detach(drc, dev, spapr_cpu_release, NULL, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return -1;
+ }
+
+ /*
+ * In addition to hotplugged CPUs, send the hot-unplug notification
+ * interrupt to the guest for coldplugged CPUs started via -device
+ * option too.
+ */
+ spapr_hotplug_req_remove_event(drc);
+
+ return 0;
+}
+
static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
+ sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(qdev_get_machine());
+
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
error_setg(errp, "Memory hot unplug not supported by sPAPR");
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+ if (!smc->dr_cpu_enabled) {
+ error_setg(errp, "CPU hot unplug not supported on this machine");
+ return;
+ }
+ spapr_cpu_unplug(hotplug_dev, dev, errp);
}
}
--
2.1.0
- [Qemu-ppc] [RFC PATCH v4 00/11] sPAPR CPU hotplug, Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 11/11] target-ppc: Enable CPU hotplug for POWER8 CPU family, Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 02/11] exec: Do vmstate unregistration from cpu_exec_exit(), Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 06/11] spapr: Create pseries-2.5 machine, Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 05/11] xics_kvm: Add cpu_destroy method to XICS, Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 07/11] spapr: Enable CPU hotplug for pseries-2.5 and add CPU DRC DT entries, Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 01/11] exec: Remove cpu from cpus list during cpu_exec_exit(), Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 03/11] cpus: Reclaim vCPU objects, Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 04/11] cpus: Add a sync version of cpu_remove(), Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 10/11] spapr: CPU hot unplug support,
Bharata B Rao <=
- [Qemu-ppc] [RFC PATCH v4 09/11] spapr: Support topologies with unfilled cores, Bharata B Rao, 2015/08/06
- [Qemu-ppc] [RFC PATCH v4 08/11] spapr: CPU hotplug support, Bharata B Rao, 2015/08/06
- Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH v4 00/11] sPAPR CPU hotplug, Zhu Guihua, 2015/08/06
- Re: [Qemu-ppc] [RFC PATCH v4 00/11] sPAPR CPU hotplug, David Gibson, 2015/08/11