public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Joerg Roedel <joerg.roedel-5C7GfCeVMHo@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: large page support for kvm
Date: Thu, 31 Jan 2008 07:44:52 +0200	[thread overview]
Message-ID: <47A16054.6080201@qumranet.com> (raw)
In-Reply-To: <20080130184035.GS6960-5C7GfCeVMHo@public.gmane.org>

Joerg Roedel wrote:
> On Tue, Jan 29, 2008 at 07:20:12PM +0200, Avi Kivity wrote:
>
>   
>> Here's a rough sketch of my proposal:
>>
>> - For every memory slot, allocate an array containing one int for every 
>> potential large page included within that memory slot.  Each entry in 
>> the array contains the number of write-protected 4KB pages within the 
>> large page frame corresponding to that entry.
>>
>> For example, if we have a memory slot for gpas 1MB-1GB, we'd have an 
>> array of size 511, corresponding to the 511 2MB pages from 2MB upwards.  
>> If we shadow a pagetable at address 4MB+8KB, we'd increment the entry 
>> corresponding to the large page at 4MB.  When we unshadow that page, 
>> decrement the entry.
>>     
>
> You need to take care the the 2MB gpa is aligned 2 MB host physical to
> be able to map it correctly with a large pte. So maybe we need two
> memslots for 1MB-1GB. One for 1MB-2MB using normal 4kb pages and one
> from 2MB-1GB which can be allocated using HugeTLBfs.
>
>   

Another option is to allocate all memory starting from address zero 
using hugetlbfs, and pass 0-640K as one memslot and 1MB+ as another. In 
case the kernel needs to support both methods (e.g. it must handle a 
memslot that starts in the middle of a large page).

>> - If we attempt to shadow a large page (either a guest pse pte, or a 
>> real-mode pseudo pte), we check if the host page is a large page.  If 
>> so, we also check the write-protect count array.  If the result is zero, 
>> we create a shadow pse pte.
>>
>> - Whenever we write-protect a page, also zap any large-page mappings for 
>> that page.  This means rmap will need some extension to handle pde rmaps 
>> in addition to pte rmaps.
>>     
>
> This sounds straight forward to me. All you need is a short value for
> every potential large page and initialize it with -1 if the host page is
> a large page and with 0 otherwise. Every time this value reaches -1 we
> can map the page with a large pte (and the guest maps with large pte).
>
>   

You don't know whether the host page is a large page in advance. It 
needs to be checked during pagefault time.

>> - qemu is extended to have a command-line option to use large pages to 
>> back guest memory.
>>
>> Large pages should improve performance significantly, both with 
>> traditional shadow and npt/ept.
>>     
>
> Yes, I think that too. But with shadow paging it really depends on the
> guest if the performance increasement is long-term. In a Linux guest,
> for example, the direct mapped memory will become fragmented over
> time (together with the location of the page tables). So the
> number of potential large page mappings will likely decrease over
> time.
>
>   

Yes, that's why it is important to be able to fail fast when checking 
whether we can use a large spte.


-- 
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

  parent reply	other threads:[~2008-01-31  5:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-29 17:20 large page support for kvm Avi Kivity
     [not found] ` <479F604C.20107-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-30 18:40   ` Joerg Roedel
     [not found]     ` <20080130184035.GS6960-5C7GfCeVMHo@public.gmane.org>
2008-01-31  5:44       ` Avi Kivity [this message]
2008-02-11 15:49         ` Marcelo Tosatti
2008-02-12 11:55           ` Avi Kivity
2008-02-13  0:15             ` Marcelo Tosatti
2008-02-13  6:45               ` Avi Kivity
2008-02-14 23:17                 ` Marcelo Tosatti
2008-02-15  7:40                   ` Roedel, Joerg
2008-02-17  9:38                   ` Avi Kivity
2008-02-19 20:37                     ` Marcelo Tosatti
2008-02-20 14:25                       ` Avi Kivity
2008-02-22  2:01                         ` Marcelo Tosatti
2008-02-22  7:16                           ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47A16054.6080201@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=joerg.roedel-5C7GfCeVMHo@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox