From: David Gibson <david@gibson.dropbear.id.au>
To: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: aik@ozlabs.ru, qemu-ppc@nongnu.org, agraf@suse.de, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH] spapr: Reduce creation of LMB DR connectors from O(n^3) to O(n^2)
Date: Mon, 14 Sep 2015 11:32:06 +1000 [thread overview]
Message-ID: <20150914013206.GB2547@voom.fritz.box> (raw)
In-Reply-To: <20150911161206.GM17433@in.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 3746 bytes --]
On Fri, Sep 11, 2015 at 09:42:06PM +0530, Bharata B Rao wrote:
> On Thu, Sep 10, 2015 at 04:28:25PM +1000, David Gibson wrote:
> > The dynamic reconfiguration (hotplug) code for the pseries machine type
> > uses a "DR connector" QOM object for each resource it will be possible
> > to hotplug. Each of these is added to its owner using
> > object_property_add_child(owner, "dr-connector[*], ...);
> >
> > This works ok for most cases, but gets ugly when allowing large amounts of
> > hotplugged RAM. For RAM, there's a DR connector object for every 256MB of
> > potential memory. So if maxmem=2T, for example, there are >250,000 objects
> > under the same parent.
>
> There is one LMB DRC object for every 256MB, so with 2T maxmem, there will be
> max 8192 LMB DRC objects.
Oops, that's embarrasing, I messed up my arithmetic. You're right,
only 8192 objects for a 2T guest. Still rather a lot.
> > The QOM interfaces aren't really designed for this. In particular
> > object_property_add() has O(n^2) time complexity (in the number of existing
> > children) for the [*] case. First it has a linear search through array
> > indices to find a free slot, each of which is attempted to a recursive call
> > to object_property_add() with a specific [N]. Those calls are O(n) because
> > there's a linear search through all properties to check for duplicates.
> >
> > For the specific case of DR connectors, we already have a sufficiently
> > unique index, so we don't need to use the [*] special behaviour. That lets
> > us reduce the total time for creating the DR objects from O(n^3) to O(n^2).
> >
> > O(n^2) is still kind of crappy, but it's enough to reduce the startup time
> > of qemu with maxmem=2T from ~20 minutes to ~4 seconds.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > ---
> > hw/ppc/spapr_drc.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> > index c1f664f..4cf3a9b 100644
> > --- a/hw/ppc/spapr_drc.c
> > +++ b/hw/ppc/spapr_drc.c
> > @@ -463,14 +463,16 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *owner,
> > {
> > sPAPRDRConnector *drc =
> > SPAPR_DR_CONNECTOR(object_new(TYPE_SPAPR_DR_CONNECTOR));
> > + char *prop_name = g_strdup_printf("dr-connector[%"PRIu32"]", id);
>
> This works only if memory hotplug alone is present. If CPU hotplug is also
> present, the lookup of DRC object for LMB DRC fails from ibm,cas call when
> the guest is booting.
Bother.
> I don't fully understand why it fails, but the object lookup doesn't seem to
> like duplicate names that we end up having here. With the above change, we
> can have duplicate prop_name under the same owner object (spapr machine
> object) due to both CPU and LMB DRC objects coming under the same parent.
So.. arguably having both types of connector under the same parent is
a mistake.
But in the short term, we should be able to fix that by using the DRC
index, instead of just the id as the property array index.
It means the indices won't be contiguous, but having something
meaningful in there is probably still better than the arbitrary index
that [*] will give us. Especially since, confusingly, the will look
like they're the LMB ID *until* you add CPU hotplug, and then they'll
get offset, maybe, depending on whether CPU or memory gets constructed
first.
Revised patch coming shortly.
--
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: Type: application/pgp-signature, Size: 819 bytes --]
prev parent reply other threads:[~2015-09-14 1:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-10 6:28 [Qemu-devel] [RFC PATCH] spapr: Reduce creation of LMB DR connectors from O(n^3) to O(n^2) David Gibson
2015-09-10 8:42 ` Peter Crosthwaite
2015-09-10 10:30 ` David Gibson
2015-09-11 12:43 ` Paolo Bonzini
2015-09-14 1:26 ` David Gibson
2015-09-11 16:12 ` Bharata B Rao
2015-09-14 1:32 ` David Gibson [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=20150914013206.GB2547@voom.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=bharata@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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).