From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc3LS-0003LH-4Q for qemu-devel@nongnu.org; Tue, 15 Sep 2015 23:25:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc3LQ-0007eM-Ks for qemu-devel@nongnu.org; Tue, 15 Sep 2015 23:25:18 -0400 Date: Wed, 16 Sep 2015 13:18:04 +1000 From: David Gibson Message-ID: <20150916031804.GZ2547@voom.fritz.box> References: <1442194913-26545-1-git-send-email-david@gibson.dropbear.id.au> <1442194913-26545-3-git-send-email-david@gibson.dropbear.id.au> <20150915040300.19285.85127@loki> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="L4xCDQ7GT+ph8Lmk" Content-Disposition: inline In-Reply-To: <20150915040300.19285.85127@loki> 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: Michael Roth Cc: aik@ozlabs.ru, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.com, pbonzini@redhat.com --L4xCDQ7GT+ph8Lmk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 14, 2015 at 11:03:00PM -0500, Michael Roth wrote: > 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[*], ...); > >=20 > > That works ok, mostly, but it means that the property indices are > > arbitrary, depending on the order in which the connectors are construct= ed. > > 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. > >=20 > > 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 pare= nt. > >=20 > > The QOM interfaces aren't really designed for this. In particular > > object_property_add() with [*] has O(n^2) time complexity (in the numbe= r 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. > >=20 > > By using a meaningful index value, which we already know is unique we c= an > > avoid the [*] special behaviour. That lets us reduce the total time for > > creating the DR objects from O(n^3) to O(n^2). > >=20 > > O(n^2) is still kind of crappy, but it's enough to reduce the startup t= ime > > of qemu with maxmem=3D2T from ~20 minutes to ~4 seconds. > >=20 > > Signed-off-by: David Gibson > > Cc: Bharata B Rao >=20 > 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. Oh, there's no question that could be done. The question is: is thousands of QOM objects under a single parent a use case that we actually want to build QOM for? > 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. >=20 > Reviewed-by: Michael Roth >=20 > > --- > > hw/ppc/spapr_drc.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > >=20 > > 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 *= owner, > > { > > sPAPRDRConnector *drc =3D > > SPAPR_DR_CONNECTOR(object_new(TYPE_SPAPR_DR_CONNECTOR)); > > + char *prop_name; > >=20 > > g_assert(type); > >=20 > > drc->type =3D type; > > drc->id =3D id; > > - object_property_add_child(owner, "dr-connector[*]", OBJECT(drc), N= ULL); > > + prop_name =3D g_strdup_printf("dr-connector[%"PRIu32"]", get_index= (drc)); > > + object_property_add_child(owner, prop_name, OBJECT(drc), NULL); > > object_property_set_bool(OBJECT(drc), true, "realized", NULL); > > + g_free(prop_name); > >=20 > > /* human-readable name for a DRC to encode into the DT > > * description. this is mainly only used within a guest in place >=20 --=20 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 --L4xCDQ7GT+ph8Lmk Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJV+N9sAAoJEGw4ysog2bOSY4UP/3bcyxgottxLlMVUkIP+8Y6Z 3gO4e4qDMD4PMYfUSRlXApYScLVt3UWiSvoklq84Ttm7oBgak3AmnyaEq0JRdAVj kLhqefj0aSKhwcsJtm5DBR0fw2e71y74yDscdZwY01Ej5bqNea4PhTsS9SJJMrGx SOpL2jRg2tUSzcT7Erz2qST9XYcNStLvh0fNljKmqcGMgb2ZCpeDtsDzL5oq/PXW aUzWGmCGyTnZm4DqYXQKHJV5DaWXRV4Vh2TJv99h6vxRAPvtQlxDHI93xylwydus Wh/jJoSUDYwej1Js3Y/RiZKvEn3E/aG3cei/rDwZ5HU4vIEaxXMSN0K08c4cPkjR ESxkBQKNfWEE8DRmyjWPTF8Oj+3HhV+IyEPf9XsqXpyiQryZ4ak/7Bj0C1Ms17PE NHBSB2TsStk/nXyxsCnLRWKWuWsRmP5hz11i1UVTmEbn6oLwYwHgtbDvcWj3yOc/ u3uUjdG1HJ5dIhYaZ/3BwLHzLKOU2jwBfbQkgCl8LT00oBH8MHOW8fqgNcFjr8vo Eniitw0LdvlZOLrtAR6se4LvsUDHeoRbRiTW3WdNMP9Ux8x9l/OJBKMQOFbyxl1Q tdsIDpTE1UwCDDbcEXZ8ChkL200u9W9ed5GqWSfVbyJbPVUe7QcGc+UsfVpGUWiJ +aY5BGA7tZckT7fcPf9K =C1Xs -----END PGP SIGNATURE----- --L4xCDQ7GT+ph8Lmk--