From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de,
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, ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH v6 11/11] spapr: CPU hot unplug support
Date: Wed, 13 Jan 2016 12:34:29 +0530 [thread overview]
Message-ID: <20160113070429.GG11785@in.ibm.com> (raw)
In-Reply-To: <20160113045700.GA22925@voom.redhat.com>
On Wed, Jan 13, 2016 at 03:57:00PM +1100, David Gibson wrote:
> On Wed, Jan 13, 2016 at 09:40:54AM +0530, Bharata B Rao wrote:
> > On Tue, Jan 12, 2016 at 05:06:34PM +1100, David Gibson wrote:
> > > On Fri, Jan 08, 2016 at 12:25:19PM +0530, Bharata B Rao wrote:
> > > > Remove the CPU core device by removing the underlying CPU thread devices.
> > > > 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 <bharata@linux.vnet.ibm.com>
> > > > ---
> > > > hw/ppc/spapr.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++
> > > > include/hw/ppc/spapr.h | 6 +++
> > > > 2 files changed, 119 insertions(+)
> > > >
> > > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > > > index c2af9ca..43cb726 100644
> > > > --- a/hw/ppc/spapr.c
> > > > +++ b/hw/ppc/spapr.c
> > > > @@ -93,6 +93,9 @@
> > > >
> > > > #define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift))
> > > >
> > > > +static QLIST_HEAD(cpu_unplug_list, sPAPRCPUUnplug) cpu_unplug_list
> > > > + = QLIST_HEAD_INITIALIZER(cpu_unplug_list);
> > > > +
> > > > static XICSState *try_create_xics(const char *type, int nr_servers,
> > > > int nr_irqs, Error **errp)
> > > > {
> > > > @@ -2432,11 +2435,121 @@ 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_core_cleanup(void)
> > > > +{
> > > > + sPAPRCPUUnplug *unplug, *next;
> > > > + Object *cpu;
> > > > +
> > > > + QLIST_FOREACH_SAFE(unplug, &cpu_unplug_list, node, next) {
> > > > + cpu = unplug->cpu;
> > > > + object_unparent(cpu);
> > > > + QLIST_REMOVE(unplug, node);
> > > > + g_free(unplug);
> > > > + }
> > > > +}
> > > > +
> > > > +static void spapr_add_cpu_to_unplug_list(Object *cpu)
> > > > +{
> > > > + sPAPRCPUUnplug *unplug = g_malloc(sizeof(*unplug));
> > > > +
> > > > + unplug->cpu = cpu;
> > > > + QLIST_INSERT_HEAD(&cpu_unplug_list, unplug, node);
> > > > +}
> > > > +
> > > > +static int spapr_cpu_release(Object *obj, void *opaque)
> > > > +{
> > > > + DeviceState *dev = DEVICE(obj);
> > > > + CPUState *cs = CPU(dev);
> > > > + PowerPCCPU *cpu = POWERPC_CPU(cs);
> > > > +
> > > > + spapr_cpu_destroy(cpu);
> > > > + cpu_remove_sync(cs);
> > > > +
> > > > + /*
> > > > + * We are still walking the core object's children list, and
> > > > + * hence can't cleanup this CPU thread object just yet. Put
> > > > + * it on a list for later removal.
> > > > + */
> > > > + spapr_add_cpu_to_unplug_list(obj);
> > > > + return 0;
> > > > +}
> > > > +
> > > > +static void spapr_core_release(DeviceState *dev, void *opaque)
> > > > +{
> > > > + object_child_foreach(OBJECT(dev), spapr_cpu_release, opaque);
> > > > + spapr_cpu_core_cleanup();
> > > > + object_unparent(OBJECT(dev));
> > >
> > > I'd prefer to see the unplug_list as a local to this function (passed
> > > to spapr_cpu_release via opaque) rather than using a new global.
> >
> > Will try that in the next iteration.
> >
> > >
> > > > +}
> > > > +
> > > > +static int spapr_core_detach(Object *obj, void *opaque)
> > > > +{
> > > > + sPAPRCoreState *core = opaque;
> > > > + DeviceState *dev = DEVICE(obj);
> > > > + 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 (thread 0) will
> > > > + * continue and signal hot unplug event to the guest.
> > > > + */
> > >
> > > This seems silly. spapr_core_unplug() iterates through all the
> > > children only to have all of them except thread 0 ignore the call..
> > >
> > > Can't you just grab the first thread and do this logic directly from
> > > spapr_core_unplug()?
> >
> > If I purely rely on the children list of the core object like I am doing
> > here, I don't see how to grab the first thread object from the list w/o
> > doing what I am doing here. However I can store the first thread object
> > in the core object during the core object's instance_init and use it here.
> > Will give it a try in the next iteration.
>
> It should be accessible by name as "thread[0]" no?
Yes, like this AFAICS:
ObjectProperty *prop = object_property_find(OBJECT(core), "thread[0]", &local_err);
Object *thread = prop->opaque;
Storing the object pointer of the main thread in the core looks simpler to
me.
Regards,
Bharata.
prev parent reply other threads:[~2016-01-13 7:05 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
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 [this message]
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=20160113070429.GG11785@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).