memory: Create FlatView directly

This avoids usual memory_region_transaction_commit() which rebuilds
all FVs.

On POWER8 with 255 CPUs, 255 virtio-net, 40 PCI bridges guest this brings
down the boot time from 25s to 20s and reduces the amount of temporary FVs
allocated during machine constructon (~800000 -> ~640000) and amount of
temporary dispatch trees (~370000 -> ~300000), the total memory footprint
goes down (18G -> 17G).

Backports commit 202fc01b05572ecb258fdf4c5bd56cf6de8140c7 from qemu
This commit is contained in:
Alexey Kardashevskiy 2018-03-11 22:16:11 -04:00 committed by Lioncash
parent 1fd8b64072
commit 7eab335b2e
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -880,6 +880,18 @@ static void address_space_set_flatview(AddressSpace *as)
}
}
static void address_space_update_topology(AddressSpace *as)
{
MemoryRegion *physmr = memory_region_get_flatview_root(as->root);
struct uc_struct *uc = as->uc;
flatviews_init(uc);
if (!g_hash_table_lookup(uc->flat_views, physmr)) {
generate_memory_topology(physmr);
}
address_space_set_flatview(as);
}
void memory_region_transaction_begin(struct uc_struct *uc)
{
++uc->memory_region_transaction_depth;
@ -1883,15 +1895,14 @@ void address_space_init(struct uc_struct *uc, AddressSpace *as, MemoryRegion *ro
memory_init(uc);
}
memory_region_transaction_begin(uc);
memory_region_ref(root);
as->uc = uc;
as->root = root;
as->current_map = NULL;
QTAILQ_INIT(&as->listeners);
QTAILQ_INSERT_TAIL(&uc->address_spaces, as, address_spaces_link);
as->name = g_strdup(name ? name : "anonymous");
uc->memory_region_update_pending |= root->enabled;
memory_region_transaction_commit(uc);
address_space_update_topology(as);
}
static void do_address_space_destroy(AddressSpace *as)