On Mon, Sep 14, 2015 at 10:11:50AM +0530, Bharata B Rao wrote: > On Mon, Sep 14, 2015 at 02:14:59PM +1000, David Gibson wrote: > > On Mon, Sep 14, 2015 at 09:37:16AM +0530, Bharata B Rao wrote: > > > On Mon, Sep 14, 2015 at 11:41:53AM +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[*], ...); > > > > > > > > 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=2T, 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=2T from ~20 minutes to ~4 seconds. > > > > > > > > Signed-off-by: David Gibson > > > > Cc: Bharata B Rao > > > > > > This patch works correctly with both CPU and memory hotplug. > > > > Care to send a Reviewed-by and/or Tested-by in that case? > > Sorry, > > Tested-by: Bharata B Rao If you could send one for the cleanup in 1/2 as well, that would be nice. -- 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