From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbhV2-0001zu-RC for qemu-devel@nongnu.org; Tue, 15 Sep 2015 00:05:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbhUz-0008T1-IU for qemu-devel@nongnu.org; Tue, 15 Sep 2015 00:05:44 -0400 Received: from e18.ny.us.ibm.com ([129.33.205.208]:50207) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbhUz-0008Sj-58 for qemu-devel@nongnu.org; Tue, 15 Sep 2015 00:05:41 -0400 Received: from /spool/local by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 Sep 2015 00:05:40 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1442194913-26545-3-git-send-email-david@gibson.dropbear.id.au> References: <1442194913-26545-1-git-send-email-david@gibson.dropbear.id.au> <1442194913-26545-3-git-send-email-david@gibson.dropbear.id.au> Message-ID: <20150915040300.19285.85127@loki> Date: Mon, 14 Sep 2015 23:03:00 -0500 Subject: Re: [Qemu-devel] [RFCv2 2/2] spapr: Don't use QOM [*] syntax for DR connectors. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , bharata@linux.vnet.ibm.com, aik@ozlabs.ru Cc: pbonzini@redhat.com, qemu-ppc@nongnu.org, agraf@suse.de, qemu-devel@nongnu.org Quoting David Gibson (2015-09-13 20:41:53) > 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[*], ...); > = > That works ok, mostly, but it means that the property indices are > arbitrary, depending on the order in which the connectors are constructed. > When we have both memory and cpu hotplug, the connectors will be under the > same parent (at least in the current drafts), meaning the indices don't > correspond to any meaningful ID. > = > It gets worse when large amounts of hotpluggable RAM is configured. For > RAM, there's a DR connector object for every 256MB of potential memory. = So > if maxmem=3D2T, for example, there are 8192 objects under the same parent. > = > The QOM interfaces aren't really designed for this. In particular > object_property_add() with [*] has O(n^2) time complexity (in the number = of > existing children): 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. > = > By using a meaningful index value, which we already know is unique we can > avoid 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=3D2T from ~20 minutes to ~4 seconds. > = > Signed-off-by: David Gibson > Cc: Bharata B Rao This is the second patch I've seen that drops use of "[*]" for performance reasons, but looking at the code I don't really see any reason that logic can't be implemented in object_property_add() in O(n) time. For instance I think it can be achieved by storing/hashing the base string to an array of auto-incremented indicies that we update whenever a child with the corresponding [n] format is added. I wouldn't hold this real fix up for that though, and in fact the use of DRC indexes make for much easier debugging anyway so I'd probably still prefer this approach anyway. Reviewed-by: Michael Roth > --- > hw/ppc/spapr_drc.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > = > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c > index 68e0c3e..2f95259 100644 > --- a/hw/ppc/spapr_drc.c > +++ b/hw/ppc/spapr_drc.c > @@ -451,13 +451,16 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *ow= ner, > { > sPAPRDRConnector *drc =3D > SPAPR_DR_CONNECTOR(object_new(TYPE_SPAPR_DR_CONNECTOR)); > + char *prop_name; > = > g_assert(type); > = > drc->type =3D type; > drc->id =3D id; > - object_property_add_child(owner, "dr-connector[*]", OBJECT(drc), NUL= L); > + prop_name =3D g_strdup_printf("dr-connector[%"PRIu32"]", get_index(d= rc)); > + object_property_add_child(owner, prop_name, OBJECT(drc), NULL); > object_property_set_bool(OBJECT(drc), true, "realized", NULL); > + g_free(prop_name); > = > /* human-readable name for a DRC to encode into the DT > * description. this is mainly only used within a guest in place > -- = > 2.4.3 >=20