kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Single memory slot
@ 2009-10-15  7:33 Avi Kivity
  2009-10-15 12:46 ` Alexander Graf
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Avi Kivity @ 2009-10-15  7:33 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm-devel

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.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Single memory slot
  2009-10-15  7:33 Single memory slot Avi Kivity
@ 2009-10-15 12:46 ` Alexander Graf
  2009-10-15 19:49   ` Marcelo Tosatti
  2009-10-15 18:51 ` Anthony Liguori
  2009-10-15 19:46 ` Marcelo Tosatti
  2 siblings, 1 reply; 7+ messages in thread
From: Alexander Graf @ 2009-10-15 12:46 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, kvm-devel


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.

Alex


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Single memory slot
  2009-10-15  7:33 Single memory slot Avi Kivity
  2009-10-15 12:46 ` Alexander Graf
@ 2009-10-15 18:51 ` Anthony Liguori
  2009-10-15 23:43   ` Avi Kivity
  2009-10-15 19:46 ` Marcelo Tosatti
  2 siblings, 1 reply; 7+ messages in thread
From: Anthony Liguori @ 2009-10-15 18:51 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, kvm-devel

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

It could potentially speed up qemu quite a lot too as we would return to 
a model where host va == fixed address + guest pa.  That makes things 
like stl_phys/ldl_phys trivial.

Regards,

Anthony Liguori




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Single memory slot
  2009-10-15  7:33 Single memory slot Avi Kivity
  2009-10-15 12:46 ` Alexander Graf
  2009-10-15 18:51 ` Anthony Liguori
@ 2009-10-15 19:46 ` Marcelo Tosatti
  2009-10-15 23:48   ` Avi Kivity
  2 siblings, 1 reply; 7+ messages in thread
From: Marcelo Tosatti @ 2009-10-15 19:46 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel

On Thu, Oct 15, 2009 at 04:33:11PM +0900, 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.

Downside is you lose the ability to write protect a small slot only 
(could mprotect(MAP_READ) the desired area but get_log+write_protect 
must be atomic).

Also if you enable dirty log for the large slot largepages are disabled.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Single memory slot
  2009-10-15 12:46 ` Alexander Graf
@ 2009-10-15 19:49   ` Marcelo Tosatti
  0 siblings, 0 replies; 7+ messages in thread
From: Marcelo Tosatti @ 2009-10-15 19:49 UTC (permalink / raw)
  To: Alexander Graf; +Cc: Avi Kivity, kvm-devel

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Single memory slot
  2009-10-15 18:51 ` Anthony Liguori
@ 2009-10-15 23:43   ` Avi Kivity
  0 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2009-10-15 23:43 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Marcelo Tosatti, kvm-devel

On 10/16/2009 03:51 AM, Anthony Liguori wrote:
> 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
>
> It could potentially speed up qemu quite a lot too as we would return 
> to a model where host va == fixed address + guest pa.  That makes 
> things like stl_phys/ldl_phys trivial.

This doesn't work on 32-bit, and you still need to perform a lookup for 
mmio.  It just shortens the loop.

Note qemu can't depend on mmio holes being unmapped (you could trap the 
SEGV, but that would be unbearably slow).

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Single memory slot
  2009-10-15 19:46 ` Marcelo Tosatti
@ 2009-10-15 23:48   ` Avi Kivity
  0 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2009-10-15 23:48 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm-devel

On 10/16/2009 04:46 AM, Marcelo Tosatti wrote:
> On Thu, Oct 15, 2009 at 04:33:11PM +0900, 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.
>>      
> Downside is you lose the ability to write protect a small slot only
> (could mprotect(MAP_READ) the desired area but get_log+write_protect
> must be atomic).
>
> Also if you enable dirty log for the large slot largepages are disabled.
>    

I guess that shoots this idea down.  We could perhaps only enable it if 
a vnc client is not connected and we don't track vga updates.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-10-15 23:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-15  7:33 Single memory slot Avi Kivity
2009-10-15 12:46 ` Alexander Graf
2009-10-15 19:49   ` Marcelo Tosatti
2009-10-15 18:51 ` Anthony Liguori
2009-10-15 23:43   ` Avi Kivity
2009-10-15 19:46 ` Marcelo Tosatti
2009-10-15 23:48   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).