On Tue, 16 May 2017 15:15:23 -0700 Anthony Xu <anthony...@intel.com> wrote:
> If cpu-memory address space is same as memory address space, > use memory address space for cpu-memory address space. > > any memory region change causeaddress space to rebuild PhysPageMap, > rebuilding PhysPageMap is very expensive. > > removing cpu-memory address space reduces the guest boot time and > memory usage. > > Signed-off-by: Anthony Xu <anthony...@intel.com> > --- > cpus.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/cpus.c b/cpus.c > index 740b8dc..15c7a6a 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -1748,8 +1748,13 @@ void qemu_init_vcpu(CPUState *cpu) > /* If the target cpu hasn't set up any address spaces itself, > * give it the default one. > */ > - AddressSpace *as = address_space_init_shareable(cpu->memory, > - "cpu-memory"); > + AddressSpace *as; > + if (cpu->memory == address_space_memory.root) { > + address_space_memory.ref_count++; probably this would cause reference leak when vcpu is destroyed > + as = &address_space_memory; > + } else { > + as = address_space_init_shareable(cpu->memory, "cpu-memory"); > + } > cpu->num_ases = 1; > cpu_address_space_init(cpu, as, 0); > }