qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: mdroth@linux.vnet.ibm.com, danielhb@linux.vnet.ibm.com,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org, lvivier@redhat.com,
	sjitindarsingh@gmail.com, bharata@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCHv2 3/8] spapr: Simplify unplug path
Date: Wed, 12 Jul 2017 12:31:48 +0200	[thread overview]
Message-ID: <20170712123148.3b4bc4f2@bahia.lan> (raw)
In-Reply-To: <20170712120451.198aef60@bahia.lan>

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

On Wed, 12 Jul 2017 12:04:51 +0200
Greg Kurz <groug@kaod.org> wrote:

> On Wed, 12 Jul 2017 15:53:12 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > spapr_lmb_release() and spapr_core_release() call hotplug_handler_unplug()
> > which after a bunch of indirection calls spapr_memory_unplug() or
> > spapr_core_unplug().  But we already know which is the appropriate thing
> > to call here, so we can just fold it directly into the release function.
> > 
> > Once that's done, there's no need for an hc->unplug method in the spapr
> > machine at all: since we also have an hc->unplug_request method, the
> > hotplug core will never use ->unplug.
> > 
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---  
> 
> Nice cleanup :)
> 
> Reviewed-by: Greg Kurz <groug@kaod.org>
> 
> >  hw/ppc/spapr.c | 54 ++++++++----------------------------------------------
> >  1 file changed, 8 insertions(+), 46 deletions(-)
> > 
> > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > index 2a059d5..ff2aa6b 100644
> > --- a/hw/ppc/spapr.c
> > +++ b/hw/ppc/spapr.c
> > @@ -2818,6 +2818,9 @@ void spapr_lmb_release(DeviceState *dev)
> >  {
> >      HotplugHandler *hotplug_ctrl = qdev_get_hotplug_handler(dev);
> >      sPAPRMachineState *spapr = SPAPR_MACHINE(hotplug_ctrl);

BTW, maybe you can also drop the hotplug_ctrl variable since it only has
one trivial user.

> > +    PCDIMMDevice *dimm = PC_DIMM(dev);
> > +    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
> > +    MemoryRegion *mr = ddc->get_memory_region(dimm);
> >      sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev));
> >  
> >      /* This information will get lost if a migration occurs
> > @@ -2838,18 +2841,7 @@ void spapr_lmb_release(DeviceState *dev)
> >       * Now that all the LMBs have been removed by the guest, call the
> >       * pc-dimm unplug handler to cleanup up the pc-dimm device.
> >       */
> > -    hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort);
> > -}
> > -
> > -static void spapr_memory_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
> > -                                Error **errp)
> > -{
> > -    sPAPRMachineState *ms = SPAPR_MACHINE(hotplug_dev);
> > -    PCDIMMDevice *dimm = PC_DIMM(dev);
> > -    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
> > -    MemoryRegion *mr = ddc->get_memory_region(dimm);
> > -
> > -    pc_dimm_memory_unplug(dev, &ms->hotplug_memory, mr);
> > +    pc_dimm_memory_unplug(dev, &spapr->hotplug_memory, mr);
> >      object_unparent(OBJECT(dev));
> >  }
> >  
> > @@ -2918,10 +2910,11 @@ static void *spapr_populate_hotplug_cpu_dt(CPUState *cs, int *fdt_offset,
> >      return fdt;
> >  }
> >  
> > -static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
> > -                              Error **errp)
> > +/* Callback to be called during DRC release. */
> > +void spapr_core_release(DeviceState *dev)
> >  {
> > -    MachineState *ms = MACHINE(qdev_get_machine());
> > +    HotplugHandler *hotplug_ctrl = qdev_get_hotplug_handler(dev);
> > +    MachineState *ms = MACHINE(hotplug_ctrl);

Same here.

> >      sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(ms);
> >      CPUCore *cc = CPU_CORE(dev);
> >      CPUArchId *core_slot = spapr_find_cpu_slot(ms, cc->core_id, NULL);
> > @@ -2945,15 +2938,6 @@ static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
> >      object_unparent(OBJECT(dev));
> >  }
> >  
> > -/* Callback to be called during DRC release. */
> > -void spapr_core_release(DeviceState *dev)
> > -{
> > -    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)
> > @@ -3159,27 +3143,6 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
> >      }
> >  }
> >  
> > -static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev,
> > -                                      DeviceState *dev, Error **errp)
> > -{
> > -    sPAPRMachineState *sms = SPAPR_MACHINE(qdev_get_machine());
> > -    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
> > -
> > -    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> > -        if (spapr_ovec_test(sms->ov5_cas, OV5_HP_EVT)) {
> > -            spapr_memory_unplug(hotplug_dev, dev, errp);
> > -        } else {
> > -            error_setg(errp, "Memory hot unplug not supported for this guest");
> > -        }
> > -    } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
> > -        if (!mc->has_hotpluggable_cpus) {
> > -            error_setg(errp, "CPU hot unplug not supported on this machine");
> > -            return;
> > -        }
> > -        spapr_core_unplug(hotplug_dev, dev, errp);
> > -    }
> > -}
> > -
> >  static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev,
> >                                                  DeviceState *dev, Error **errp)
> >  {
> > @@ -3397,7 +3360,6 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
> >      mc->get_hotplug_handler = spapr_get_hotplug_handler;
> >      hc->pre_plug = spapr_machine_device_pre_plug;
> >      hc->plug = spapr_machine_device_plug;
> > -    hc->unplug = spapr_machine_device_unplug;
> >      mc->cpu_index_to_instance_props = spapr_cpu_index_to_props;
> >      mc->possible_cpu_arch_ids = spapr_possible_cpu_arch_ids;
> >      hc->unplug_request = spapr_machine_device_unplug_request;  
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2017-07-12 10:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12  5:53 [Qemu-devel] [PATCHv2 0/8] spapr: DRC cleanups (part VI) David Gibson
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 1/8] spapr: Treat devices added before inbound migration as coldplugged David Gibson
2017-07-12  8:41   ` Greg Kurz
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 2/8] spapr: Remove 'awaiting_allocation' DRC flag David Gibson
2017-07-12  9:38   ` Laurent Vivier
2017-07-12 10:00   ` Greg Kurz
2017-07-12 11:05     ` David Gibson
2017-07-12 11:27       ` Greg Kurz
2017-07-12 17:04         ` Greg Kurz
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 3/8] spapr: Simplify unplug path David Gibson
2017-07-12 10:04   ` Greg Kurz
2017-07-12 10:31     ` Greg Kurz [this message]
2017-07-13  0:30       ` David Gibson
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 4/8] spapr: Refactor spapr_drc_detach() David Gibson
2017-07-12 11:47   ` Greg Kurz
2017-07-13  0:53     ` David Gibson
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 5/8] spapr: Cleanups relating to DRC awaiting_release field David Gibson
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 6/8] spapr: Consolidate DRC state variables David Gibson
2017-07-12 17:36   ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 7/8] spapr: Remove sPAPRConfigureConnectorState sub-structure David Gibson
2017-07-12 17:40   ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 8/8] spapr: Implement DR-indicator for physical DRCs only David Gibson
2017-07-12 17:44   ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
2017-07-12 13:48 ` [Qemu-devel] [Qemu-ppc] [PATCHv2 0/8] spapr: DRC cleanups (part VI) Daniel Henrique Barboza
2017-07-13  0:57   ` David Gibson
2017-07-13 10:13     ` Daniel Henrique Barboza
2017-07-14  6:53       ` David Gibson
2017-07-14 13:50         ` Daniel Henrique Barboza
2017-07-15  2:42           ` David Gibson
2017-07-13  1:09 ` [Qemu-devel] " David Gibson

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=20170712123148.3b4bc4f2@bahia.lan \
    --to=groug@kaod.org \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=danielhb@linux.vnet.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=sjitindarsingh@gmail.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).