public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: Zhao Forrest <forrest.zhao@gmail.com>
Cc: kvm-devel@lists.sourceforge.net, Javier Guerra <javier@guerrag.com>
Subject: Re: KVM architecture docs
Date: Wed, 05 Mar 2008 08:10:23 +0200	[thread overview]
Message-ID: <47CE394F.1030604@qumranet.com> (raw)
In-Reply-To: <ac8af0be0803042205q61e2e189rd55fb00f160871ce@mail.gmail.com>

Zhao Forrest wrote:
>>> Normally swapping mechanism choose the Least Recently Used(LRU) pages
>>> of a process to be swapped out. When KVM uses MMU notifier in linux
>>> kernel to implement swapping for VM, could KVM choose LRU pages of a
>>> VM to swap out? If so, could you give a brief description about how
>>> this is implemented?
>>>
>>>       
>> The Linux memory manager approximates LRU by scanning pages for the
>> accessed bit, which is set in the pte by the processor when a page is
>> accessed through that pte. mmu notifiers provide a callback for the
>> check, so that kvm can check the accessed bit on the shadow ptes.
>>     
>
> If I understand correctly, when NPT is used by KVM in the future, this mmu
> notifier can't help much for swapping out pages used by VM, right?
>   

No, NPT does not change things materially.  Shadow page tables are still 
used, though instead of mapping guest virtual addresses to host physical 
addresses, they now translate guest physical addresses to host physical 
addresses.  Swapping and all the other goodies still work.

> That is, when NPT is used, a balloon para-virt driver running on gust
> OS might be more efficient for swapping, am I right?
>   

Ballooning is more efficient than swapping both with and without NPT.  
The problem with ballooning is that it requires guest cooperation.  The 
guest may not be able to balloon, or it may take a long time to balloon, 
while the host may need the memory immediately.  A rebooting guest also 
implicitly deflates its balloon, creating a large and unpredictable 
memory demand on the host.

A good solution needs to use ballooning with swapping as a fallback for 
guaranteeing that the system does not run out of memory.

A nice feature in 2.6.25 is the ability to select which guests will 
swap, via the memory controller feature (mlock() also works, but is 
relatively crude).

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
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/

  reply	other threads:[~2008-03-05  6:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-03 15:51 KVM architecture docs Alessandro Sardo
2008-03-03 18:23 ` Avi Kivity
2008-03-04  4:12   ` Zhao Forrest
2008-03-04  8:25     ` Avi Kivity
2008-03-04  9:02       ` Zhao Forrest
2008-03-04  9:21         ` Avi Kivity
2008-03-04 14:17           ` Javier Guerra
2008-03-04 15:08             ` Avi Kivity
2008-03-05  4:06               ` Zhao Forrest
2008-03-05  5:19                 ` Avi Kivity
2008-03-05  6:05                   ` Zhao Forrest
2008-03-05  6:10                     ` Avi Kivity [this message]
2008-03-05  6:38                     ` Avi Kivity
2008-03-05  6:51                   ` Zhao Forrest
2008-03-05  6:58                     ` 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=47CE394F.1030604@qumranet.com \
    --to=avi@qumranet.com \
    --cc=forrest.zhao@gmail.com \
    --cc=javier@guerrag.com \
    --cc=kvm-devel@lists.sourceforge.net \
    /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