qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: mdroth@linux.vnet.ibm.com, agraf@suse.de, ehabkost@redhat.com,
	qemu-devel@nongnu.org, pbonzini@redhat.com, qemu-ppc@nongnu.org,
	tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com,
	imammedo@redhat.com, afaerber@suse.de,
	david@gibson.dropbear.id.au
Subject: Re: [Qemu-devel] [PATCH v6 10/11] spapr: CPU hotplug support
Date: Wed, 13 Jan 2016 09:31:26 +0530	[thread overview]
Message-ID: <20160113040126.GD11785@in.ibm.com> (raw)
In-Reply-To: <5695930E.8030202@ozlabs.ru>

On Wed, Jan 13, 2016 at 10:58:06AM +1100, Alexey Kardashevskiy wrote:
> On 01/08/2016 05:55 PM, Bharata B Rao wrote:
> >Support CPU hotplug via device-add command like this:
> >
> >(qemu) device_add powerpc64-cpu-core,id=core2
> >
> >In response to device_add, CPU core device will be created. CPU core
> >device creates and realizes CPU thread devices. If the machine type
> >supports CPU hotplug, boot-time CPUs are created as CPU core devices
> >otherwise they continue to be created as individual CPU devices.
> >
> >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.
> >
> >Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> >---
> >  hw/ppc/spapr.c              | 183 ++++++++++++++++++++++++++++++++++++++++++--
> >  hw/ppc/spapr_events.c       |   3 +
> >  hw/ppc/spapr_rtas.c         |  24 ++++++
> >  include/hw/ppc/spapr.h      |   5 ++
> >  target-ppc/translate_init.c |   8 ++
> >  5 files changed, 216 insertions(+), 7 deletions(-)
> >
> >diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> >index a3ce1db..c2af9ca 100644
> >--- a/hw/ppc/spapr.c
> >+++ b/hw/ppc/spapr.c
> >@@ -63,6 +63,7 @@
> >
> >  #include "hw/compat.h"
> >  #include "qemu-common.h"
> >+#include "hw/ppc/cpu-core.h"
> >
> >  #include <libfdt.h>
> >
> >@@ -600,6 +601,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
> >@@ -1743,6 +1756,8 @@ static void ppc_spapr_init(MachineState *machine)
> >      char *filename;
> >      int smt = kvmppc_smt_threads();
> >      int smp_max_cores = max_cpus/smp_threads;
> >+    int spapr_smp_cores = smp_cpus/smp_threads;
> >+    Object *core;
> >
> >      msi_supported = true;
> >
> >@@ -1822,13 +1837,22 @@ static void ppc_spapr_init(MachineState *machine)
> >      if (machine->cpu_model == NULL) {
> >          machine->cpu_model = kvm_enabled() ? "host" : "POWER7";
> >      }
> >-    for (i = 0; i < smp_cpus; i++) {
> >-        cpu = cpu_ppc_init(machine->cpu_model);
> >-        if (cpu == NULL) {
> >-            fprintf(stderr, "Unable to find PowerPC CPU definition\n");
> >-            exit(1);
> >+
> >+    if (smc->dr_cpu_enabled) {
> >+        for (i = 0; i < spapr_smp_cores; i++) {
> >+            core = object_new(TYPE_POWERPC_CPU_CORE);
> >+            object_property_set_bool(core, true, "realized", &error_abort);
> >+        }
> >+    } else {
> >+        for (i = 0; i < smp_cpus; i++) {
> >+            cpu = cpu_ppc_init(machine->cpu_model);
> >+            if (cpu == NULL) {
> >+                fprintf(stderr, "Unable to find PowerPC CPU definition\n");
> >+                exit(1);
> >+            }
> >+            object_property_set_bool(OBJECT(cpu), true, "realized",
> >+                                     &error_abort);
> >          }
> >-        spapr_cpu_init(spapr, cpu);
> >      }
> >
> >      if (kvm_enabled()) {
> >@@ -2222,10 +2246,125 @@ 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 int spapr_core_attach(Object *obj, void *opaque)
> >+{
> >+    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(qdev_get_machine());
> >+    sPAPRMachineState *ms = SPAPR_MACHINE(qdev_get_machine());
> >+    sPAPRCoreState *core = opaque;
> >+    DeviceState *dev = DEVICE(obj);
> >+    CPUState *cs = CPU(dev);
> >+    PowerPCCPU *cpu = POWERPC_CPU(cs);
> >+    int id = ppc_get_vcpu_dt_id(cpu);
> >+    sPAPRDRConnector *drc =
> >+        spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, id);
> >+    sPAPRDRConnectorClass *drck;
> >+    int smt = kvmppc_smt_threads();
> >+    Error *local_err = NULL;
> >+    void *fdt = NULL;
> >+    int fdt_offset = 0;
> >+
> >+    /*
> >+     * Only main SMT thread (thread 0) will continue and signal the
> >+     * hotplug event to the guest. Other threads of the core will
> >+     * return from here.
> >+     */
> >+    if ((id % smt) != 0) {
> >+        return 0;
> >+    }
> >+
> >+    if (!smc->dr_cpu_enabled) {
> >+        /*
> >+         * This is a cold plugged CPU but the machine doesn't support
> >+         * DR. So skip the hotplug path ensuring that the CPU is brought
> >+         * up online with out an associated DR connector.
> >+         */
> >+        return 0;
> >+    }
> >+
> >+    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 (dev->hotplugged) {
> >+        fdt = spapr_populate_hotplug_cpu_dt(dev, cs, &fdt_offset, ms);
> >+    }
> 
> 
> spapr_core_attach() is only called from spapr_core_plug() which is only
> called from spapr_machine_device_plug() which is a hotplug handler so the
> check for dev->hotplugged seems redundant here and below, no? Or this is
> called at the boot time for cold-plug devices?

->plug() handler will be called for cold plugged CPUs too. For those CPUs
specified using -smp option and for those specified using -device option,
->plug() handler will be called because I am initializing these boot time
CPUs as CPU core devices.

Regards,
Bharata.

  reply	other threads:[~2016-01-13  4:01 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-08  6:55 [Qemu-devel] [PATCH v6 00/11] sPAPR CPU hotplug Bharata B Rao
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 01/11] machine: Don't allow CPU toplogies with partially filled cores Bharata B Rao
2016-01-12  4:03   ` David Gibson
2016-01-12 23:24   ` Alexey Kardashevskiy
2016-01-23 13:47   ` Eduardo Habkost
2016-01-25  8:57     ` Bharata B Rao
2016-01-26 17:47       ` Eduardo Habkost
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 02/11] exec: Remove cpu from cpus list during cpu_exec_exit() Bharata B Rao
2016-01-12  4:06   ` David Gibson
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 03/11] exec: Do vmstate unregistration from cpu_exec_exit() Bharata B Rao
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 04/11] cpu: Don't realize CPU from cpu_generic_init() Bharata B Rao
2016-01-12  4:09   ` David Gibson
2016-01-23 13:31   ` Eduardo Habkost
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 05/11] cpu: Reclaim vCPU objects Bharata B Rao
2016-01-12  4:13   ` David Gibson
2016-01-27 16:31   ` Matthew Rosato
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 06/11] cpu: Add a sync version of cpu_remove() Bharata B Rao
2016-01-12  4:16   ` David Gibson
2016-01-12  6:53     ` Bharata B Rao
2016-01-13  3:45       ` David Gibson
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 07/11] xics, xics_kvm: Handle CPU unplug correctly Bharata B Rao
2016-01-12  4:19   ` David Gibson
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 08/11] target-ppc: Introduce PowerPC specific CPU core device Bharata B Rao
2016-01-12  4:24   ` David Gibson
2016-01-12 23:30   ` Alexey Kardashevskiy
2016-01-12 23:44   ` Alexey Kardashevskiy
2016-01-13  4:30     ` Bharata B Rao
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 09/11] spapr: Enable CPU hotplug for pseries-2.6 and add CPU DRC DT entries Bharata B Rao
2016-01-12  5:41   ` David Gibson
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 10/11] spapr: CPU hotplug support Bharata B Rao
2016-01-12  5:58   ` David Gibson
2016-01-13  3:55     ` Bharata B Rao
2016-01-12 23:58   ` Alexey Kardashevskiy
2016-01-13  4:01     ` Bharata B Rao [this message]
2016-01-08  6:55 ` [Qemu-devel] [PATCH v6 11/11] spapr: CPU hot unplug support Bharata B Rao
2016-01-12  6:06   ` David Gibson
2016-01-13  4:10     ` Bharata B Rao
2016-01-13  4:57       ` David Gibson
2016-01-13  7:04         ` Bharata B Rao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160113040126.GD11785@in.ibm.com \
    --to=bharata@linux.vnet.ibm.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=nfont@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=tyreld@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).