From: Marcelo Tosatti Subject: Re: Single memory slot Date: Thu, 15 Oct 2009 16:49:48 -0300 Message-ID: <20091015194948.GB11656@amt.cnet> References: <4AD6D037.3060301@redhat.com> <6F43EB76-D20F-46A3-BDCF-F25928848C67@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , kvm-devel To: Alexander Graf Return-path: Received: from mx1.redhat.com ([209.132.183.28]:6879 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935396AbZJOTuk (ORCPT ); Thu, 15 Oct 2009 15:50:40 -0400 Content-Disposition: inline In-Reply-To: <6F43EB76-D20F-46A3-BDCF-F25928848C67@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Oct 15, 2009 at 02:46:38PM +0200, Alexander Graf wrote: > > On 15.10.2009, at 09:33, Avi Kivity wrote: > >> One way to improve the gfn_to_pfn() memslot search is to register just >> one slot. This can only work on 64-bit, since even the smallest guests >> need 4GB of physical address space. Apart from speeding up >> gfn_to_page(), it would also speed up mmio which must iterate over all >> slots, so a lookup cache cannot help. >> >> This would require quite a bunch of changes: >> - modify gfn_to_pfn() to fail gracefully if the page is in the slot >> but unmapped (hole handling) >> - modify qemu to reserve the guest physical address space >> - modify qemu memory allocation to use MAP_FIXED to allocate memory >> - some hack for the vga aliases (mmap an fd multiple times?) >> - some hack for the vmx-specific pages (e.g. APIC-access page) >> >> Not sure it's worthwhile, but something to keep in mind if a simple >> cache or sort by size is insufficient due to mmio. > > One thing I've been wondering for quite a while is that slot loop. Why > do we loop over all possible slots? Couldn't we just remember the max > extry (usually 1 or 2) and not loop MAX_SLOT_AMOUNT times? > > That would be a really easy patch and give instant speed improvements > for everyone. gfn_to_memslot_unaliased uses kvm->nmemslots which is the max entry. Oh, kvm_is_visible_gfn does not. It should just use gfn_to_memslot_unaliased.